Reputation: 37
I would like to plot something (an arrow, a label) that could mark on the chart everytime my strategy sets a buy or sell order (which happens under certain conditions but can disappear)
Is there a way in pine script I could do that ?
Here's the extract of the strategy that creates the order :
strategy.entry("BuyOrder", strategy.long, stop=high+syminfo.mintick, comment="Buy", when = window())
Upvotes: 0
Views: 723
Reputation: 1961
You can use ta.change()
with strategy.position_size
and strategy.opentrades
:
//@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
changeCond = ta.change(strategy.position_size, 1) or ta.change(strategy.opentrades,1)
bgcolor(changeCond? color.new(color.red, 80) : na)
Upvotes: 0