PureBytes Links
Trading Reference Links
|
I'm not sure that I entirely understand your question. But, try something like this:
per = 10;
xxx = High - Low; // Use any _expression_ you want
diff = 0;
cont = NZ(null, null);
currentBar = BarCount - 1;
firstBar = max(0, currentBar - per);
for (bar = currentBar - 1; bar >= firstBar; bar--) {
if (xxx[bar] > diff) {
diff = xxx[bar];
cont[bar] = (currentBar - bar);
} else {
diff = iif(bar > firstBar, xxx[bar - 1], 1);
cont[bar] = cont[bar + 1];
}
}
Plot(xxx, "XXX", colorBlue, styleBar);
Plot(cont, "CONT", colorRed, styleStaircase | styleOwnScale);
Mike --- In amibroker@xxxxxxxxxxxxxxx, "angio" <angio1967@xxx> wrote: > > hello guys, > can someone help me to write this loop for an indicator, there are many days that I try but I can't do !!! > > - the beginning of the loop is the bar before today > - the loop length is the variable PER (for example 10) > > *** Then the loop works from BAR -1 to BAR -10 *** > > PER=10; > > XXX= my _expression_; > > DIFF=0; set variable to 0 > CONT=0; set variable to 0 > > in the loop: > > If XXX > DIFF > then DIFF = XXX > and CONT assumes the number of backwards bar in the loop > > for example: > > BAR -1 XXX > 0 cont = 1 > BAR -2 XXX > diff cont = 2 > BAR -3 XXX > diff cont = 3 > BAR -4 XXX > diff cont = 4 > BAR -5 XXX > diff cont = 5 > BAR -6 XXX > diff cont = 6 > BAR -7 XXX < diff cont = 6 break loop, CONT assumes 6 > BAR -8 XXX < diff cont = 6 > BAR -9 XXX > diff cont = 6 > BAR -10 XXX > diff cont = 6 > > The main problem is how to set the beginning of the loop and how to assign values to the arrays earlier in reverse from the usual. > > I hope I was clear, thanks for the reply. > Angio >
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___
|