Based on a request on the forum (https://www.prorealcode.com/topic/count-5-10candle-sticks-that-closes-above-50-ema/), I wrote this indicator that may help to better identify when an Engulfing pattern can be a good reversal point.
It counts candles BELOW an MA (on a Bullish Engulfing) and candles ABOVE an MA (on a Bearish Engulfing). I added two MA’s, to detect when their average counts are rising or dropping to make an even better decision:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
// Count candles Above or Below an average before an Engulfing occurs // // (requested at https://www.prorealcode.com/topic/count-5-10candle-sticks-that-closes-above-50-ema/) // // AvgP = 100 // AvgT = 0 // p = 50 // t = 1 // AvgP = max(2,min(999,AvgP)) //2-999 AvgT = max(0,min(6,AvgT)) //0-6 p = max(2,min(999,p)) //2-999 t = max(0,min(6,t)) //0-6 // Bullish = close > open Bearish = close < open Opposite = (Bearish AND Bullish[1]) OR (Bearish[1] AND Bullish) Body = abs(close - open) Engulfing = (Body > Body[1]) AND Opposite BullishEng= Engulfing AND Bullish AND (close >= open[1]) AND (open <= close[1]) BearishEng= Engulfing AND Bearish AND (Open >= close[1]) AND (close <= open[1]) MyEma = average[p,t](close) // // Count candles ABOVE average before a BEARISH Engulfing occurs // BullBarCount = 0 BearBarCount = 0 If BearishEng THEN //BullBarCount = 0 FOR i = BarIndex - 1 DOWNTO 1 x = BarIndex - i IF close[x] > MyEma[x] THEN BullBarCount = BullBarCount + 1 ELSE BREAK ENDIF NEXT ENDIF // // Count candles BELOW average before a BULLISH Engulfing occurs // If BullishEng THEN //BearBarCount = 0 FOR i = BarIndex - 1 DOWNTO 1 x = BarIndex - i IF close[x] < MyEma[x] THEN BearBarCount = BearBarCount + 1 ELSE BREAK ENDIF NEXT BearBarCount = -BearBarCount ENDIF // BullAvg = average[AvgP,AvgT](BullBarCount) BearAvg = average[AvgP,AvgT](BearBarCount) // RETURN BullBarCount AS "Bulls",BearBarCount AS "Bears",BullAvg AS "BullMA",BearAvg AS "BearMA",0 AS "Zero" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials