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

[amibroker] simple code question



PureBytes Links

Trading Reference Links

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.  




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

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

<*> 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/