Aamerallous
Aamerallous

Reputation: 133

Momentum Candle Breakout

I am new in pine script and trying to write a script. I want to check

  1. A slightly big red(momentum) candle than average
  2. There are at least two candles closed within the body of that red momentum candle.
  3. After these two candles the next candle breaks the overall previous three candles in opposite direction.

So far I have written the below script but I am stuck in it.

     //@version=4
     study("Momentum Candle",shorttitle="Momentum_Candles_80_Percent", overlay=true)

     
     body = abs(close-open)
     rng=high-low
     strongRed = body/rng>=0.80 and open > close and 

     plotchar(strongRed,location=location.belowbar,color=color.blue)

Upvotes: 1

Views: 560

Answers (1)

Mazen Abduallah
Mazen Abduallah

Reputation: 122

you have to use [] brackets to select the specific candle, provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down. expr1\[expr2\]

//@version=4
study("Momentum Candle",shorttitle="Momentum_Candles_80_Percent", overlay=true)


body = abs(close-open)
rng=high-low
strongRed = body/rng>=0.80 and open > close[1]  and
                               open > close[2]  and
                               open > open[1]   and
                               open > open[2]   and
                               close < close[1] and
                               close < close[2] and
                               close < open[1]  and
                               close < open[2]  or
                               open < close[1]  and
                               open < close[2]  and
                               open < open[1]   and
                               open < open[2]   and
                               close > close[1] and
                               close > close[2] and
                               close > open[1]  and
                               close > open[2]
plotchar(strongRed,location=location.belowbar,color=color.blue)

Upvotes: 0

Related Questions