- Accounts & Connection Management
- Data Management & Analysis
- Price Monitoring
- Charting
- Trading
- Scanners
-
Builders
-
Manual Strategy Builder
- Main Concept
- Operand Component
- Algo Elements
-
Use Cases
- How to create a condition on something crossing something
- How to create an indicator based on another indicator
- How to calculate a stop loss based on indicator
- How to submit stop order based on calculated price
- How to calculate a current bar price using a price type from inputs
- How to Use a Closed Bar Price
- Automatic Strategy Builder
-
Manual Strategy Builder
- Autotrading
- FinScript
- Trade Analysis
- Media Feeds
- Logs & Notifications
- UI & UX
Although variable declaration is not an action per se, it is considered an algo element because it can only be declared within the OnBarUpdate handler of a strategy in the Manual Strategy Builder (MSB).
Similarities and Differences with Input Parameters
Â
While local variable declarations share similarities with input parameter declarations, there are key differences:
Â
- Run-Time Calculation: A local variable's value can be dynamically calculated at run-time. For instance, a variable can be assigned a value derived from an indicator, the current price, another input parameter, a private member, or another variable.
- Scope: A local variable has a specific scope within the strategy. Any algo element higher up in the element tree cannot access this variable because it does not exist within their scope yet. This ensures that variables are only accessible within the context they are defined.
Â
Assigning Values to Local Variables
Â
When declaring a local variable, it must be assigned a value immediately. This value can be specified using the standard methods described in the "Operand Component" chapter. For example, a variable of type double could be declared to hold the last value of the Average True Range (ATR) indicator, multiplied by 2.
Conclusion
Â
Local variable declarations are a critical part of the MSB, allowing for dynamic and context-specific calculations within a strategy. By enabling values to be calculated at run-time and maintaining specific scopes, local variables provide flexibility and precision in strategy development. This capability ensures that complex strategies can be efficiently organized and executed within the OnBarUpdate handler, enhancing the overall functionality and adaptability of trading strategies in FinStudio.
- Accounts & Connection Management
- Data Management & Analysis
- Price Monitoring
- Charting
- Trading
- Scanners
-
Builders
-
Manual Strategy Builder
- Main Concept
- Operand Component
- Algo Elements
-
Use Cases
- How to create a condition on something crossing something
- How to create an indicator based on another indicator
- How to calculate a stop loss based on indicator
- How to submit stop order based on calculated price
- How to calculate a current bar price using a price type from inputs
- How to Use a Closed Bar Price
- Automatic Strategy Builder
-
Manual Strategy Builder
- Autotrading
- FinScript
- Trade Analysis
- Media Feeds
- Logs & Notifications
- UI & UX