What is Declare Variable in FYERS Automate, and when should I 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 workflow run.
Use it for a saved snapshot rather than a continuously refreshed condition.
When should I use Declare Variable?
Use Declare Variable when you need to:
Capture LTP when the automation starts.
Remember a selected option contract for the current run.
Save the combined premium at a specific time.
Calculate and save a percentage above or below a captured value.
Calculate an average at market open and keep that result unchanged.
Pass a saved calculated result to later parts of the workflow.
Tip: Declare Variable is like a snapshot. It captures the required value at that point rather than continuing to refresh it.
Can Declare Variable perform calculations?
Yes.
Declare Variable can:
Fetch data from one or more data sources.
Use supported functions.
Perform arithmetic.
Build calculations in several steps.
Pass a calculated value or selected symbol into later logic.
You should not choose Declare Variable simply because the strategy uses mathematics. Expression Builder also supports calculations.
The deciding factor is whether the result should remain fixed or live.
Example: Capture a starting price
“Alert when the live price is at least 10% above the price when the automation started.”
The workflow needs two different types of values:
Declare Variable captures the starting LTP.
Expression Builder reads the live LTP.
The captured LTP remains fixed while the live LTP continues to change.
What If?
Scenario
What to do
What if the value should refresh each time the condition is checked?
Use Expression Builder.
What if I select the highest-OI option at 9:20 AM and want to keep monitoring that same contract?
Use Declare Variable to save the selected symbol, then use that symbol in later live checks.
What if another option later becomes the highest-OI contract?
The saved symbol does not change during that workflow run because the Declare Variable result is already frozen.
What if the automation runs again?
Declare Variable calculates again when the node executes in the new workflow run.
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 ...
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 ...
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 ...
The place order action in Automate lets you place a live trade automatically when your automation reaches a specific trigger, condition, or step. Based on the order type you select, you can place options, futures, or a direct order for a symbol, and ...
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 ...