MQL4 "possible loss of data due to type conversion" for old indicator

 

Hi everyone,

I copy my indicator from one PC to the other and this notice shows up even though it works fine with the first PC.

"possible loss of data due to type conversion"

Also it take long time for the MT4 to upload the old indicator. I notice the different of MQL4 wizard when I open it. Is that the reason for the notice and the slow?

Could you please help me out with it?

Thank you,

SCFX

for(i=numberbars-1; i>=1;i--)
   {     
         d1bar_3 = iBarShift(Symbol(), D1, Time[i]) + 3;
...
...
if ( iADX(NULL,D1,14,0,0,d1bar_3)<=27 )


 
r u sure the problem is in those lines ?
 

Yes, the notice point to that line.

That's so weird since I work in other PC and I DO NOT do anything, just copy to new PC and it doesn't run. It turn GRAY in the indicator windows.

Then I try to Comprise it and that notice shows up.

SCFX

 
scfx:

Yes, the notice point to that line.

That's so weird since I work in other PC and I DO NOT do anything, just copy to new PC and it doesn't run. It turn GRAY in the indicator windows.

Then I try to Comprise it and that notice shows up.

SCFX


Which line?

It is probably something like you are using a double value, where an integer is expected

for example

       d1bar_3 = iBarShift(Symbol(), D1, Time[i]) + 3;

if your variable D1 is a double, you will get that warning

 
scfx:

Hi everyone,

I copy my indicator from one PC to the other and this notice shows up even though it works fine with the first PC.

"possible loss of data due to type conversion"

Also it take long time for the MT4 to upload the old indicator. I notice the different of MQL4 wizard when I open it. Is that the reason for the notice and the slow?

Could you please help me out with it?

Thank you,

SCFX




Hi scfx,

Possible loss of data due to conversion means that the program is converting something into something else. Let me explain.

Some programmers used, as a shortcut, when they didn't need the decimals an int variable to store a double variable's value. Something like this :

int x;
double y=Ask; // this is an example
if(your condition here) x=y;

The program will store the int value of y into x and discard the decimals but will generate the warning, not error,you get.

If you want to fix it, look trough the code and find the int variable . You can then make it a double and before you assign value to it, get rid of the decimals.

If you just change it's type to a double you may alter the calculations from that point on, so if the code requires an int value, you can just normalize it to zero decimals.

Does it make any sense to you ?

In your example if dlbar_3 and D1 are of int type, I don't really see a conversion between two types.

My guess is (as GumRai already mentioned) that D1 may be a double.

Reason: