Tradingviewluck
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: December 22nd, 2021

How to reverse your position with TradingView custom signals for 3Commas

Hi,

I am trading with my strategy script LONG and SHORT together on 1 account. Sometimes if the LONG position is open, The SHORT alert triggers and it wants to place a new SHORT position. But the LONG position is still open and the SHORT position is been cancelled.

3commas does not support HEDGE MODE yet.

I need your help in the following, I use TV for my signals and I use a place holder {{strategy.order.comment}} in my alerts so the 3commas bot can do the trade.

There is a workaround made by 3commas.

https://help.3commas.io/en/articles/363 ... om-signals

You can combine a sell message and a buy message together.

I'm using escape characters because I inject the message in the script itself. And it works really good with 1 message.

But the 3commas bot is not picking the combined trade signals, what is it what im doing wrong?

JSON string:
[{"message_type": "bot", "bot_id": 756065, "email_token": "d98895d9-adc5-4852-94o0-de67ad25923b", "delay_seconds": 0, "action": "close_at_market_price"}, {"message_type": "bot", "bot_id": 820763, "email_token": "d98895d9-adc5-4852-94o0-de67ad25923b", "delay_seconds": 6}]


escaped string:
{\"message_type\": \"bot\", \"bot_id\": 756065, \"email_token\": \"d98895d9-adc5-4852-94o0-de67ad25923b\", \"delay_seconds\": 0, \"action\": \"close_at_market_price\"}, {\"message_type\": \"bot\", \"bot_id\": 820763, \"email_token\": \"d98895d9-adc5-4852-94o0-de67ad25923b\", \"delay_seconds\": 6}]

I use https://www.freeformatter.com/json-esca ... #ad-output to escape the string.

Return to “Pine Script Q&A”