Need help with this code D:

 

Hi everyone, i must say that i'm not a coder, so this is one of my first attemp to make my own indicator, its based on rules wrote in other language but i wanted in mql4.
I attached the mql4 file if anyone could answer me whats wrong. For an unknown reason the code works fine till i try to calculate the EMA(ExtAverage, Line 216) of an array (ExtCal, Line 211) that was previously populated, and if the EMA can't be calculated then the next part of the indicator keeps in blank (ExtResult, Line 223). 

Hope someone could help me.

Files:
TEST1.mq4  19 kb
 
MarcoyLiss:

Hi everyone, i must say that i'm not a coder, so this is one of my first attemp to make my own indicator, its based on rules wrote in other language but i wanted in mql4.
I attached the mql4 file if anyone could answer me whats wrong. For an unknown reason the code works fine till i try to calculate the EMA(ExtAverage, Line 216) of an array (ExtCal, Line 211) that was previously populated, and if the EMA can't be calculated then the next part of the indicator keeps in blank (ExtResult, Line 223). 

Hope someone could help me.

When you look at your Terminal->Experts, it says "zero divide in 'TEST1.mq4' (210,24)". So you need to check the value of 'a'.


 
Seng Joo Thio:

When you look at your Terminal->Experts, it says "zero divide in 'TEST1.mq4' (210,24)". So you need to check the value of 'a'.


Thanks for the answer, but i'm still caught in that, don't know why the code get back a zero divide error if i suppose that the calls of the bollinger bands (iBands) is written correctly.

 
MarcoyLiss:

Thanks for the answer, but i'm still caught in that, don't know why the code get back a zero divide error if i suppose that the calls of the bollinger bands (iBands) is written correctly.

You can add a Print statement (as below, before line 206) to see the values of limit2 and the total number of bars - limit2 must be at least 20 less than the total number of bars in your chart (because bollinger bands require 20 bars for computation) or else iBands will give you zero.

   Print (limit2, ", ", iBars(NULL,0));
Reason: