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

Re: [amibroker] Possible division by 0 error



PureBytes Links

Trading Reference Links

look up nz() in the AB help.


best regards,

herman


For tips on developing Real-Time Auto-Trading systems visit:

http://www.amibroker.org/userkb/


Friday, March 14, 2008, 12:43:08 PM, you wrote:


> Can anybody see a way to adjust this "Dynamic Momentum Index " 

> formula from the Library so that it always returns a value and 

> not "Empty" on some intraday charts:


> _SECTION_BEGIN("Dynamic Momentum Index");

> period = Param( "RSI Period", 13, 1, 100, 1 );

> MAperiod = Param( "MA Period", 5, 1, 100, 1 );

> StDevperiod = Param( "StDev Period", 8, 1, 100, 1 );


upday=IIf(C>>Ref(C,-1),C-Ref(C,-1),0);

> downday=IIf(Ref(C,-1)> C,Ref(C,-1)-C,0);


> Stda=MA(StDev(C,StDevperiod),MAperiod);

> V1=StDev(C,StDevperiod)/Stda;

> TD=int(period/V1);


> Su=Sum(upday,TD);

> Sd=Sum(downday,TD);

> M1=(Su-Sd);

> M2=abs(Su+Sd);

> DMI=50*(M1+M2)/M2;

> xs=Param("Smoothing",3,1,10,1);

> xs1=Param("Trigger Line",5,1,10,1);


> Plot(EMA(DMI,xs),"Dynamic Momentum Index ",colorRed,1);

> Plot(MA(DMI,xs1),"trigger",colorBlue,1);

> Buy=Cross(EMA(DMI,xs),MA(DMI,xs1));

> Sell=Cross(MA(DMI,xs1),EMA(DMI,xs));

> PlotShapes(IIf(Buy ,shapeUpArrow,shapeNone) ,colorBrightGreen);

> PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorOrange);

> Plot(70,"",2,1);Plot(30,"",2,1);

> _SECTION_END();


> I have tried substituting:

>  Max(C,0.0001) instead of close

> also:  DMI = (50*M1)/M2 + 50; 

> instead of: DMI=50*(M1+M2)/M2;

> These were attempts to clear out any division by zero errors but 

> didn't make a difference.

> Any suggestions on ways to make it work please?

> Patrick





> ------------------------------------


> 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

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


__._,_.___

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

__,_._,___