[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Backwards loop


  • Date: Wed, 13 Jan 2010 12:07:21 -0000
  • From: "angio" <angio1967@xxxxxxxx>
  • Subject: [amibroker] Re: Backwards loop

PureBytes Links

Trading Reference Links

Thanks Mike, 

I try it.

--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> 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@> 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/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/