'Momentum Candle Breakout
I am new in pine script and trying to write a script. I want to check
- A slightly big red(momentum) candle than average
- There are at least two candles closed within the body of that red momentum candle.
- 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)
Solution 1:[1]
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mazen Abduallah |
