Closing all trades, pips100?

 

Hello,

I'm a novice with MT4 and have a question. Last night i installed an EA (100pips). This EA started very enthousiastic and opened about 160!! trades which were closed during the night. It resulted in a los of about 40 pips. Overnight it opened about 140 trades. Current loss is - 100 pips (not closed yet). Question: can i close all the trades in one time (it seems undoable to close them piece by piece)?

Kind regards Mario

 
int start()
{
  int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    int type   = OrderType();

    bool result = false;

    switch(type)
    {
      //Close opened long positions
      case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
                          break;

      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
                          break;

      //Close pending orders
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }

    if(result == false)
    {
      Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      Sleep(3000);
    }
  }

  return(0);
}

Add this as SCRIPT to your mt4 and call it whenever you need it. Be carefully it closes really all orders does not matter pending or active.
 
./Indicators 100ma_qual.mq44344 bytes
./Indicators 100ma_qual.mq44344 bytes
./Indicators 100_pips.mq44442 bytes
./Experts 100_pips_a_day.mq44442 bytes
./Experts 100_pips_ea.mq44444 bytes
./Experts 100_pips_v2_inverso.mq44590 bytes
./Experts 100_pips_v3.1.mq45285 bytes
./Experts 100_pips_v3.mq44468 bytes
./Experts 100_pips_v3_1_.1.mq44579 bytes
./Indicators 5383_lbr_1000_pips_one_week_ki_signals1_h1_low_3_10_18_optimized.mq44467 bytes
./Experts eurusd_usdchf_atr_100.mq422369 bytes
./Experts makegrid_50_100_200_30pips_stop70.mq411783 bytes
./Experts makegrid_with_100_and_200_ema.mq411683 bytes
./Experts makegrid_with_100_and_200_ema.mq411683 bytes
./Indicators newmacd__50_100_200.mq43263 bytes
./Indicators test_last_100.mq42349 bytes
./Indicators test_last_100.mq42349 bytes
./Experts truesort_1001.mq46222 bytes
./Experts truesort_1100.mq45901 bytes
./Scripts zz_timewinter_1_1000.mq42120 bytes
./Indicators zz_yz_mdac_elder_1_1000.mq46427 bytes


There seems to be different version of that EA. check http://www.fx1.net/codelibrary.php for others.
 
fx1.net:

Add this as SCRIPT to your mt4 and call it whenever you need it. Be carefully it closes really all orders does not matter pending or active.

Thank you!! Thart saves a lot af time. And thnx for the array of EA's. Which one is your favorite?
 
Mario123:

Thank you!! Thart saves a lot af time. And thnx for the array of EA's. Which one is your favorite?

I just installed one of the EA's you sent me. Backtesting revealed that that EA performed bad on the 15 min bar but did very well on the 5 min bar. Can one install the EA just for one bar-chart?
 
Mario i dont have any experience with that EA, so i cannot help you with that. You can install same EA to unlimited charts
 
fx1.net:
Mario i dont have any experience with that EA, so i cannot help you with that. You can install same EA to unlimited charts

It's just to understand how MT4 works. When i install any EA, it runs on all charts. This particular EA operates best at the M5 chart so i want to install it just for that chart. Do you know if that is possible in MT4 or is it something you have to enclose in the EA?
Reason: