Problem with " *Point "

 

HI,

I got this problem suddently, never before and not in my other EA's, and I cant seem to locate the reason....

x=5;

x*Point=0.0001

I have done a MarketInfo for Point followed by a RefreshRates() and still, everything I *Point, comes out bad.

Same occurrence with my var "point" or the system default " Point".

ask=MarketInfo(Symbol(),MODE_ASK);
ask=NormalizeDouble(ask,Digits);
bid=MarketInfo(Symbol(),MODE_BID);
bid=NormalizeDouble(ask,Digits);
point=MarketInfo(Symbol(),MODE_POINT);

These four come out at .0011.

SL & TP are at 100 and

distance is at 15.

115 comes out as .0011 etc...

buy_stop_SL = (StopLoss+distance)*point; should = .0115 but comes out as .0011

buy_stop_TP = (TakeProfit+distance)*point; should = .0115 but comes out as .0011

sell_stop_SL = (StopLoss+distance)*point; should = .0115 but comes out as .0011

sell_stop_TP = (TakeProfit+distance)*point; should = .0115 but comes out as .0011

I'm sure its a simple oversite of my part but WHERE?

Thanks

 

If I had to guess I would say the value for MODE_POINT is 0.00001 (5 decimal places), not 0.0001 (4 decimal places) for the specific broker you are testing your code with.

115*0.00001 = 0.00115

Now if you are printing this double as a text string then metatrader will truncate the printed value to four decimal places (the default, which can be changed if you like).

Thus when it prints your value it is printing 0.0011

The stored value, used for subsequent calculations, will still be the correct value of 0.00115

The question for you is what are the values for MODE_POINT and Digits for the specific broker and currency pair you are testing?

 
1005phillip:

If I had to guess I would say the value for MODE_POINT is 0.00001 (5 decimal places), not 0.0001 (4 decimal places) for the specific broker you are testing your code with.

115*0.00001 = 0.00115

Now if you are printing this double as a text string then metatrader will truncate the printed value to four decimal places (the default, which can be changed if you like).

Thus when it prints your value it is printing 0.0011

The stored value, used for subsequent calculations, will still be the correct value of 0.00115

The question for you is what are the values for MODE_POINT and Digits for the specific broker and currency pair you are testing?

Makes a lot of sense, if this is the case, it would be the first time in 2 years my broker would have switched to 5 digits for this Symbol (EURUSD)

I will test this.

Thanks

 
  1. Print defaults to 4 decimals. Use Print( DoubleToStr(v,8) ) to see more
  2. Adjust to 5 digit brokers, don't use Point
    //++++ 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; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

 
WHRoeder:
  1. Print defaults to 4 decimals. Use Print( DoubleToStr(v,8) ) to see more
  2. Adjust to 5 digit brokers, don't use Point

This looks like exactly what I was looking for, now I understand more the principle.

I will study this more and do some tests and get back to you.

Thank you very much WHR.

Micky

 
Micky52:

This looks like exactly what I was looking for, now I understand more the principle.

I will study this more and do some tests and get back to you.

Thank you very much WHR.

Micky


Thanks WHRoeder, it works fine.

Now the lengthy process of adjusting all my EA's. LOL

Thank You

Micky

 

Use my function, solve this point problem in the easiest way.

https://www.mql5.com/en/forum/127435