| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (2) | Thread Tools | Display Modes |
|
|||
|
Hello all,
I want to close all my orders at the same time but i coudn't. I tried this code but it didn't work : '''''''''''''''''''''''''''''''''''''''' total = OrdersTotal(); for(i=0;i < total;i++) { if(OrderSelect(i, SELECT_BY_POS)==true) { OrderClose(OrderTicket(),OrderLots(),Ask,80,CLR_NO NE); OrderClose(OrderTicket(),OrderLots(),Bid,80,CLR_NO NE); } } '''''''''''''''''''''''''''''''''''''''' Can anybody help me ? I would be very grateful if you can help me |
|
|||
|
Mehdi,
Put this code (procedure) outside start() section and when you if the condition is met to close all trades, just call the procedure like that: int start() { // your code here ..... If (your condition here) ShutDownAllTrades(); } void ShutDownAllTrades { int Retry; While (OrdersTotal()>0) { for (int cnt=OrdersTotal()-1;cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderType()==OP_BUY) { Retry=0; while (Retry<5 && !IsTradeAllowed()) { Retry++; Sleep(1000); } RefreshRates(); OrderClose(OrderTicket(),OrderLots(),Bid,Slippage, Yellow); Sleep(1000); } else if (OrderType()==OP_SELL) { Retry=0; while (Retry<5 && !IsTradeAllowed()) { Retry++; Sleep(1000); } RefreshRates(); OrderClose(OrderTicket(),OrderLots(),Ask,Slippage, Yellow); Sleep(1000); } else { Retry=0; while (Retry<5 && !IsTradeAllowed()) { Retry++; Sleep(1000); } OrderDelete(OrderTicket()); Sleep(1000); } } } } HTH Yannis |
|
|||
|
Quote:
I added your procedure between " int deinit() { } " (out of start) as you said but there is a problem via compiling after void ShutDownAllTrades { : '{' comma or semicolon expected . I look forward to hearing from you. Thanks a lot Last edited by MehdiForex; 10-03-2006 at 01:42 PM. |
|
|||
|
Oops sorry.
What's missing is the () after void ShutDownAllTrades() Be careful also for the variable named 'Slippage' in the orderclose function. You might need to replace that with the one you are using when you place your orders. Yannis |
|
|||
|
Quote:
!Thanks again |
|
||||
|
Quote:
As far as I know ObjectsRedraw() refreshes objects that just been 'created' and 'set'. I need to refresh an indicator which is not on the Object list, so ObjectsRedraw() doesnt work. ![]() Or may be you know how to refer to an existing indicator? Last edited by european; 10-04-2006 at 07:03 AM. |
|
|||
|
Hi all,
I wrote an expert but it doesn't work very well i would be very grateful if anybody can help me . I checked MACD in H4 in EUR/GBP and the condition is when the MODE_MAIN of MACD is > 0 BUY EUR and SELL GBP and when is < 0 first of all close previous position and open SELL EUR and BUY GBP. It usually open just one of them . Thanks Last edited by MehdiForex; 10-04-2006 at 12:37 PM. |
![]() |
| Bookmarks |
| Tags |
| histogram |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
|
||||
| Posted By | For | Type | Date | |
| OzFx System:) - Page 639 | This thread | Refback | 06-21-2008 09:53 PM | |
| Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart | This thread | Refback | 12-08-2007 11:46 AM | |