Finding a bar with specific range

I am trying to find and plot the high and low of a bar which range is more than say 50 points. Basically I want to run a loop when a new day start and when that specific range bar appear want to mark the high low and on breakout of that range take position. Any help please, thanks

I am able to find and plot the high low with bellow code

p1 = Param("range",100,1,9999,1);


for (i=0; i<BarCount; i++){

if((H[i] - L[i])>=p1){
Plot(H[i],"",colorAqua);
Plot(L[i],"",colorBlue);
}
}

but it will start from the first bar of the data set. but want to search from first bar of a new day.

Why not to use arrays instead of loop ?

Spread = Param("Minimum Differnece Between High & Low",50,1,100);

C1 = H-L >= Spread;

// To keep the value until you get a true signal again ...
VH50 = valuewhen(C1,H);
VL50 = valuewhen(C1,L);

// Or just catch the them at the time of their occurence ...
IH50 = iif(C1,H,0);
IL50 = iif(C1,L,0);
4 Likes

for (i=0; i<BarCount; i++)

This is probably the most abused line of code in the AB universe :slight_smile:

And one can use the newday condition to detect a newday.

newDay = Day() != Ref( Day(), -1);
2 Likes

thank for the reply it solved my problem . thanks again