4/5 digit broker question.

 

Hello MQL4 community,

Four digit broker: "3" is equivalent to 3.

Five digit broker: "30" is equivalent to 3.

Please confirm that the above two statements are correct.

Thank you.

 
WhooDoo22:

Hello MQL4 community,

Four digit broker: "3" is equivalent to 3. //3 Point == 3 Pip

Five digit broker: "30" is equivalent to 3. //30 Point == 3 Pip

Please confirm that the above two statements are correct. // it is never 30 is 3 do you change 30 dollar for 3 dollar ??

Thank you.

 

@deVries:

"it is never 30 is 3 do you change 30 dollar for 3 dollar ??"

No. :)


When coding a SL in an EA for a five digit broker, "30*Point" is equivalent to 3 points.

When coding a SL in an EA for a four digit broker, "30*Point" is equivalent to 30 points.

Please state otherwise if this is incorrect.

Thank you.

 

When coding a SL in an EA for a five digit broker, "30*Point" is equivalent to 30 points equivalent to 3 pips

When coding a SL in an EA for a four digit broker, "30*Point" is equivalent to 30 points. equivalent to 30 pips

Adjust for points/pips on stops AND slippage

//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.015      0.0150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){                                             OptInitialization();
     if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
    /* On ECN brokers you must open first and THEN set stops
    int ticket = OrderSend(..., 0,0,...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0))
       Alert("OrderModify failed: ", GetLastError());
     */
 

@WHRoeder:

If what I wrote is correct, then all the code in "SRC" can be simplified.

Example:

int  TP=50;
int  SL=50;
int  slip=3;
bool 4digit;
bool 5digit;

if(4digit)

  {TP*1; SL*1; slippage*1;}

if(5digit)
 
  {TP*10; SL*10; slippage*10;}

Thank you.

 
WhooDoo22:

@WHRoeder:

If what I wrote is correct, then all the code in "SRC" can be simplified.

Your code will not work . . . what does this do ?

{TP*10; SL*10; slippage*10;}
 

int TP = 50.

50*10 = 500.

500 = 50 for a 5 digit broker. The multiplication of 10 to the number will add a zero to the end of the number.

I believe that it would work. Why would it not?

Maybe this would make more sense...

{TP=TP*10; SL=SL*10; slip=slip*10;}

Thanks Simon.

 
WhooDoo22:

int TP = 50.

50*10 = 500.

500 = 50 for a 5 digit broker. The multiplication of 10 to the number will add a zero to the end of the number.

I believe that it would work. Why would it not?

Maybe this would make more sense...

Yes it would and it would compile and change the values. Alternatively you could just spend some time to understand WHRoeder's code and use that . . .


If you use your code you need to be careful that it isn't executed more than once at ant time including when changing chart timeframes . . . . . otherwise slip goes from slip to slip*10 to slip*100 to slip*1000, etc
 

I will spend time to understand WHRoeder's code.

Thank you.