MoForce posted # :
Sorry for the silly Q :P but I'm wondering... how do you close all positions? I can't seem to figure out how to code it into my EA :(
Thanks
Try this
#include <trade/trade.mqh>
void OnStart()
{
CTrade trade;
int i=PositionsTotal()-1;
while (i>=0)
{
if (trade.PositionClose(PositionGetSymbol(i))) i--;
}
}

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 for the silly Q :P but I'm wondering... how do you close all positions? I can't seem to figure out how to code it into my EA :(
Thanks