How to remove the last digit if the "digit count > 5 "
-
Case -:
High - 1.08713
Low - 1.08282
price distance (High - Low) = 0.00431Mid-Level Price = High - (Price Distance / 2 )
The issue is when I dived the price distance by "2", sometimes the digit count is above 5 digits. The math works without no issues,
But when place a trade using these prices are not working. because let's say the entry price is came as 1.089003
then there is a issue.My EA didn't placed orders. I guess this digit issue is the case here.
Question -:
are there any code blocks to remove the last digit of a price level when it was saved into a variable ?.
-
DoubleToString(YourValue,2) this will cut the digits after the "." to 2
-
I need to pick the variable that contains the 6 digits number and do the math, then update that variable to the correct value. Can you help bro, honestly, I don't know how to code custom MQL codes.
-
do you have the value like "1.089003", and if so would it need to be 1.08 or 1.09? With the code above you can just put the variable name where I put "YourValue"
-
brother, will this condition block check the price value in "PDif" has more than 5 digits compared to the original digit by broker?

-
Is this your lot size, or a price value?
-
Price value bro.
(High - Low ) / 2ex - (1.08713 - 1.08282) / 2
= 0.002155
-
You do not need to normalise price values, and if you want the middle value it is high+low/2 or low+high/2 makes no diffrance if adding
-
No bro, I need to calculate the "middle value", so then I can "subtract" the middle value from the "Low" to determine the "Stop loss" for the buy pending order I'm about to set at Low.
-
In this case, Sometimes the middle value has 6 decimal places, let's say I want to place buy pending order on EURUSD, stop loss has 6 decimal places, which will never place the pending order. (as I think)
-
I have done this many times, you just need to add the 2 together and divide by 2
-
it working brother.. thanks for the support