Exploration query

I design an exploartion for the closing price of the 5th bars and 10 bars prior to the bar with the lowest price within the current 52 weeks. If the today(close) price is higher than those (5th and 10 th) closing price, it is a signal to long and vice versa.

// search for 52 weeks low
bi = BarIndex();
dt = DateTime();
LastX = LastValue(bi);
LowCond1 = bi == LastX-260;
Low52 = LowestSince(lowCond1, Low);
BarsSinceLow52 = LowestSinceBars(lowCond1, L);
Low52X = LastX - LastValue(BarsSinceLow52);
LowDate = Ref(dt,-BarsSinceLow52);

Next steps needs to set 52 weeks low as reference bar and use barsince, but how to use it?
Can anyone help me?



1 Like

@roychan you have been a member of this forum for more than 2 years and yet in many of your posts you refuse to properly use code tags when posting a code sample. Why do you refuse to use this forum properly?

Try this for finding the Close 10 bars before the Lowest Low of the previous 252 bars (one year of daily bars).

CloseTenBack = ValueWhen(L==LLV( L, 252 ), Ref(C, -10));


Unfortunately the code line of previous post is not correct in a way to get actual bar of lowest low of previous n-period.

Instead code for getting bars having passed since LLV is achieved by using LLVBars() function and then using Ref() for getting five and ten bars back from there to get price before LLV bar.

ll_bars = LLVBars(L, 252);

CloseFiveBack = Ref(C, -ll_bars-5);
CloseTenBack = Ref(C, -ll_bars-10);
Filter = C > CloseTenBack AND C > CloseTenBack AND Status("LastBarInRange");

@fxshrat thanks for picking up my mistake. I should not have rushed my answer (it looked correct with a very superficial quick test).

1 Like

@fxshrat probably meant:

Filter = C > CloseFiveBack AND C > CloseTenBack AND Status("LastBarInRange");