Close All Positions Only for Selected Chart
3件の返信
To close all open position and orders only for EURUSD for example (not for all active charts in MT) you would need a custom function that contains Symbol check
void sqCloseAllOrdersForChart() {
for(int i=OrdersTotal()-1; i>=0; i--) {
if (OrderSelect(i,SELECT_BY_POS)==true) {
if((OrderType() == OP_BUY || OrderType() == OP_SELL) && Symbol() == OrderSymbol()) {
sqClosePositionAtMarket(-1);
} else if (Symbol() == OrderSymbol()) {
tmpRet = OrderDelete(OrderTicket());
}
}
}
}
これを EA Wizard / code / CustomFunctions.mq4 ファイルに追加してください。その後、添付の例に示されているように、Wizardでそのまま使用できます。.
0
To close all open position and orders only for EURUSD for example (not for all active charts in MT) you would need a custom function that contains Symbol check
void sqCloseAllOrdersForChart() { for(int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i,SELECT_BY_POS)==true) { if((OrderType() == OP_BUY || OrderType() == OP_SELL) && Symbol() == OrderSymbol()) { sqClosePositionAtMarket(-1); } else if (Symbol() == OrderSymbol()) { tmpRet = OrderDelete(OrderTicket()); } } } }これを EA Wizard / code / CustomFunctions.mq4 ファイルに追加してください。その後、添付の例に示されているように、Wizardでそのまま使用できます。.
Thank you Tomas, this answers many of my prayers!
0
Quick question: Do we create another folder into which to place this file (…/code/CustomFunctions)? or place it in the Code folder?
0
Open the existing EAW / code / CustomFunctions.mq4 and add this new function there
0
3件の返信を表示中 - 1 - 3件目 (全3件中)