I want to plot a line between Cond1 = true and Cond2 = true. But only when I know cond2 is true, I mean, I need to plot the line backwards.
The following code works fine for the last ocurrence (my best attempt):
//CHART
Plot(C,"C",colorBlack, styleBar);
Plot(MA(C,20),"MA",colorRed,styleLine);
//CONDITIONS
cond1 = Cross( C, MA(C,20) );
cond2 = Cross( MA(C,20), C);
//I WANT TO PLOT A LINE THAT GOES FROM COND1 = TRUE TO COND2 = TRUE
//BUT ONLY IF AND WHEN I KNOW COND2 IS TRUE
bi = BarIndex();
Cond2Bar = SelectedValue( ValueWhen( Cond2, bi) );
Cond1Bar = SelectedValue( ValueWhen( Cond2, ValueWhen( Cond1, bi) ) );
Line = SelectedValue(ValueWhen( Cond1, H) );
Plot( LineArray( Cond1Bar, line, Cond2Bar, line ), "Start",colorBlue,styleThick);
But when I try to plot all ocurrences I cannot make it work. If I use a normal plot then I need to shift it and have a problem with the number of bars to shift, which is an array and the function requieres a scalar. If I use LineArray() then it gives me only 1 ocurrence, then I place it in a loop and a error message of being called more than 500 times appears.
I have tried different options from the Knowledge Base with no success: http://www.amibroker.com/kb/2015/01/14/drawing-line-extensions-on-future-bars-using-afl/
And of course I have searched the forum, but didn't find something that I can use or know how to apply properly.
Thank you very much!