Hello everyone.
as in title.. i believe this problem would very simple for you guys... but yet i still cant find the solution.
hopefully someone can help me about this topic.
Believe me, this take a lot of courage for me to post this kind of topic (beginner level problem),.. i already did the search, read the references, and hours of trial & error in formula editor... and still didn't succeed. Oh well, i think my knowledge in AFL is still very far.
.
I'm trying to find resistance level array, with specific condition.
for simplicity, let say the resistance logics is like this:
-
define the significant bar (cond_1)
-
find the High, from the bar of cond_1 (cond_2)
-
Cond_3:
a. if Ref(C,-1) is below the High of cond_2, then still use the previous cond_2
b. if Ref(C,-1) is above the High of cond_2, then find the next lowest High that meet Cond_2 (but not necessarily from the most recent bar) -
plot the array of Cond_3
.
Conditions:
cond_1 = C<Ref(C,-1) AND H<Ref(H,-1) AND L<Ref(L,-3) AND C < ((H+L)/2);
cond_2 = ValueWhen(cond_1, H, 1);
cond_3 = IIf((Ref(C,-1) < cond_2), ValueWhen(cond_1 , cond_2, 1), ValueWhen(cond_1 , cond_2, 2 /* this is the problem,.. is there any way to find the "next cond_2" without loop?*/) ) ;
Plot(cond_3, "Resistance 1", colordarkred, styleline);
PlotOHLC(O,H,L,C,"",IIf(cond_1, colorDarkRed, colorDarkGreen),styleCandle);
so yeah.. the problem is, i'm struggling to find the next-lowest-high (3.b) to be plotted in array, and i can't use time/period-based argument like in HHV, HighestSince, etc. Because next-lowest-high of cond_2, could happen at anytime (could be as far as 20 bar in high timeframe or maybe only 3 bar in low timeframe).
i really believe the solution should be already very near (if without loop).
or am i wrong? and i really do need a loop for this?
hopefully someone can help me on this.
Much appreciated.
rgds.