// Downloaded From https://www.WiseStockTrader.com
//+--------------------------------------------------------------------------------------------------------+
//|                                                                                                GAPs.afl |
//|                                                                                        Project EJR 2011 |
//|                                                                                   erleninvest@gmail.com |
//+---------------------------------------------------------------------------------------------------------+

candlejump = Param("Candle Jump",11,3,20) ; // Amount of candles to jump is detected
Vlrgap = Param("Porcentagem GAP",0.3,0,2,0,01) ; // size percentage above or below
qntcandles=BarsSince(TimeNum() < Ref(TimeNum(),-1)); // counting candles that have passed since the day began.
Vlry=ValueWhen(TimeNum() < Ref(TimeNum(),-1),Ref(C,-1));  // return to the previous close when the day begins.
Vlrt=ValueWhen(qntcandles==0,Open); // 
wait=IIf(qntcandles < candlejump,1,0); 
delay=IIf(wait==1 AND ( Vlrt > Vlry * (1+(vlrgap/100)) 
OR Vlrt < Vlry * (1-(vlrgap/100))) ,1,0); 

/////////////////////////PLOT

Plot(delay,"teste",colorRed);