1. Home
  2. Docs
  3. Documentation
  4. Setting up a bot
  5. TradingView Bot

TradingView Bot

This strategy allows you to execute your strategy defined in TradingView using the webhook. Opening and closing positions are realized using market orders, so your strategy must count with that.


How to create bot

  1. Create your strategy in TradingView that will call the API of ChainTerminal platform.
  2. Create TradingView bot in ChainTerminal platform
    1. Select name of your bot
    2. Select what will be the Quote Asset of futures markets
    3. Select the quantity (cost) of your position that will be opened when the signal comes. Quantity can be set as one of the:
      1. Fixed – absolute value
      2. % – percentage of your available balance (so the absolute value can vary for every signal incoming as your available balance fluctuates)
    4. Select Type of TradingView bot:
      1. Long – for bull trending market
      2. Short – for bear trending market
  3. Copy Webhook url that was generated specially for your bot and use it in TradingView
  4. In TradingView the call to ChainTerminal API should meet this requirements:
    Type: POST
    Url: copied url from TradingView bot
    Message body type: JSON
    Message body structure:
    • baseAsset: string
    • side: BUY / SELL

Example:

{
    “baseAsset”: “BTC”,
    “side”: “BUY”
}


How Does It Work

Long Type

ChainTerminal receives a signal and validates it (if bot is running, if market exists, etc.).
Then it checks your position on that market (if is open, if is short/long).
Depending on the signal it executes order or ignores the signal.
Possible cases:

Position statusSignal sideOutcome
Not openedBUYOpen position (place market buy)
LongBUYIncrease position by selected quantity (place market buy)
LongSELLClose position (place market sell)

All other cases are ignored. 


Short Type

ChainTerminal receives a signal and validates it (if bot is running, if market exists, etc.).
Then it checks your position on that market (if is open, if is short/long).
Depending on the signal it executes order or ignores the signal.
Possible cases:

Position statusSignal sideOutcome
Not openedSELLOpen position (place market sell)
ShortSELLIncrease position by selected quantity (place market sell)
ShortBUYClose position (place market buy)

All other cases are ignored.