Convert Price To Pips
-
Hello, I'm trying to check the distance between the Support and Resistance objects in my project, convert that to pips, and then divide the distance in pips by 2 to use as take profit and stop loss. I've looked at a ton of threads in this forum trying to figure out how to do this correctly, but wasn't able to get it working. I'm only able to get it working by dividing the price by 0.0001 (EURGBP).
Here is my project: https://fxdreema.com/shared/25OiIW1ve
Is there anyway to adjust this so that I can use it on multiple pairs? Currently doing the price to pip conversion in the "Convert to Pips" formula.
-
You can do it with this code, create a variable called Distance, the price is relevent to what you are using:
MQL4
price1 = 1.2345;
price2 = 1.2350;// Calculate the absolute difference in price
double difference = MathAbs(price1 - price2);// Convert the difference to points and store in Distance
Distance = difference / Point;// Optionally, you can print the value of Distance for verification
Print("The distance in points is: ", Distance);
MQl5:
price1 = 1.2345;
price2 = 1.2350;// Calculate the absolute difference in price
double difference = MathAbs(price1 - price2);// Convert the difference to points and store in Distance
Distance = difference / _Point;// Optionally, you can print the value of Distance for verification
// Print("The distance in points is: ", Distance); -
Sorry for the late reply, but this works perfectly thank you so much!
-
@MelloMatt You are welcome