How to deal with 4 o 5 digits ?

 

Hi, I'm implementing a function which get the numbers of pips between two price levels. But depending of the digits of the broker I get differents values, for example

Price1: 1,5510

Price2: 1,5500

Difference in 4 digit broker: 0,001, so 0,001/Point = 10 pips

Difference in 5 digit broker: 0,001, so 0,001/Point = 100 pips

I solve this issue by using a constant of 0,0001 to divide the result of the difference instead of Point, in this way I'm able to make the function independent of the broker digits.

But I guess should be a better way to do this.


Any help would be appreciated!

 

Standart answer of WHRoeder:

//++++ These are adjusted for 5 digit brokers.
double  pips2points,    // slippage  3 pips    3=points    30=points
        pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int init(){
    if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
 

I tried a million times a solution like zzuegg proposes, but without success. I suggest you that you hardcode it, like you are doing. Multiply to 0.001 or 0.01 and that's it.

It worked for me smoothly.

 
qjol:

https://www.mql5.com/en/forum/123324 & next tie u can use search as i did


Thanks for your colaboration, but the information on that link is about counting orders, and my issue is about the decimal digits of the broker. Thanks anyway.
 

sorry it's supposed to be an answer for https://www.mql5.com/en/forum/130469

i deleted it

 
zzuegg:

Standart answer of WHRoeder:

My standard answer included the comment
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
Must adjust TP, SL and Slippage. Most forget the last.
 

first of all, thanks for your answers.

I'm trying to understand the idea, is there a public program where this is implemented? so in this way I can understand it more easily.

 
desert:

first of all, thanks for your answers.

I'm trying to understand the idea, is there a public program where this is implemented? so in this way I can understand it more easily.

https://www.mql5.com/en/code/9987

Quite the same concept.

take a look at:

init() function how pointMod is set

start() function how pointMod is applied to trading operation.


I am shure there are others too, but that one is from me so i know that it is used.

Reason: