The following simple code works only ones, when I double click on the
indicator (called TEST). The plot is perfect.

bi = BarIndex();
dt_array = DateTime();
Trade_dt=dt_array[SelectedValue(bi)];
Trade_dt_text = DateTimeToStr(Trade_dt);

Trade_flag = IIf(dt_array == Trade_dt,1,0);
Plot(Trade_flag,"F",colorRed);

The moment I click on the chart or indicator (refresh) there is an error:
Error 10
Substrict out of range.
You must not access array elements outside 0..(Barcount -1) range.
Error is at Trade_dt_text .....

I know how to fix it. Just insert in the very beginning
SetBarsRequired(100000,0);, but that's not the point.

1.Why does it work the first time , but not the second and the
following refreshes ?
2.There is a price to pay for it. Execution time increases
dramatically. The SelectedValue is almost in every case at the very
end of the chart. Quick AFL should cover such cases, but it seems that
DateTime() is excluded from quick AFL. Is it true?

I will appreciate some explanation, so I can write more efficient
software. Thank you in advance.

AF  


Reply via email to