MarketInfo(NULL, MODE_TICKVALUE)
- You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, MarketInfo does not. OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period.
- No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, MarketInfo does not. OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period.
- No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
Thanks, I will take care of it from now on. Just changed my code.
But in this case the result is the same. I receive the same lot size to be closed. There is an error in the maths and I can't figure out the missing part in it.
EDIT: Problem solved!Why don't you open just two orders? The first one (the partial close volume) with a TakeProfit at 1.1700.
If you do a partial close, the broker creates a new position with a new ticket, which you have to search for..
Why don't you open just two orders? The first one (the partial close volume) with a TakeProfit at 1.1700.
If you do a partial close, the broker creates a new position with a new ticket, which you have to search for..
I never thought about that because for me it doesn't matter if a new position with a new ticket is created. Additionally I don't use partial closes all the time. Only when prices comes to an area which might cause troubles.
Multiple EAs on same symbol, order modify conflict - Trailing Stop - MQL4 and MetaTrader 4 - MQL4 programming forum

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
this script should close a part of the running trade just to cover a possible loss if the stoploss would be hit.
For example I bought EURUSD at 1.1600 and the stoploss is at 1.1550. Price rises to 1.1700. Now I want to sell exactly the amount of lots that the rest position is safe in case of price falling down to my stoploss at 1.1550.
I hope that makes sense.
Here is my code so far. Everything seems to be correct until the very last part of the code where I try to calculate the lots to close.