Somethings wrong with the 3 digits code ......

 
//+------------------------------------------------------------------+
//| Initialize program's function                                    |
//+------------------------------------------------------------------+
   void OnInit()
   {
   
      if ( Digits == 3 || Digits == 5 )
      {
         Slippage = Slippage * 10 ;
      }
      
      
      
      if ( Point == 0.001 )
      {
         Multiplier = 0.01 ;
      }
      else
      {
         Multiplier = Point ;
      }
      
      
      
      if ( Point == 0.00001 )
      {
         Multiplier = 0.0001 ;
      }
      else
      {
         Multiplier = Point ;
      }
      
   }
//+------------------------------------------------------------------+

The multiplier is to calculate the SL and TP for 2 to 5 digits broker . The 4 and 5 digits works fine, however the problem lies with the 3 digits broker .

EJ at buy ( or sell ) 140.540, SL and TP for 30 pips should be 140.240 and 140.840 . Should works fine with the 2nd if after initialize . However it shows 140.510 for SL and 140.570 for TP .

If the point == 0.00001 is at the 2nd place instead of the last, the 3 digits works perfectly fine and the problems changes to 4 and 5 digits ....

Doesn't have problem at older build though .

 
juniorlcq:

The multiplier is to calculate the SL and TP for 2 to 5 digits broker . The 4 and 5 digits works fine, however the problem lies with the 3 digits broker .

EJ at buy ( or sell ) 140.540, SL and TP for 30 pips should be 140.240 and 140.840 . Should works fine with the 2nd if after initialize . However it shows 140.510 for SL and 140.570 for TP .

If the point == 0.00001 is at the 2nd place instead of the last, the 3 digits works perfectly fine and the problems changes to 4 and 5 digits ....

Doesn't have problem at older build though .

Your code wouldn't have worked on the old build either
if ( Point == 0.001 )
      {
         Multiplier = 0.01 ;   // with 3 Digits, Point = 0.001, so Multiplyer = 0.01
      }
      else
      {
         Multiplier = Point ;
      }
      
      
      
      if ( Point == 0.00001 )  //Point does not = 0.00001
      {
         Multiplier = 0.0001 ;
      }
      else
      {
         Multiplier = Point ;  //So multiplyer is changed to 0.001
      }
 
No it works fine until now ... How can I change it ...
 
juniorlcq:
No it works fine until now ... How can I change it ...


We help guys don't know what's wrong with the code

they get an answer why it is wrong....

and then they ignore totally the help they get ....

if ( Point == 0.001 )
      {
         Multiplier = 0.01 ;   // with 3 Digits, Point = 0.001, so Multiplyer = 0.01
         Print("check one Point = ",Point,"  Multiplier = ",Multiplier);
      }
      else
      {
         Multiplier = Point ;
         Print("check two Point = ",Point,"  Multiplier = ",Multiplier);
      }
      
      
      
      if ( Point == 0.00001 )  //Point does not = 0.00001
      {
         Multiplier = 0.0001 ;
         Print("check three Point = ",Point,"  Multiplier = ",Multiplier);
      }
      else
      {
         Multiplier = Point ;  //So multiplyer is changed to 0.001
         Print("check four Point = ",Point,"  Multiplier = ",Multiplier);
      }

Ofcours it works fine...... it suddenly changed

I think if You're wrong you should apologize to GumRai

 
deVries:


We help guys don't know what's wrong with the code

they get an answer why it is wrong....

and then they ignore totally the help they get ....

Ofcours it works fine...... it suddenly changed

I think if You're wrong you should apologize to GumRai



I'm sorry cause' I'm dumb enough to not understand the answer .
What I don't understand is, I already have 2 if for 3 and 5 point to change it to 0.01 and 0.0001 .

Why do you all said the last if does not == 0.00001, and why does multiplier change to 0.001 ? It should be 0.0001 if point is not equal to 0.00001 .

 
juniorlcq:



I'm sorry cause' I'm dumb enough to not understand the answer .
What I don't understand is, I already have 2 if for 3 and 5 point to change it to 0.01 and 0.0001 .

Why do you all said the last if does not == 0.00001, and why does multiplier change to 0.001 ? It should be 0.0001 if point is not equal to 0.00001 .


if ( Point == 0.001 )
      {
         Multiplier = 0.01 ;   // with 3 Digits, Point = 0.001, so Multiplyer = 0.01
         Print("check one Point = ",Point,"  Multiplier = ",Multiplier);
      }
      else
      {
         Multiplier = Point ;
         Print("check two Point = ",Point,"  Multiplier = ",Multiplier);
      }
      
      
      
      if ( Point == 0.00001 )  //Point does not = 0.00001
      {
         Multiplier = 0.0001 ;
         Print("check three Point = ",Point,"  Multiplier = ",Multiplier);
      }
      else
      {
         Multiplier = Point ;  //So multiplyer is changed to 0.001
         Print("check four Point = ",Point,"  Multiplier = ",Multiplier);
      }

EURUSD

EURJPY.... let us know what prints you have with this code

 
juniorlcq:



I'm sorry cause' I'm dumb enough to not understand the answer .
What I don't understand is, I already have 2 if for 3 and 5 point to change it to 0.01 and 0.0001 .

Why do you all said the last if does not == 0.00001, and why does multiplier change to 0.001 ? It should be 0.0001 if point is not equal to 0.00001 .

You really need to read and understand this: Can price != price ? simply checking if two doubles are equal is asking for issues.
 

Does this make sense to you?

  x=3;
  
  if (x==3)      y=2;    //YES x==3, so y must =2
  if (x!=3)      y=x;    //as x=3,(x!=3)cannot be true, so y remains =2
  
  if (x==5)      y=4;    //No x==3, so it certainly doesn't ==5
  if (x!=5)      y=x;    //x=3, so (x!=5) is true, so y=3
  
  
  
  
  x=3;
  
  if (x==5)      y=4;    //No x==3, so it certainly doesn't ==5
  if (x!=5)      y=x;    //x=3, so (x!=5) is true, so y=3
  
  if (x==3)      y=2;    //YES x==3, so y must =2
  if (x!=3)      y=x;    //x does =3, (x!=3) is false so y stays =2

There is no way that your code worked in a previous build. It would not work in any build.

Thank you DeVries :)

 
    Slippage = Slippage * 10 ;
Each time you change timeframes (or pairs) slippage increases by 10 (or 100 with the double oninit calls. ) 10, 100, 1000, 10000... Do it right don't multiple repeatedly don't compare doubles.
 
RaptorUK:
You really need to read and understand this: Can price != price ? simply checking if two doubles are equal is asking for issues.


Thank you . It helps !! *Mucks!*
 
WHRoeder:
Each time you change timeframes (or pairs) slippage increases by 10 (or 100 with the double oninit calls. ) 10, 100, 1000, 10000... Do it right don't multiple repeatedly don't compare doubles.

Oh I didn't notice that ... is it okay if I put in a switch function ?
Reason: