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

[amibroker] ATR - whats wrong ?



PureBytes Links

Trading Reference Links

I want to write ATR step by step. I write code:

##########################
num=2;

ATR1=ATR(1);
ATRNUM=ATR(num);

a1=High-Low;
a2=abs(High-Ref(Close, -1));
a3=abs(Low-Ref(Close, -1));
MYATR1=Max(a1, Max(a2, a3));

MYATRNUM=0;
for( i = 1; i < BarCount; i++ )
{
    x=0;
    for (j=1; j <= num; j++)
    {
        x = x + MYATR1[i-num+j];
    }
    MYATRNUM[i]=x/num;
}

Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_N(Title = Title + "\n"+ "num: " + NumToStr(num,1.2,False));
_N(Title = Title + "\n"+ "ATR(1): " + NumToStr(ATR1,1.2,False));
_N(Title = Title + "  "+ "ATR(num): " + NumToStr(ATRNUM,1.2,False));
_N(Title = Title + "\n"+ "(MY)ATR(1): " + NumToStr(MYATR1,1.2,False));
_N(Title = Title + "  "+ "(MY)ATR(num): " + NumToStr(MYATRNUM,1.2,False));
###########################


What wrong with MYATRNUM ? ATRNUM and MYATRNUM are different. Could anybody help me with that ?


Regards


__._,_.___

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___