Draw horizontal line and calculate round numbers from open price.
-
I want to calculate the round price base on the open price from a buy or sell order. Can you please help?
-
@okranoblues
Did you find a solution?I need a similar solution. I need to know the Upper & Lower Round number from current market price.
From there it should be easy to get your next target TP & SL, by the round number, which I believe is what you want to have.
-
I think we wrote emails back then with okranoblues.
There is only a block that can detect round numbers, but it doesn't give you any values that can be used outside. I guess I need to add something in "Condition" block, but who knows when. Calculating round numbers may be actually easy, especially when the current price is used. In MT4 you can get the Ask/Bid price just by writing Ask or Bid, because they are predefined variables: https://docs.mql4.com/predefined
Here is some calculation:
MathCeil(Ask / gridsize) * gridsizeLet's imagine that Ask is 0.942 and you want to get the upper round number that is rounded to the second digit. You want "gridsize" to be 0.01. Then you have:
MathCeil(0.942 / 0.01) * 0.01And the result is 0.95.
What is MathCeil()? You can see this function here: https://docs.mql4.com/math The function to be used for the lower side is MathFloor()