Introduction #
This guide covers the full setup of TradingView JSON alert configuration for automated trading. You’ll learn how to use JSON to send buy, sell, and close signals directly from TradingView strategies or indicators to your broker platform.
For a visual walkthrough, refer to the accompanying video:
1. Strategy JSON #
This JSON configuration is used for executing strategy-based automated trades in TradingView. Trades are executed based on predefined conditions within a TradingView strategy.
1.1 JSON Configuration #
{
"symbol": "NQ",
"date": "{{timenow}}",
"data": "{{strategy.order.action}}",
"quantity": "{{strategy.order.contracts}}",
"risk_percentage": 0,
"price": "{{close}}",
"tp": 0,
"percentage_tp": 0,
"dollar_tp": 0,
"sl": 0,
"dollar_sl": 0,
"percentage_sl": 0,
"trail": 0,
"trail_stop": 0,
"trail_trigger": 0,
"trail_freq": 0,
"update_tp": false,
"update_sl": false,
"breakeven": 0,
"token": "your_token_here",
"pyramid": true,
"reverse_order_close": false,
"account_id": "your_account_id",
"multiple_accounts": [
{
"token": "your_token_here",
"account_id": "FFFF",
"risk_percentage": 0,
"quantity_multiplier": 1
}
]
}
1.2 Parameter Explanation #
symbol #
- Represents the trading instrument (e.g.,
"NQ"
for Nasdaq futures). - If using TradingView, ensure the symbol is mapped correctly, especially for continuous contracts.
date #
- The timestamp when the order is sent (
"{{timenow}}"
).
data #
- Determines the action:
"buy"
,"sell"
, or"close"
. - For a strategy, this should be
{{strategy.order.action}}
.
quantity #
- Defines the trade size.
- Can be an absolute value (e.g.,
quantity: 2
) or a percentage-based risk calculation. - If
risk_percentage
is specified andquantity
is not provided, the system calculates the quantity based on the stop loss and account balance.
risk_percentage #
- Percentage of risk allocated to the trade.
- If specified, the system calculates the quantity based on the stop loss and account balance.
price #
- Sets the order execution price.
- If provided, the order will be placed as a limit order.
- If not provided, the latest close price will be used.
tp / percentage_tp / dollar_tp #
- Take Profit settings:
- If
tp
is provided, it is used directly. - If not specified, the system checks predefined settings and applies them automatically.
- If
sl / percentage_sl / dollar_sl #
- Stop Loss settings:
- If
sl
is provided, it is used directly. - If not specified, the system checks predefined settings and applies them automatically.
- If
update_tp #
true
: Updates an existing take profit order instead of placing a new one.false
: A new TP order will be created.
update_sl #
true
: Updates an existing stop loss order instead of placing a new one.false
: A new SL order will be created.
reverse_order_close #
true
: Closes any existing opposite position before executing the new trade.false
: No position closure before execution.
account_id #
- Defines the specific Tradovate account to be used.
- If not provided, the system defaults to the primary linked account.
2. Indicator JSON #
This JSON configuration is used for indicator-based trading signals. When a TradingView indicator generates a buy or sell signal, this JSON executes the trade.

2.1 JSON Configuration #
{
"symbol": "NQ",
"date": "{{timenow}}",
"data": "buy",
"quantity": 10,
"risk_percentage": 0,
"price": "{{close}}",
"gtd_in_second": 0,
"tp": 0,
"percentage_tp": 0,
"dollar_tp": 10,
"sl": 0,
"percentage_sl": 0,
"dollar_sl": 5,
"trail": 1,
"trail_stop": 3.75,
"trail_trigger": 5,
"trail_freq": 1.25,
"update_tp": false,
"update_sl": false,
"breakeven": 3.75,
"token": "your_token_here",
"pyramid": false,
"reverse_order_close": true,
"order_type": "MKT",
"account_id": "your_account_id",
"multiple_accounts": [
{
"token": "your_token_here",
"account_id": "df3321",
"risk_percentage": 0,
"quantity_multiplier": 1
}
]
}
2.2 Parameter Explanation #
symbol #
- Represents the trading instrument (e.g.,
"NQ"
for Nasdaq futures).
date #
- The timestamp when the order is sent (
"{{timenow}}"
).
data #
- Determines the action:
"buy"
,"sell"
, or"close"
. - For an indicator,
"buy"
or"sell"
must be explicitly set.
quantity #
- Defines trade size.
- If
risk_percentage
is set andquantity
is omitted, the system automatically calculates the quantity based on SL and available account balance.
price #
- Sets the entry price.
- If passed, the system treats the order as a limit order.
- If not passed, the system defaults to the latest close price.
tp / percentage_tp / dollar_tp #
- Take Profit settings:
- If
tp
is provided, it is used directly. - If not specified, the system checks predefined settings and applies them automatically.
- If
sl / percentage_sl / dollar_sl #
- Stop Loss settings:
- If
sl
is provided, it is used directly. - If not specified, the system checks predefined settings and applies them automatically.
- If
update_tp #
true
: Modifies the existing TP order instead of creating a new one.
update_sl #
true
: Modifies the existing SL order instead of creating a new one.
reverse_order_close #
true
: If a position exists in the opposite direction, it is closed before executing the new order.
account_id #
- Defines the Tradovate account for execution.
- If not specified, the system uses the default account
3. Pyramid Mode (Multiple Positions) #
3.1 How Pyramid Mode Works #
- pyramid: false (default behavior):
- If a buy alert is received while a buy or sell position is open, the existing position is closed before opening a new one.
- If a sell alert is received while a buy or sell position is open, the existing position is closed before opening a new one.
- pyramid: true (enabled mode):
- Buy alerts will not cancel existing buy positions (allows stacking multiple buy trades).
- Sell alerts will not cancel existing sell positions (allows stacking multiple sell trades).
This allows traders to scale into a trade instead of closing and reopening positions.
3.2 Pyramid Mode and Reverse Order Close #
Reverse Order Close | Pyramid | What Happens to the Existing Position (Same Signal)? | What Happens to the Existing Position (Opposite Signal)? | What Happens to a New Signal? |
True | False | It will be closed | It will be closed | A new trade opens if not a close signal. |
True | True | It will not be closed | It will be closed | A new trade opens if not a close signal. |
False | N/A | It will not close the trade | It will not close the trade | A new trade opens if not a close signal. |
4. Take Profit (TP) & Stop Loss (SL) Settings #
4.1 Take Profit (TP) #
A predefined price level where a position is closed to secure profits.
Example: If TP is set at 15,500, and the market price reaches this level, the trade is automatically closed to lock in profits.
4.2 Stop Loss (SL) #
A predefined price level where the position is closed to limit losses.
Example: If SL is set at 15,450, and the price drops to this level, the trade closes to prevent further losses.
4.3 TP1 & TP2 (Partial Profit Levels) #
- TP1: First exit level (e.g., 50% of the position closes at 15,500).
- TP2: Second exit level (remaining position closes at 15,550).
This strategy helps lock in partial profits while letting the rest of the trade run.
More Resources #
Want to automate trades on platforms beyond Rithmic, such as Interactive Brokers, TradeLocker, TradeStation, or ProjectX?
Explore all PickMyTrade setup guides
Using Tradovate instead?
View the Tradovate automation guide