gap fill screener
Forums › ProRealTime English forum › ProScreener support › gap fill screener
- This topic has 11 replies, 2 voices, and was last updated 1 year ago by rob.es.
Viewing 12 posts - 1 through 12 (of 12 total)
-
-
04/02/2023 at 11:15 PM #212688
I saw this “gap fill indicator” by Roberto gozzi. I wonder how can we make the screener for it and be able to screen only when the current price is really close to the available gap. here is the indicator code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146// GAP Monitoring till Filled//// https://www.prorealcode.com/topic/gap-fill-indicator///DEFPARAM DrawOnLastBarOnly = True////ONCE GapLineSize = 4//ONCE GapDepth = 0.35//ONCE t155 = 135ONCE t255 = 255ONCE Elements = 10ONCE UPwards = 1ONCE DOWNwards = -1//IF BarIndex = 0 THENFOR i = 0 TO Elements$Gap[i] = 0$Gap2[i] = 0$Direction[i] = 0$BarID[i] = 0NEXTENDIF//// Calculate average rangeAverageHIGH = AVERAGE[20](HIGH)AverageLOW = AVERAGE[20](LOW)AverageRANGE = AverageHIGH - AverageLOW//IF BarIndex <= 9999999 THEN//// check whether any previous gap has been filled//FOR i = 1 TO ElementsIF $Direction[i] = UPwards THEN //bearish gapsIF high[1] < $Gap[i] AND high >= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFELSIF $Direction[i] = DOWNwards THEN //bullish gapsIF low[1] > $Gap[i] AND low <= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFENDIFNEXT//// Detect new Gaps//// Find bullish gapsIF LOW > HIGH[1] AND (LOW - HIGH[1]) > GapDepth * AverageRANGE THENgapfillzoneHIGH = LOWgapfillzoneLOW = HIGH[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarIDE[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = DOWNwards$BarID[i] = abreakENDIFNEXTENDIF//// Find bearish gapsIF HIGH < LOW[1] AND (LOW[1] - HIGH) > GapDepth * AverageRANGE THENgapfillzoneHIGH = HIGHgapfillzoneLOW = LOW[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = UPwards$BarID[i] = abreakENDIFNEXTENDIF////ENDIF//// draw lines//FOR i = 1 TO ElementsIF $Gap[i] <> 0 THENa = $BarID[i]x = $Gap[i] //gapfillzoneLOWy = $Gap2[i] //gapfillzoneHIGHIF $Direction[i] = DOWNwards THENDRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Green",t155) style(Line,2)DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Green",t255) style(Line,2)ELSIF $Direction[i] = UPwards THENDRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Red",t155) style(Line,2)DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Red",t255) style(Line,2)ENDIFENDIFNEXT//RETURN04/12/2023 at 4:47 AM #21315504/12/2023 at 9:23 AM #213162You can try this code, setting the distance you consider close enough:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149// GAP Monitoring till Filled//// https://www.prorealcode.com/topic/gap-fill-indicator/////DEFPARAM DrawOnLastBarOnly = True////ONCE GapLineSize = 4ONCE GapDepth = 0.3ONCE Distance = 2 * PipSize //detect when the current price is as close as DISTANCE pips////ONCE t155 = 135//ONCE t255 = 255ONCE Elements = 10ONCE UPwards = 1ONCE DOWNwards = -1//IF BarIndex = 0 THENFOR i = 0 TO Elements$Gap[i] = 0$Gap2[i] = 0$Direction[i] = 0$BarID[i] = 0NEXTENDIF//// Calculate average rangeAverageHIGH = AVERAGE[20](HIGH)AverageLOW = AVERAGE[20](LOW)AverageRANGE = AverageHIGH - AverageLOW//IF BarIndex <= 9999999 THEN//// check whether any previous gap has been filled//FOR i = 1 TO ElementsIF $Direction[i] = UPwards THEN //bearish gapsIF high[1] < $Gap[i] AND high >= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFELSIF $Direction[i] = DOWNwards THEN //bullish gapsIF low[1] > $Gap[i] AND low <= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFENDIFNEXT//// Detect new Gaps//// Find bullish gapsIF LOW > HIGH[1] AND (LOW - HIGH[1]) > GapDepth * AverageRANGE THENgapfillzoneHIGH = LOWgapfillzoneLOW = HIGH[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarIDE[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = DOWNwards$BarID[i] = abreakENDIFNEXTENDIF//// Find bearish gapsIF HIGH < LOW[1] AND (LOW[1] - HIGH) > GapDepth * AverageRANGE THENgapfillzoneHIGH = HIGHgapfillzoneLOW = LOW[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = UPwards$BarID[i] = abreakENDIFNEXTENDIF////ENDIF//// draw lines////FOR i = Elements DOWNTO 1IF $Gap[Elements] <> 0 THENa = $BarID[Elements]x = $Gap[Elements] //gapfillzoneLOWy = $Gap2[Elements] //gapfillzoneHIGH//IF $Direction[i] = DOWNwards THEN//DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Green",t155) style(Line,2)//DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Green",t255) style(Line,2)//ELSIF $Direction[i] = UPwards THEN//DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Red",t155) style(Line,2)//DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Red",t255) style(Line,2)//ENDIFc1 = (abs(close - x) <= Distance)c2 = (abs(close - y) <= Distance)ENDIF//NEXT//SCREENER[c1 OR c2]1 user thanked author for this post.
04/14/2023 at 2:22 AM #21326404/14/2023 at 11:36 AM #21328504/15/2023 at 4:40 AM #21332004/15/2023 at 11:33 AM #213326There you go:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152// GAP Monitoring till Filled//// https://www.prorealcode.com/topic/gap-fill-indicator/////DEFPARAM DrawOnLastBarOnly = True////ONCE GapLineSize = 4ONCE GapDepth = 0.3ONCE Distance = 2 * PipSize //detect when the current price is as close as DISTANCE pips////ONCE t155 = 135//ONCE t255 = 255ONCE Elements = 10//ONCE UPwards = 1ONCE DOWNwards = -1//IF BarIndex = 0 THENFOR i = 0 TO Elements$Gap[i] = 0$Gap2[i] = 0$Direction[i] = 0$BarID[i] = 0NEXTENDIF//// Calculate average rangeAverageHIGH = AVERAGE[20](HIGH)AverageLOW = AVERAGE[20](LOW)AverageRANGE = AverageHIGH - AverageLOW//IF BarIndex <= 9999999 THEN//// check whether any previous gap has been filled//FOR i = 1 TO Elements//IF $Direction[i] = UPwards THEN //bearish gaps//IF high[1] < $Gap[i] AND high >= $Gap[i] THEN//FOR j = i TO Elements - 1//// move next element to the current position (so it's overwritten)//$Gap[j] = $Gap[j + 1]//$Gap2[j] = $Gap2[j + 1]//$Direction[j] = $Direction[j + 1]//$BarID[j] = $BarID[j + 1]//// clear the next element//$Gap[j + 1] = 0//$Gap2[j + 1] = 0//$Direction[j + 1] = 0//$BarID[j + 1] = 0//NEXT//$Gap[Elements] = 0//$Gap2[Elements] = 0//$Direction[Elements] = 0//$BarID[Elements] = 0//ENDIF//ELSIF $Direction[i] = DOWNwards THEN //bullish gapsIF $Direction[i] = DOWNwards THEN //bullish gapsIF low[1] > $Gap[i] AND low <= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFENDIFNEXT//// Detect new Gaps//// Find bullish gapsIF LOW > HIGH[1] AND (LOW - HIGH[1]) > GapDepth * AverageRANGE THENgapfillzoneHIGH = LOWgapfillzoneLOW = HIGH[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarIDE[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = DOWNwards$BarID[i] = abreakENDIFNEXTENDIF//// Find bearish gaps//IF HIGH < LOW[1] AND (LOW[1] - HIGH) > GapDepth * AverageRANGE THEN//gapfillzoneHIGH = HIGH//gapfillzoneLOW = LOW[1]//a = BARINDEX-1//// make room for one more array element, if needed//IF $Gap[Elements] <> 0 THEN//Elements = Elements + 1//$Gap[Elements] = 0//$Gap2[Elements] = 0//$Direction[Elements] = 0//$BarID[Elements] = 0//ENDIF//// store the new element in the first available slot//FOR i = 1 TO Elements//IF $Gap[i] = 0 THEN//$Gap[i] = gapfillzoneLOW//$Gap2[i] = gapfillzoneHIGH//$Direction[i] = UPwards//$BarID[i] = a//break//ENDIF//NEXT//ENDIF////ENDIF//// draw lines////FOR i = Elements DOWNTO 1IF $Gap[Elements] <> 0 THENa = $BarID[Elements]x = $Gap[Elements] //gapfillzoneLOWy = $Gap2[Elements] //gapfillzoneHIGH//IF $Direction[i] = DOWNwards THEN//DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Green",t155) style(Line,2)//DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Green",t255) style(Line,2)//ELSIF $Direction[i] = UPwards THEN//DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Red",t155) style(Line,2)//DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Red",t255) style(Line,2)//ENDIF//c1 = (abs(close - x) <= Distance)//c2 = (abs(close - y) <= Distance)c1 = (abs(low - x) <= Distance)c2 = (abs(low - y) <= Distance)ENDIF//NEXT//SCREENER[c1 OR c2]1 user thanked author for this post.
04/15/2023 at 7:52 PM #21333504/15/2023 at 10:22 PM #213337Yes, you are right, uncomment line 133 and line 150, then replace [elements] with [ i ].
Unfortunately I cannot test it.
04/16/2023 at 1:49 AM #21334005/03/2023 at 10:42 AM #214045I modified it a bit, it sounds better now:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155// GAP Monitoring till Filled//// https://www.prorealcode.com/topic/gap-fill-indicator/////DEFPARAM DrawOnLastBarOnly = True////ONCE GapLineSize = 4ONCE GapDepth = 0.35ONCE Distance = 2 * PipSize //detect when the current price is as close as DISTANCE pips////ONCE t155 = 135//ONCE t255 = 255ONCE Elements = 10ONCE UPwards = 1ONCE DOWNwards = -1//IF BarIndex = 0 THENFOR i = 0 TO Elements$Gap[i] = 0$Gap2[i] = 0$Direction[i] = 0$BarID[i] = 0NEXTENDIF//// Calculate average rangeAverageHIGH = AVERAGE[20](HIGH)AverageLOW = AVERAGE[20](LOW)AverageRANGE = AverageHIGH - AverageLOW//IF BarIndex <= 9999999 THEN//// check whether any previous gap has been filled//FOR i = 1 TO ElementsIF $Direction[i] = UPwards THEN //bearish gapsIF high[1] < $Gap[i] AND high >= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFELSIF $Direction[i] = DOWNwards THEN //bullish gapsIF low[1] > $Gap[i] AND low <= $Gap[i] THENFOR j = i TO Elements - 1// move next element to the current position (so it's overwritten)$Gap[j] = $Gap[j + 1]$Gap2[j] = $Gap2[j + 1]$Direction[j] = $Direction[j + 1]$BarID[j] = $BarID[j + 1]// clear the next element$Gap[j + 1] = 0$Gap2[j + 1] = 0$Direction[j + 1] = 0$BarID[j + 1] = 0NEXT$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIFENDIFNEXT//// Detect new Gaps//// Find bullish gapsIF LOW > HIGH[1] AND (LOW - HIGH[1]) > GapDepth * AverageRANGE THENgapfillzoneHIGH = LOWgapfillzoneLOW = HIGH[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarIDE[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = DOWNwards$BarID[i] = abreakENDIFNEXTENDIF//// Find bearish gapsIF HIGH < LOW[1] AND (LOW[1] - HIGH) > GapDepth * AverageRANGE THENgapfillzoneHIGH = HIGHgapfillzoneLOW = LOW[1]a = BARINDEX-1// make room for one more array element, if neededIF $Gap[Elements] <> 0 THENElements = Elements + 1$Gap[Elements] = 0$Gap2[Elements] = 0$Direction[Elements] = 0$BarID[Elements] = 0ENDIF// store the new element in the first available slotFOR i = 1 TO ElementsIF $Gap[i] = 0 THEN$Gap[i] = gapfillzoneLOW$Gap2[i] = gapfillzoneHIGH$Direction[i] = UPwards$BarID[i] = abreakENDIFNEXTENDIF////ENDIF//// draw lines//MinDistance = 999999FOR i = 1 TO ElementsIF ($Gap[i] <> 0) AND ($Direction[i] = DOWNwards) THENa = $BarID[i]x = $Gap[i] //gapfillzoneLOWy = $Gap2[i] //gapfillzoneHIGH//IF $Direction[i] = DOWNwards THEN//DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Green",t155) style(Line,2)//DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Green",t255) style(Line,2)//ELSIF $Direction[i] = UPwards THEN//DRAWSEGMENT(a,x,a+GapLineSize,x) COLOURED("Red",t155) style(Line,2)//DRAWSEGMENT(a,y,a+GapLineSize,y) COLOURED("Red",t255) style(Line,2)//ENDIFc1 = (abs(high - x))// <= Distance) //or HIGH instead of CLOSEc2 = (abs(high - y))// <= Distance) //or HIGH instead of CLOSEcx = min(c1,c2)c3 = (abs(low - x))// <= Distance) //or LOW instead of CLOSEc4 = (abs(low - y))// <= Distance) //or LOW instead of CLOSEcy = min(c3,c4)MinDistance = min(MinDistance,min(cx,cy))ENDIFNEXT//SCREENER[MinDistance <= Distance]1 user thanked author for this post.
05/04/2023 at 5:23 AM #214104 -
AuthorPosts
Viewing 12 posts - 1 through 12 (of 12 total)
Find exclusive trading pro-tools on
Similar topics: