alleyway / add-tradingview-alerts-tool

Automated entry of TradingView alerts for bot trading tools such as 3Commas, Alertatron, CryptoHopper, etc.
MIT License
655 stars 142 forks source link

entries and exits with one alert #21

Closed ricardodacosta closed 3 years ago

ricardodacosta commented 3 years ago

Within my TradingView strategy, I have the following

if (longCondition[1] and barstate.isconfirmed) strategy.entry("ENTER LONG (BUY)", strategy.long, alert_message = long_entry_message)

long_entry_message is an input variable where I enter the deal entry message for the platform I trade with, 3Commas in this case but could be used with others.

Same scenario for strategy.exit. Then on the actual alerts message box I simply enter {{strategy.order.alert_message}}

This allows me to have one alert that can do both (enter and exit trades) depending on which signal is triggered.

Works great as it saves me alerts from my package limit. However I have to update Pair information manually for each alert. Using your tool, it saves me some time but I still have to manually change the Pair information one by one afterwards since my message is built into the strategy

That being said, is there anything you can think of I could do? Is it possible to create an If statement within your JSON message that would fire a message to enter a deal or another one to close at market depending on whether strategy.entry or strategy.exit is TRUE? If so that would be great because I could take advantage of your magic "{{quote}}_{{base}}" to swap Pairs information automatically.

I know this is more of an issue for me rather than an issue of the tool itself but I would be surprise if I am the only one who uses 1 alert to do both enter and exit trades.

mlake commented 3 years ago

Hi there..sorry for the delayed response..

there’s no way to have if statements in json

is there no way to get the current trading pair in your pine script?

vjeuel commented 3 years ago

I am having exactly the same issue? How would I add the trading pairs to the pine script?

Create a list as an array and loop thru it?

What would be great as well is to be able to have both signals at once at the alerts thru your program, I see that there is a pending request that does just that.

I am amazed by what you guys are developing here and I think it has a huge potential.

ricardodacosta commented 3 years ago

@vjeuel what I did to make this work is this:

follow the instructions as normal but on the config.yml file under "message" you enter "{{strategy.order.alert_message}}"

Then on PineScript code find your strategy.entry and strategy.exit and enter the buy or sell signal message provided to you by your broker under alert_message along with pair="+ syminfo.ticker +" as you see below :

strategy.entry("ENTER LONG (BUY)", strategy.long, alert_message = "token=xxxxx label=BREAKOUT position=OPEN pair="+ syminfo.ticker +" valid=90s mode=STRATEGY")

strategy.exit("TRAILING SL (CLOSE LONGS)","ENTER LONG (BUY)", stop = exitLongCondition, alert_message = "token=xxxxx label=BREAKOUT position=CLOSE pair="+ syminfo.ticker +" valid=90s mode=STRATEGY")

Hope this helps

vjeuel commented 3 years ago

Thank you @ricardodacosta, I appreciate you taking the time to reply, I will give it a try.