Jump to content

Close all Orders on pair/magic...


expat1967

Recommended Posts

Hi All,

 

getting an error: "assignment expected" on marked lines below... Appreciating your support, or if you function in the drawer... ;)

 

Cheers

 

void CloseOrderIf()

{

double TotalProfit;

 

for(int i=0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS);

 

if(OrderMagicNumber()==Magic)

 

TotalProfit != OrderProfit();

}

 

if(TotalProfit >= Amount20)

{

//Close all trades

for(i=0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS);

 

if(OrderSymbol() == Symbol() &&

OrderMagicNumber()==Magic)

{

if(OrderType() == OP_BUY)

{

OrderClose(OrderTicket(), OrderLots(), Bid, 3);

i--;

}

 

if(OrderType() == OP_SELL)

{

OrderClose(OrderTicket(), OrderLots(), Ask, 3);

i--;

}

}

}

}

}

Link to comment
Share on other sites

Not sure what you are after, but I think you should change that red ! to a +

 

Thanks Kenny, found a solution already. It should close all trades wit a specific magic number on a cummulated profit...

 

{

double dblProfit=0;

int POS=0;

bool boolTerm=false;

while(boolTerm==false)

{

if(OrderSelect(POS,SELECT_BY_POS))

{

if(OrderMagicNumber()==Magic) dblProfit=dblProfit+OrderProfit();

POS++;

}

else

boolTerm=true;

}

if (dblProfit>= ProfitAmount)

{

CloseOrderLong();

CloseOrderShort();

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...