How To Automate a TradingView Script to Binance COINM

Binance

You can now send TradingView alerts to Binance CoinM thanks to the Tradingview to Anywhere tool. The bot uses human-like commands that can be combined with TradingView’s dynamic alert messages.

How to Automate TradingView script in simple steps

  1. Head to TradingView To Binance and scroll to the step-by-step guide to getting started.
  2. Create new Binance API keys. Allow Futures, Spot & Margin trading, and allow unrestricted IP access.
  3. Submit your API keys on the TradingView To Binance website. and follow the easy on-screen instructions provided to finish setting up your webhook.

How to Automate a TradingView Strategy to Binance COINM
For a strategy with a buy and close command only, use {{strategy.order.action}} - which returns the string “buy” or “sell” for the executed order.
For a strategy that has long, short, and close commands, use {{strategy.market_position}} - which returns the current position of the strategy in string form: “long”, “flat”, or “short”.

Specify the asset symbol to trade, the number of contracts, and the account using the TradingView to Anywhere commands.
Please note that quantity is passed as either the number of contracts or as a percentage.

For Example:

  1. A strategy with long and short commands only.
    Close BTC/USD A=COINM
    {{strategy.order.action}} BTC/USD Q=1 L=5 A=COINM
    or
    Close BTC/USD A=COINM
    {{strategy.order.action}} BTC/USD Q=150% A=COINM

The command above will ensure that any open positions of BTCUSD are closed before executing the command from your strategy.

  1. A strategy with long, short, and exit commands.
    {{strategy.market_position}} BTC/USD Q=1 L=10 A=COINM
    or
    {{strategy.market_position}} BTC/USD Q=150% A=COINM

This command will automatically enter and exit your positions so no need to type in the close command first like in the previous case.

How to Automate TradingView Indicator to Binance COINM
To automate a TradingView indicator to Binance COINM:

  1. Select the indicator as the condition and choose the long or short condition.
  2. To avoid alert duplication, select once per bar.
  3. Add the applicable buy/sell TradingView To Anywhere command in the message field.

For Example:

  • For a Buy condition, the command will be;
    Close BTC/USD A=COINM
    Buy BTC/USD Q=1 L=15 A=COINM
    or
    Close BTC/USD A=COINM
    Buy BTC/USD Q=100% A=COINM

  • For a Sell condition, the command will be;
    Close BTC/USD A=COINM
    Sell BTC/USD Q=1 L=5 A=COINM
    or
    Close BTC/USD A=COINM
    Sell BTC/USD Q=150% A=COINM

Please note we include the close command before the buy/sell command to make sure that any previous open positions are closed before opening a new one.

That’s all, it is that simple! :slight_smile:

why you used 150% ? ???

Hello @Yasser
To apply a 1.5X leverage.

SL=2%

This is not working anymore, correct?
Setting up stop loss …

Hello @MrRekt,

It is working as expected. I did test it just a few minutes ago.

Regards.

Hello,

I just did a few tests using the TTA app, it’s working.

I have implemented it again in TV, will keep you posted.

Previously it was returning errors (orders not being executed, when adding SL)

1 Like

Hello,

I was wrong, it’s working

This is the code I used in TV

Close ETHUSDT A=USDM
Short ETHUSDT Q=0.1 L=50 SL=0.2% A=USDM

1 Like