Reputation: 1
I have written an algorithm for auto live trading , where i have linked TRadingview with Tradetron to automate my trading .
From tradingview , i am trying to create two alerts " one for buy and one for exit"
Now , the pine script which i have written includes this piece of code :
if(EnterBuy and strategy.position_size <= 0)
strategy.entry("Buy", strategy.long,when=EnterBuy)
if(EnterSell and strategy.position_size > 0)
strategy.exit("Exit the buy","Buy", limit = close)
I want to link my alerts to buy and exit accordingly. But what i am observing is , if any of the above condition is satisfied , tradingview is firing two alerts .whereas i want the alerts to be conditional
Upvotes: 0
Views: 196
Reputation: 21342
Use the alert_message
argument of the strategy.entry
and strategy.exit
functions.
if(EnterBuy and strategy.position_size <= 0)
strategy.entry("Buy", strategy.long,when=EnterBuy, alert_message="Enter Long")
if(EnterSell and strategy.position_size > 0)
strategy.exit("Exit the buy","Buy", limit = close, alert_message="Exit Long")
Upvotes: 0