Download MetaTrader 5
To add comments, please log in or register
Share links from other resources. Now they have a description.
Harry
267
Harry 2014.03.03 03:28 

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 )


qjol
3243
qjol 2014.03.03 03:57  
r u sure the problem is in those lines ?
Harry
267
Harry 2014.03.03 04:09  

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

Keith Watford
Moderator
7979
Keith Watford 2014.03.03 05:04  
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

Daniel Petrovai
440
Daniel Petrovai 2014.03.05 05:14  
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.

/
To add comments, please log in or register