Results 1 to 4 of 4

Thread: Rounding to non-standard numbers in MQL4

  1. #1

    Rounding to non-standard numbers in MQL4

    When trading CFD's which potentially have a minimum increment/tick dimensions of 0.25 in the case of the SP500, I need to discover a method of rounding some like a moving average or ATR into the closest of the tiniest increment.

    NormalizeDouble(78.2123,0.25) will trune the 0.25 into the closest number in this case 0 then round to 78

    as will:

    MathRound(78.2123)

    anybody have some ideas?

    cheers

    M

  2. #2
    You can also try
    Inserted Code double a=78.1251; double ticksize=0.25; a=NormalizeDouble(MathRound(a/ticksize)*ticksize,2); Print(a= DoubleToStr(a,2));

  3. #3
    wow, thanks guys, very much appreciated!
    I'll try them in the morning
    M

  4. #4
    Inserted Code double d = 78.2123; double ticksize = 0.25; Id = (int)(d / ticksize ticksize) * ticksize; NormalizeDouble(d, 2); Print(d);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners. Read more.