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

Re: [amibroker] simple code question



PureBytes Links

Trading Reference Links

For most things, AB is way simpler that other languages out there.
Try (one line):
 
plot(C-ref(C,-1), " Change from Yesterdays Close ",colorred,1);
 
-CS
----- Original Message -----
Sent: Friday, June 10, 2005 3:50 PM
Subject: [amibroker] simple code question

I have had Amibroker for awhile now but continued to use TradeStation
because that is what I have been used to and it worked for most of
what I needed.  I decided to dust off Amibroker and see what it can
do but I am having a coding problem.  I want to plot a simple
indicator that measures change. 

In TS, the formula is a relatively simple:

Chg = Close - Close[1];
Plot1(Chg);

In Amibroker what I have is:

for( i = 1; i < BarCount; i++ )
{
Chg =  Close[ BarCount - 1 ] - Close[ BarCount - 2 ];
}
Plot (Chg, "Change", colorBlue, styleLine);

The problem is that the indicator's value is correct on the last bar
of the chart, but it plots that same value on every bar preceding it,
so all that results is a straight line.  I tried it with the Plot
statement inside the For loop but then all I get is a straight line
with many instances of the same value (obviously due to the loop).

I figured I could work it out from the code for Rate of Change, but
that is simply coded with the 'ROC' function, and the code for the
functions are not available to my knowledge.

Any help is appreciated, thanks. 




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links