• Get access

'Close all'/'Open' tools - page 2

To add comments, please log in or register
Sergey Golubev
Moderator
114813
Sergey Golubev  
glader:
I am trading LIVE. Do you trade LIVE? Could it be broblem? Thanks for help in advance...

It was Alpari demo account.

You mean that you tried to use it with real account?

Should work as well.

glader
83
glader  
newdigital:
It was Alpari demo account.

You mean that you tried to use it with real account?

Should work as well.

Yes, I ve tried to use it with real account on live but there was an error msg...

Quite confuse but thanks for your help anyway...

ma6
3
ma6  
glader:
I tried it, but ERROR : 4109

Tools->Options->ExpertAdvisors-> V Enable ExpertAdvisors(...and Scripts)

glader
83
glader  
ma6:
Tools->Options->ExpertAdvisors-> V Enable ExpertAdvisors(...and Scripts)

Thank you so much... it is working now !!!

Sergey Golubev
Moderator
114813
Sergey Golubev  

CloseOnTime EA from Kimiv.

Files:
rocko1
11
rocko1  
ma6:
Tools->Options->ExpertAdvisors-> V Enable ExpertAdvisors(...and Scripts)

I'm still getting the same error. What do you mean by "V"?

thanks

sibil
3
sibil  

I have the same problem.

Order ...... failed to close .Error:4109

SloForeX
196
SloForeX  

Close all opened orders

I have a question about how to close all opened trades. That include trades wich were opened manually.

Here is the code:

if(BalanceEquityProtectionLevel > 0 && AccountEquity() <= AccountBalance ()* BalanceEquityProtectionLevel)

{

AllowTrading = false;

Print("Min. Equity Level Reached - Trading Halted For ",Symbol());

// Alert("Min. Equity Level Reached - Trading Halted For ",Symbol());

for(cnt=OrdersTotal();cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

mode=OrderType();

if (mode==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Blue); }

if (mode==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Red); }

// }

}

}

The problem is that, If I have opened a few pairs it's not always true that all trades will be closed too. Further more, it happend that EA continue to open another trade despite the parameter allowtrading == false.

I was debugging this thing and noticed that for some reason this code block was not executed for all pairs. Why, I don't know. Does somebody know answer to that?

This block should close all opened orders and prevent further trading.Maybe I could resolve this issue with writting parameter false to a file or something? The problem in this situation is also with pairs that have no opened orders.

Thanks..

Dejan

european
479
european  

Here's my code that i wrote long time ago, it will close all running positions.

#include

#include

int start()

{

double sA;

int cnt, totalOrders;

totalOrders = OrdersTotal();

if (totalOrders>0)

{

for (cnt=0;cnt<totalOrders;cnt++)

{

OrderSelect(0, SELECT_BY_POS);

if (OrderType() == OP_BUY) sA = MarketInfo(OrderSymbol(),MODE_BID);

else sA = MarketInfo(OrderSymbol(),MODE_ASK);

OrderClose(OrderTicket(),OrderLots(),sA,3,CLR_NONE);

}

}

return(0);

}

SloForeX
196
SloForeX  

Your code is very similar than mine. The results are the same. I attached a picture, to make some things more clearly.

EA does close all trades for pair GBPUSD (picture). As you can see, after this another trade is opened. (1 means allowtrade is true, 0 allowtrade is false).

Files:
image3.jpg 359 kb
To add comments, please log in or register