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


    • Related Articles

    • What is Expression Builder in FYERS Automate, and when should I use it?

      Expression Builder is an advanced Automate node for conditions that depend on calculations, relationships between values, or data from one or more sources. Its data and calculations are evaluated again whenever its parent condition checks. Use it ...
    • What is Declare Variable in FYERS Automate, and when should I use it?

      Declare Variable is used when a strategy needs to capture or calculate a value at one point in the workflow and reuse that same result later. It calculates once and keeps its data source values and calculated outputs fixed for the rest of that ...
    • What is Backtest in FYERS Automate?

      Backtest in FYERS Automate helps you test an automation strategy using historical market data before running it live. It shows how the strategy would have performed in the past based on your selected time period, capital, slippage, and order ...
    • How are orders and prices matched in FYERS Automate Backtest?

      Backtest on FYERS Automate simulates order execution using historical market data. The orders in a backtest are considered as market orders, and the execution price for the market order is taken as the 1-minute candle close price. This helps the ...
    • How do I run a backtest in FYERS Automate?

      You can run a backtest from the Automate workflow after the strategy is ready for testing. The backtest uses your selected date range, capital, and slippage value to simulate how the strategy would have performed using historical data. Use this ...