How to code nearest round number level?

User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

How to code nearest round number level?

Post by SteveHopwood »

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:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
Elixe
Trader
Posts: 98
Joined: Tue Jun 04, 2013 6:44 pm
Location: France

How to code nearest round number level?

Post by Elixe »

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
You do not have the required permissions to view the files attached to this post.
:D
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

How to code nearest round number level?

Post by SteveHopwood »

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:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Coders Hangout”