Dynamic Variables
An overview of dynamic variables and how to use them
What Are Dynamic Strategy Variables?
Dynamic strategy variables in TradingView are placeholders that automatically populate with values from your TradingView strategy during execution. They are primarily used for strategies and can dynamically set parameters like:
Action: Whether to buy, sell, or close a position.
Quantity (Qty): The amount of an asset to trade.
How to Use Dynamic Strategy Variables in CrossTrade Alerts
1. Using Variables with the Alert Message Window
If your TradingView strategy generates dynamic variables for Action and Qty, you can integrate these into your CrossTrade alert. Here’s how:
Define the variables in your strategy.
In the alert's Message field, ensure that the placeholders (e.g.,
{{strategy.order.action}}
,{{strategy.order.qty}}
) are used.CrossTrade will interpret these placeholders and execute the corresponding actions on your connected trading platform.
Example:
If your strategy generates an alert with the following placeholders:
CrossTrade will process the alert dynamically, replacing the placeholders with the actual action (e.g., buy
, sell
) and quantity values defined by your strategy.
If you're trading futures, its best to use the variable {{strategy.order.contracts}}
2. Static Alerts for Indicators
Since indicators do not support dynamic variables, you must provide all required fields explicitly in the Message window. For example:
This ensures that CrossTrade receives complete and actionable instructions for your trades.
3. Customizing Alerts with Pine Script
For users with access to Pine Script, you can take full control of the alert payload by embedding the CrossTrade configuration directly into your script. This method ensures maximum flexibility and precision.
Steps:
Define the full CrossTrade payload in your Pine Script:
Call the payload in your alert configuration using the
{{strategy.order.alert_message}}
placeholder.
Example Alert:
Key Points to Remember
Strategies Only: Dynamic variables are exclusively for use with strategies. They are not supported for indicators.
Supported Fields: Only the Action and Qty fields can use dynamic variables in CrossTrade alerts.
Static Messages for Indicators: For indicators, you must manually provide all required details in the alert's Message window.
Last updated