What is the difference between Expression Builder and Declare Variable in FYERS Automate?

What is the difference between Expression Builder and Declare Variable in FYERS Automate?

Expression Builder and Declare Variable can both use data sources, functions, arithmetic, and multi-step calculations. The difference is whether the value should continue to refresh or be captured once and retained.

Use Declare Variable for a snapshot. Use Expression Builder for a condition that must stay live.

Expression Builder vs Declare Variable

RequirementDeclare VariableExpression Builder
When it calculatesWhen the node executesWhenever its parent condition checks
Data source valuesCaptured and frozenRefreshed
Calculated outputRetained for the workflow runRecalculated
Best suited forRemembering a value or selectionMonitoring a changing condition
Option selectionCan keep one selected contract fixedCan reselect as data changes
Candle dataFixed captured windowMoving window
ArithmeticSupportedSupported
FunctionsSupportedSupported

When should I use Declare Variable?

Use it when the requirement includes concepts such as:

  • “Capture this value now.”
  • “Remember this price.”
  • “Use the same option for the rest of the run.”
  • “Save this average at market open.”

Examples:

  • Capture ATM CE LTP when the automation starts.
  • Save the previous-20-candle average at 9:20 AM.
  • Select the highest-OI PE at 9:20 AM and keep that same contract.

When should I use Expression Builder?

Use it when the value must continue changing with the data.

Examples:

  • Every minute, select whichever PE currently has the highest OI.
  • Recalculate the previous-20-candle average every five minutes.
  • Continuously calculate CE LTP + PE LTP.
  • Compare current P&L with a threshold.

When should I use both?

Use both when the strategy compares a saved reference value with something live.

For example:

“Alert when live LTP is 10% above the LTP when the automation started.”

Use:

  1. Declare Variable → capture the starting LTP.
  2. Expression Builder → fetch the live LTP.
  3. Expression Builder → compare the live LTP with the captured baseline.

When do I need neither?

If a normal Automate node already supports the exact requirement, use that node.

For example:

“Alert when RELIANCE LTP is above ₹3,000.”

No advanced calculated baseline is required.

What If?

ScenarioWhat to do
What if mathematics is involved?That alone does not determine which node to use. Both Declare Variable and Expression Builder support mathematics.
What if I need today's selected option to remain fixed?Use Declare Variable.
What if the selected option should change whenever the ranking changes?Use Expression Builder.
What if one part is fixed and another part is live?Use both. Declare Variable can retain the fixed value while Expression Builder evaluates the live value.

Last updated: 26 Aug 2026