All Collections
Bots (DCA, GRID)
Signal bot
Signal bot: what is JSON file and what it contains
Signal bot: what is JSON file and what it contains

Learn more about what is a JSON file and what parameters does it include.

Updated today

What is JSON and what job it does?

JSON is a type of format that is used to store and transport the data. It stands for JavaScript Object Notation.

While creating Signal bot or a DCA bot on 3Commas, the system automatically generates a unique JSON-file, sometimes it's called "JSON message". It includes all important data to make your bots work. TradingView uses the JSON format to transfer the data in the POST-request.

Here in this article we will describe all parameters JSON file includes.

The difference between "Indicators" and "Strategies".

Indicators are scripts that can perform any calculations written in TradingView's Pine Script language and display them on a chart.

The notification functionality of indicators allows sending a notification when a specific condition is met. The condition can be set either by the user or by the author of the indicator used.

Strategies are also scripts written in the TradingView Pine Script programming language, but designed to simulate trading and perform testing on historical data to check its effectiveness on TradingView, in other words, it can be named backtesting. As a result of running the strategy, entries and exits are displayed on the chart using arrow markers.

Strategies also support an alert function that sends a notification when a position changes. Thus, you can implement your strategy on the real market. However, it is important to remember that TradingView alerts will come when requests are executed, which is not the same as placing a request. The data contained in the request will be used to create a notification for your alert and will be replaced with the corresponding value.

"Indicators" JSON file example and explanation.

Here is an example of the JSON file for Signal bot's Indicators type:

{
"secret": "token",
"max_lag": "300",
"timestamp": "{{timenow}}",
"trigger_price": "{{close}}",
"tv_exchange": "{{exchagne}}",
"tv_instrument": "{{ticker}}",
"action": "exit_long",
"bot_uuid": "signal-bot-uuid",
"order": {
"amount": {amount},
"currency_type": "quote"
}
}

The parameters are as follows:

  • secret (required) - a unique 3Commas token to authenticate incoming requests within a single user. The token is generated automatically when you create a Signal Bot.

  • max_lag (optional) - Maximum allowable signal processing delay in seconds. An integer value between [10, 86400]. The default is 300. Calculates the value by: ('first_processed_at' - 'timestamp').

  • timestamp (optional) - {{timenow}} received from TradingView. Alert trigger time in UTC in the format yyyy-MM-ddTHH:mm:ssZ. Returns the time to the nearest second regardless of the interval. For example: 2019-08-27T09:56:00Z.

  • trigger_price (required) - {{close}} received from TradingView, where: close - variable represents the current price.

  • tv_exchange (required) - {{exchange}} received from TradingView. Exchange for which the alert is created (BINANCE, OKX, BYBIT, etc.).

  • tv_instrument (required) - {{ticker}} received from TradingView. The trading pair for which the alert was created. For example: BTCUSD, etc. Make sure to write the pair name precisely as different exchanges have different naming for the same contract.

  • action (required) - Returns one of the following values: enter_long; enter_shot; exit_long; exit_shot.

  • bot_uuid (required) - Signal Bot identification code in the 3Commas system.

  • order. amount (optional) - Returns the number of contracts of the executed order. When passing a value in this field, data in 'order.currency_type' must be passed in the pair.

  • order.currency_type (optional):

    • base - only for entry and exit signals;

    • quote - only for entry and exit signals;

    • position_percent - only for exit signals;

    • margin_percent - only for entry signals.
      If this field is filled, the data in 'order.amount' must be passed in the pair.

"Strategy" JSON file example and explanation.

{
"secret": "token",
"max_lag": "300",
"timestamp": "{{timenow}}",
"trigger_price": "{{close}}",
"tv_exchange": "{{exchange}}",
"tv_instrument": "{{ticker}}",
"action": "{{strategy.order.action}}",
"bot_uuid": "86a9ac05-8d79-44a9-bd34-a8dd2884db41",
"strategy_info": {
"market_position": "{{strategy.market_position}}",
"market_position_size": "{{strategy.market_position_size}}",
"prev_market_position": "{{strategy.prev_market_position}}",
"prev_market_position_size": "{{strategy.prev_market_position_size}}"
},
"order": {
"amount": "{{strategy.order.contracts}}",
"currency_type": "base"
}
}

The parameters are as follows:

  • secret (required) - a unique 3Commas token to authenticate incoming requests within a single user. The token is generated automatically when you create a Signal Bot.

  • max_lag (optional) - Maximum allowable signal processing delay in seconds. An integer value between [10, 86400]. The default is 300. Calculates the value by: ('first_processed_at' - 'timestamp').

  • timestamp (optional) - {{timenow}} received from TradingView. Alert trigger time in UTC in the format yyyy-MM-ddTHH:mm:ssZ. Returns the time to the nearest second regardless of the interval. For example: 2019-08-27T09:56:00Z.

  • trigger_price (required) - {{close}} received from TradingView, where: close - variable represents the current price.

  • tv_exchange (required) - {{exchange}} received from TradingView. Exchange for which the alert is created (BINANCE, OKX, BYBIT, etc.).

  • tv_instrument (required) - {{ticker}} received from TradingView. The trading pair for which the alert was created. For example: BTCUSD, etc. Make sure to write the pair name precisely as different exchanges have different naming for the same contract.

  • action (required) - {{strategy.order.action}} received from TradingView.

    Returns the buy "buy" or sell "sell" value of the executed order.

  • bot_uuid (required) - Signal Bot identification code in the 3Commas system.

  • market_position (required) - {{strategy.market_position}} received from TradingView.

    Returns the value of the current strategy position in long, flat or short string.

  • market_position_size (required) - {{strategy.market_position_size}} received from TradingView.

    Returns the size of the current position as an absolute value (not a negative number).

  • prev_market_position (required) - {{strategy.prev_market_position}} received from TradingView. Returns the strategy's previous position in long, flat or short string.

  • prev_market_position_size (required) - {{strategy.prev_market_position_size}} received from TradingView. Returns the size of the previous position as an absolute value (not a negative number).

  • order. amount (required) - {{strategy.order.contracts}} received from TradingView. Returns the number of contracts of the executed order.

  • order.currency_type (required):

    • base - only for exit signals.


FAQ

Is it possible to send signals from a Bitcoin chart to a different trading pair?

Absolutely. To do this, simply replace the placeholders tv_instrument and tv_exchange within the JSON message manually. It's important to pay attention to the format used for trading pairs.

For instance:

BTCUSDT:OKX - spot pair on OKX. (BTC/USDT in 3Commas UI)

BTCUSDT.P:OKX - perpetual linear futures on OKX. (BTC-USDT-SWAP/USDT in 3Commas UI)
BTCUSD.P:OKX - perpetual inverse futures on OKX (BTC-USD-SWAP/BTC in 3Commas UI)

Here's an example of how part of the original JSON message looks:

{ ... "tv_exchange": "{{exchange}}", "tv_instrument": "{{ticker}}" ... }

And here's how you might modify it:

{ ... "tv_exchange": "OKX", "tv_instrument": "1INCHUSDT.P" ... }

By making these changes, the signal would then apply to the 1INCH-USDT-SWAP/USDT pair on 3Commas. Remember to double-check the trading pair format to ensure accuracy.

Did this answer your question?