stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

How to code nearest round number level?
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3676
Page 2 of 2
Author:  SteveHopwood [ Thu Jun 19, 2014 6:37 pm ]
Post subject:  How to code nearest round number level?

Elixe » Thu Jun 19, 2014 1:36 pm wrote:Glad you find it useful :mrgreen:

I'll probably make the "second" logic using pfactor function when I have some spare time, that might be easier to use in your shell if you want to keep theses functions in future EA.
Yes please - never know when I might need this in a multi-pair trader. I just tried, but simply replacing x / Point with x ^ factor doesn't always work, as in double pricetoInt = price / Point; double pricetoInt = price * factor; does not work in dsu's ea. It doesn't work in the risk-based calculation function either - never been able to work out why not.

:xm:
Author:  Elixe [ Thu Jun 19, 2014 7:23 pm ]
Post subject:  How to code nearest round number level?

Here you go, tell me if you have any issues,

tested it with JPY, EUR & XAU, seems to be working fine

There are no input, the script will write its resulting floor/ceil for 10, 100 & 1000 pips in the expert logs.
func_floor_pfactor.mq4
Author:  SteveHopwood [ Thu Jun 19, 2014 9:37 pm ]
Post subject:  How to code nearest round number level?

Elixe » Thu Jun 19, 2014 7:23 pm wrote:Here you go, tell me if you have any issues,

tested it with JPY, EUR & XAU, seems to be working fine

There are no input, the script will write its resulting floor/ceil for 10, 100 & 1000 pips in the expert logs.
Fantastic. Works a treat. Thanks. :clap: :clap: :clap:

I have used your original code in dsu's ea at http://www.stevehopwoodforex.com/phpBB3 ... f=5&t=3695. I have updated the ea on my coding machine with your latest and future updates will include your this.

:xm:
All times are UTC Page 2 of 2