And what job would that be?
Showing us the code that "does not do the job" but not explaining what that job is or what you expect it to do, serves no purpose.
How can we help you if we don't know what you are expecting?
We cannot read your mind, so please elaborate on your requirements, hopefully more clearly and in detail.
EDIT: And please format/style your code properly before posing so that it will be easier to read. Use MetaEditor's Styler Tool.
After a very quick look, just skimming over the code, I noticed this:
double percentageloss = balance/100*percentagerisk*ORDER_PRICE_OPEN;
Unfortunately "ORDER_PRICE_OPEN" is not an actual price (opening or otherwise). It is a constant, a property identifier, from the set of values of the "ENUM_ORDER_PROPERTY_DOUBLE" enumeration to be used with the functions OrderGetDouble() and HistoryOrderGetDouble(). You can't use it in the way you have done.
You also cannot calculate a percentage loss from an opening price, so please explain your calculation in more detail because it does not make sense.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use