Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1329
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
Hi. How do I make a leaderboard here?
top ?
Good afternoon, all. I am trying to attach a lot size calculation to the Grail machine, so that the lot is set as a percentage of the deposit in case of loss. In other words, if a stop loss triggers, the specified percentage of the deposit is lost, or if the deposit is small for this percentage, then the lot is set to the minimum possible for the broker... I found a script on some website that does such things and transferred the script code to myself, but the lot is not considered correctly... I did so. In the input variables I declared a variable responsible for the maximum risk.
Then I declare variables in the on tick. A variable that stores the amount of free funds in the account. A variable of a point value of a symbol. A variable of a broker's minimum lot. A variable that stores the value of maximum lot at the broker. And the variable which stores the lot size step.
And then the lot volume with a given risk at a certain stop loss is calculated. Stop Loss is calculated by atp or fixed in pips - this calculation works correctly because if I put a fixed lot then all is well open and works. The formula for calculating the lot volume is as follows.
After all of the calculations through the print print lot value to view it.
What is displayed in the logbook
Good afternoon, all. I am trying to attach a lot size calculation to the Grail machine, so that the lot is set as a percentage of the deposit in case of loss. In other words, if a stop loss triggers, the specified percentage of the deposit is lost, or if the deposit is small for this percentage, then the lot is set to the minimum possible for the broker... I found a script on some website that does such things and transferred the script code to myself, but the lot is not considered correctly... I did so. In the input variables I declared a variable responsible for the maximum risk.
Then I declare variables in the on tick. A variable that stores the amount of free funds in the account. A variable of a point value of a symbol. A variable of a broker's minimum lot. A variable that stores the value of maximum lot at the broker. And the variable which stores the lot size step.
And then the lot volume with a given risk at a certain stop loss is calculated. Stop Loss is calculated by atp or fixed in pips - this calculation works correctly because if I put a fixed lot then all is well open and works. The formula for calculating the lot volume is as follows.
After all these calculations I print the lot value to check it.
What is printed in the logbook can be seen at ***
At first glance, the function seems to be OK. The only thing you should put in the formula is not the order stoploss price but the distance from the order opening to the stop in points.
Then we need to normalize the lot to accuracy, not _Digits but to Step - (incremental step of lot size). Print should be outputted through DoubleToString() with the same accuracy, then you will see what you want to see.
Good afternoon everyone. I'm trying to get a lot size calculation into the Grail machine,
I've done this
At first glance the function seems fine. The only thing we should add to the formula is the distance in points from the order opening to the stop, rather than the stoploss price of the order.
Furthermore: we should normalize the lot to accuracy, not to _Digits but to Step - (incremental step of lot size) and you should output it to Print using DoubleToString() with the same accuracy.
My mathematics is not very good - how to calculate distance from order opening to stop and replace sl with this one?
Anormalised the lot value like thisSo, it remains to be seen how to calculate the distance from the open position to the stop in the code.
So it remains to be seen how to calculate the distance from the open to the stop in the code?
Thank you very much for the piece of code, but the question now is what type to declare the variables in this piece of code and what values to assign to them? I'm not a wizard, I'm just learning.
Thank you very much for the piece of code, but the question now is what type to declare the variables in this piece of code and what values to assign to them? I'm not a magician, I'm just learning
open price to buy
buy stop loss price
spreadGreetings!
Can someone help me?