Just playing around, learning how to write strategies. The one I'm trying right now is (pseudo-code)...
if(previousCandle == red
... AND previousCandle.high >= sma
... AND previousCandle.low <= sma
... AND currentPrice > previousCandle.high)
enter trade
What I have in Pine Script is...
redTouch = close < open and high >= ma and low <= ma
longCond = redTouch[1] and close > high[1]
strategy.entry("Long", strategy.long, when = longCond)
The redTouch
candles are all identified correctly (checked previously using BG colors), but for the longCond
I don't want close > high[1]
, because that enters the trade only on the next candle (and too late).
The following screenshot shows where the trade is currently being entered (blue line on red candle), and where I'd like it to trigger/enter (yellow line on green candle).
How do I change close > high[1]
to price > high[1]
or a similar intra-candle crossover trigger? Or can you only enter trades in the next candle in Pine Script?