the value returned by CopyBuffer cannot be divided during debugging
our topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
read the online documents on how to load handles.
double ma5[]; int ma5_handle= INVALID_HANDLE ; int OnInit() { ArraySetAsSeries(ma5,true); ma5_handle=iMA(_Symbol,PERIOD_CURRENT,5,0,MODE_SMA,PRICE_CLOSE); EventSetTimer(10); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { EventKillTimer(); } void OnTimer() { if (CopyBuffer(ma5_handle,0,0,20,ma5) == 20) { double a=1/ma5[12]; Print(_Symbol," ",ma5[0]," ",ma5[12], " ", a); } }
try it out
Can you help me?
This is all my code:
An error "Zero devided" is reported on the third row code from the bottom:double a=1/ma5[12];
When I delete it, the value of the indicator ma5[12] is not zero !
Why can't it be divided?