Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1331

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
Sorry, got caught up in the conversation here, didn't notice...
A common theme, and your codes are always interesting...
took a lot for myself)
The technical task is understood better in Ukrainian
I'm not at that level yet, my mother tongue is Russian :)
...but I understand it on a casual levelI don't have that level yet, my first language is Russian :)
I am from the USSR...I have two mother tongues)
I am from the USSR... I have two mother tongues)
and we've got three, still surzhik.
I'm not very good at maths - how do I calculate distance from order open to stop in the code, so I can replace sl with this one?
Anormalised the lot value like thisSo, it remains to understand how to calculate the distance from the open price to the stop in the code?
The absolute value of the difference between the open and stop price should be divided by the price step.
And this value sl goes into the formula.
Considering that you put a stop calculated by the ATR indicator, it is enough to
And this will already be the normalised lot size.buyopening price
buy stop loss
spread
Now I understand, I just have to understand, which value I should assign to buy and sell prices.
In other words, I assign Ask to the buy open price, f to the sell open price I assign Bid?
In the code, I open an order in the following way.
You mean I assign Ask to the buy open price and Bid to the sell open price variable?
Judging by this function, you already know the stop loss... I don't understand what the issue is
Divide the absolute value of the difference between the open and stop price by the price step.
and this sl value will go into the formula.
Considering that you put a stop calculated by the ATR indicator, it is enough to
And that would be the normalised lot size.I did it by code as you advised. In the beginning of the code I have the condition to choose the type of stop - atp or fixed.
Then I commented my normalization and assigned it this way
Profit calculation is next in the code. No problems there and after calculating the profit I added the scary formula I've been advised to use.
All was compiled without errors. But when I ran the test the error appears in the log, it's division by zero as far as I understand and the test is stopped. Where did I mess up here or what didn't I do right?