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

[amibroker] Re: Need help - "for" loop MACD() not incrementing in array



PureBytes Links

Trading Reference Links

As per Steve's original answer, remove the loop. AmiBroker works on the entire array at once. Note also that your comment was wrong; false is 0, non zero is true.

x = MACD();
y = Signal();
Hist = x - y;
z = Hist > Ref(Hist, -1); // z = 1 if True, 0 if False

// To verify
for (bar = 0; bar < BarCount; bar++) {
_TRACE("x =" + x[bar] +" y =" + y[bar] +" Hist =" + Hist[bar]);
}

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "Michael" <herpse30@xxx> wrote:
>
> 
> 
> Steve:
>      I tried several variations of MACD()[i] and MACD[i] but always receive an Error 30, Syntax error. I am wondering if I should just compute MACD and Signal on my own, and increment through the array?
>      I need to keep track of an "up" histogram bar count day as it loops through the code. Is there another way to keep a counter without a for or while loop, and then clear it when a down day occurs?
> Thanks
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@> wrote:
> >
> > Hi - If you want to step through the array bar-by-bar, you should be using 
> > subscripts inside the loop that refer to the bar, e.g.
> > 
> > MCAD[i]
> > 
> > But unless you need the loop for something else, I think you could just 
> > remove the looping code at the top and use your regular array-based AFL to 
> > do what you want...
> > 
> > Steve
> > 
> > ----- Original Message ----- 
> > From: "Michael" <herpse30@>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Wednesday, October 07, 2009 12:08 PM
> > Subject: [amibroker] Need help - "for" loop MACD() not incrementing in array
> > 
> > 
> > > Thanks for lookin'.
> > > I am attempting to process a for loop through EOD data that includes a 
> > > test of the difference between the MACD() and Signal(). I installed a 
> > > trace and found that the MACD() and Signal() are not incrementing through 
> > > the data array. The numbers returned remain the same and I go nowhere.
> > >
> > > What do I have to do to increment MACD() and Signal() through the EOD data 
> > > within a for loop?
> > >
> > > Partial code sample follows:
> > >
> > > for(i = 1; i < BarCount; i++ )
> > > { // for loop bracket
> > > x = MACD();
> > > y = Signal();
> > > Hist = x - y;
> > > z = Hist > Ref(Hist, -1); // z = 0 if True, 1 if False
> > > _TRACE("x =" + x +"  y =" + y +"  Hist =" + Hist);
> > >
> > > Thanks,
> > > Mike L.
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > **** 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
> > >
> > >
> > >
> > >
> >
>




------------------------------------

**** 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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto: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/