You could have saved a lot of your time if you would have searched for: close profitable positions => https://www.mql5.com/en/search#!keyword=close%20profitable%20positions&module=mql5_module_codebase.
E.g.: https://www.mql5.com/en/code/19364. Not exactly what you want but easy to adapt.
This:
if(PositionSelect(_Symbol))
works only on netting positions I would use PositionGetTicket(idx). Type it place the cursor there and press F1 and read what it does and can.
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
You could have saved a lot of your time if you would have searched for: close profitable positions => https://www.mql5.com/en/search#!keyword=close%20profitable%20positions&module=mql5_module_codebase.
E.g.: https://www.mql5.com/en/code/19364. Not exactly what you want but easy to adapt.
This:
works only on netting positions I would use PositionGetTicket(idx). Type it place the cursor there and press F1 and read what it does and can.
- 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 all, I am attempting to write a function that cycles through open positions and closes all those that are in profit by x amount and then returns true, and would return false in the case where no positions have been closed, I have the following code which seems to be ineffective, could someone please offer insight as to where I am going wrong?