You might want to use Print() or PrintFormat() to examine your Range and your _Point
(Monitor the Expert Log to see the Print() output there)
Good luck.
Tips:
This article might be useful too
https://www.mql5.com/en/articles/10211
(Monitor the Expert Log to see the Print() output there)
Good luck.
Tips:
This article might be useful too
https://www.mql5.com/en/articles/10211

Market math: profit, loss and costs
- www.mql5.com
In this article, I will show you how to calculate the total profit or loss of any trade, including commission and swap. I will provide the most accurate mathematical model and use it to write the code and compare it with the standard. Besides, I will also try to get on the inside of the main MQL5 function to calculate profit and get to the bottom of all the necessary values from the specification.
Thank you for your help! I'll try it out.
Hi
When you calculated Range it’s already a decimal value (not in points) – so when you then multiply by “Point” it’s very small value –hence it’s closing immediately. Just use:
SL = Bid - Range;
And this will work properly (just make sure that you will be using correct price Bid/Ask for proper trades.
Have a nice day👍📊

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, i'm pretty new to automated trading and have a problem. I'm trying to programm a EA that open a trade (under specific conditions) at the high of the previous candle. My problem is that i try to set the stop loss at the low of the previous candle. I got the Low and the high of the previous candle with the iLow/iHigh function. After that i programmed:
Range = (high - low);
SL = Bid - Range*_Point;
trade.Buy(0.1,_Symbol,Ask,SL);
The SL (and TP if coded like that) will always be the same as the open price of the trade and immedeately closes the position. If i put a number like 400 instead of (high-low) it works perfectly fine.
Why does it work with a number but not with (high-low) and what am a doing wrong?
Thank you very much in advance for your help!