| / | Forum |
|
seattlerust
2011.01.25 20:37
I occasionally have a number of limit buy or sell orders in place (multiple lots so I can scale out) that bog down just before reaching execution level and I would like to execute all of them at one time at market. Is there an EA available that does this? Thanks, SR |
|
How to Enrich Information You Present? Use Videos! How to get more information over to the viewers? There is a very simple method to prepare a video to be published on the MQL4.community website using new technologies. |
|
qjol
2011.01.25 22:48
not AFAIK simple to do this 1) for () // loop all the orders 2) OrderSelect() // select_tham_one_by_one 3) if () // find if it's the order u loocking for by OrderType (& or whatever) 4) OrderDelete() // this order 5) OrderSend() // a new one at market price 6) mission accomplished 7) It was so hard ?? |
|
seattlerust
2011.01.25 23:23
qjol:
not AFAIK simple to do this
But thanks for this. I will try to make use of it. SR |
|
sxTed
2011.01.26 01:26
seattlerust, please try the following untested code:
double dPP, dSL, dTP; for (int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if (OrderType() >= OP_BUYLIMIT && OrderType() <= OP_SELLSTOP) { if (OrderType()%2 == OP_BUY) dPP = MarketInfo(OrderSymbol(),MODE_ASK); else dPP = MarketInfo(OrderSymbol(),MODE_BID); dSL = OrderStopLoss(); dTP = OrderTakeProfit(); if (dSL!=0) dSL=dPP-(OrderOpenPrice()-dSL); if (dTP!=0) dTP=dPP+(dTP-OrderOpendPrice()); if (OrderSend(OrderSymbol(),OrderType()%2,OrderLots(),dPP,5,dSL,dTP,OrderComment(),OrderMagicNumber()) == false) { Print("OrderTicket ",OrderTicket()," modify error ",GetLastError()); return; } if (OrderDelete(OrderTicket()) == false) { Print("OrderTicket ",OrderTicket()," delete error ",GetLastError()); return; } } } } |
|
seattlerust
2011.02.01 07:42
|