--- In [email protected], "Habibur Md. Rahman Planning Networks"
<ha...@...> wrote:
>
> Hi
>
> I want to detect the status of current day's price status, that is,
this is the highest (or lowest) closing price of last nth day's closing
price. What could be the afl to detect the value of n?


Greater = Close >= Ref(Close, -1);
N = BarsSince(NOT Greater);

Plot(Close, "Close", colorDarkGrey, styleLine);
Plot(N, "N", colorBlue, styleStaircase | styleOwnScale);

> Another thing is, when working with loop, how I can break the loop
based on array condition. For example, When the condition Ref(O,-i) >
Ref(O,0) first occurs i want to break the loop and get the value of 'i'.
Since 'If' doesn't work on array, then how to do it?


for (i = 0; i < BarCount; i++) {
    if (...my Condition...) {
       break;
    }
}

// At this point, i holds the value at which your condition was true.

Although, you're probably better off using the ValueWhen function rather
than looping. The need to actually do looping is a lot less common than
first imagined.

Mike

Reply via email to