This indicator provides a way to track 3 different types of Gaps along with actively tracking how far away the price is from closing them. Open gaps to the upside are represented as positive bars and gaps to the downside as negative bars.
The Gap types are as follow:
- Daily Gaps – Unclosed range between market closing price and market open price
- Intraday Gaps – Unclosed range between the top and bottom shadows of two consecutive candles
- Brooks Gaps – Unclosed range between the top and bottom of every second candle
The gap type can be manually switched using the GapType parameter.
The code looks as follow:
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
//Gap Type as Variable If GapType = 1 Then //Daily SGap = 0 LGap = 0 If hour = 17 and minute = 0 Then GapClose = close ElsIf hour = 9 and minute = 0 then If low > GapClose Then Gap = (low-GapClose)* -1 ElsIf high < GapClose Then Gap = (GapClose-high) * +1 EndIf ElsIf hour >= 9 and hour < 17 Then If Gap > 0 Then Gap = (GapClose-high) * +1 ElsIf Gap < 0 Then Gap = (low-GapClose) * -1 EndIf Else Gap = 0 EndIf ElsIf GapType = 2 Then //Intraday Gap = 0 Once SGap = 0 Once LGap = 0 If hour < 9 or hour >= 22 Then SGap = 0 LGap = 0 Else If SGap = 0 and low - high[1] > 0.0001 THEN SGapClose = high[1] SGap = (low-SGapClose) * -1 EndIf If LGap = 0 and low[1] - high > 0.0001 THEN LGapClose = low[1] LGap = (LGapClose-High) * +1 ENDIF If SGap < 0 Then If (low-SGapClose) * -1 > 0 Then SGap = 0 Else SGap = (low-SGapClose) * -1 EndIf EndIf If LGap > 0 Then If (LGapClose-High) < 0 Then LGap = 0 Else LGap = (LGapClose-High) * +1 EndIf EndIf EndIf ElsIf GapType = 3 Then //Brooks Gap Gap = 0 Once SGap = 0 Once LGap = 0 If hour < 9 or hour >= 22 Then SGap = 0 LGap = 0 Else If SGap = 0 and low - high[2] > 0.0001 THEN SGapClose = high[2] SGap = (low-SGapClose) * -1 EndIf If LGap = 0 and low[2] - high > 0.0001 THEN LGapClose = low[2] LGap = (LGapClose-High) * +1 ENDIF If SGap < 0 Then If (low-SGapClose) * -1 > 0 Then SGap = 0 Else SGap = (low-SGapClose) * -1 EndIf EndIf If LGap > 0 Then If (LGapClose-High) < 0 Then LGap = 0 Else LGap = (LGapClose-High) * +1 EndIf EndIf EndIf EndIf return Gap style(HISTOGRAM) as "GAP", SGap style(HISTOGRAM) as "Short GAP", LGap style(HISTOGRAM) as "Long GAP", 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