seeminly simple idea, kicking my @ss, please help
-
hi attemping to make a ea based on round numbers, specificly every 100 pips..would like to place a pending order at x.xx90 for buy and x.xx10 sor sell...seemingy simple but...round number detector seems confused at times and is never exactly on round number , so cant find it that way, and pending oreder in grid , witch should work, cant seem to get a round number correct at start, in other words, if at x.xx33 when start ea , will grid will place trades acording to the 33 level, not the 00 level i desire.. have spent countless times tring diffent methods and cant find the simple answer i know is there, please help.. or is there a way to get pending order gind to start from a 00 mark?? thanks in advance
-
Round numbers detector is some kind of filter, it should be placed somewhere under "on Tick" so it can check the current price at every tick and it would pass every time the price reaches a new round number. But this block is not really suitable for making pending orders.
In the pending orders blocks there is nothing about round numbers, this is something that I should add, but who knows when. Anyway, I got something for you. These are some simple formulas for calculating round numbers out of the Bid price (in this example): https://fxdreema.com/shared/xHE9eHHHc
MathCeil() and MathFloor() are MQL4 functions that give you the nearest bigger and the nearest smaller integer:
https://www.mql5.com/en/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathceil
https://www.mql5.com/en/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathfloorBid is a predefined variable in MQL4 and it gives you the current Bid price of course. There is Ask as well.
My example gives this result on the chart: http://prntscr.com/hafr46
These values can be used as Open Price for a pending order and you can also customize the formula if you want.