Help, one EA with multicurrency on multiframe make terminal freeze

 

I'm using one EA in multicurrency on multiframe, the terminal sometimes freeze, I don't know why? The protype as following:

for (int i = 0; i < TOTALTRADESYMBOLS; i++)
{
  string symbol = AllTradeSymbols[i];
  ...
  double r_mn1_0 = iRSI(symbol, PERIOD_MN1, 3, PRICE_CLOSE, 0);
  double r_mn1_1 = iRSI(symbol, PERIOD_MN1, 3, PRICE_CLOSE, 1);

  double mh4_5_0 = iMA(symbol, PERIOD_H4, 5, 0, MODE_SMA, PRICE_CLOSE, 0);
  double mh4_5_1 = iMA(symbol, PERIOD_H4, 5, 0, MODE_SMA, PRICE_CLOSE, 1);
  double ch4_0 = iClose(symbol, PERIOD_H4, 0);
  ...
}

  If I comment all iRSI, iMA and other indicator calculations, the EA will be fine, but useless. Any solutions or idea, please. 

 
soarowl:I'm using one EA in multicurrency on multiframe, the terminal sometimes freeze, I don't know why? The protype as following: If I comment all iRSI, iMA and other indicator calculations, the EA will be fine, but useless. Any solutions or idea, please.  
Optimize your code | reduce the work-load [bars, ticks] | or get a more-powerful computer. There's not much within the above code to cause mt4 to freeze, therefore, look elsewhere. Watch out for endless loops, thats usually the cause of freezing in my experience.
 
#define TOTALTRADESYMBOLS 43

string AllTradeSymbols[TOTALTRADESYMBOLS] =
{
        "AUDUSDpro",
        "AUS200",
        "COPPER",
        "CORN",
        "COTTON",
        "ESTX50",
        "EURUSDpro",
        "FRA40",
        "GBPUSDpro",
        "GER30",
        "HK40",
        "HTG_OIL",
        "JPN225",
        "NAS100",
        "NZDUSDpro",
        "PALLAD",
        "PLAT",
        "SOYBEAN",
        "SPX500",
        "SUGAR",
        "UK100",
        "UK_OIL",
        "US30",
        "USDCADpro",
        "USDCHFpro",
        "USDCNHpro",
        "USDCZKpro",
        "USDDKKpro",
        "USDHUFpro",
        "USDJPYpro",
        "USDMXNpro",
        "USDNOKpro",
        "USDPLNpro",
        "USDRUBpro",
        "USDSEKpro",
        "USDSGDpro",
        "USDTRYpro",
        "USDZARpro",
        "US_NATG",
        "US_OIL",
        "WHEAT",
        "XAGUSDpro",
        "XAUUSDpro",
};
I monitor above symbols on xxxxxxxx demo plateform. My EA money management and trailing stop modification are fine, but if I calculate enter/exit market condition using some internal indicatiors, terminal will be freezed in minutes or hours. Am too greedy, too many symbols?
 
soarowl:
 I monitor above symbols on www.xxx.com demo plateform. My EA money management and trailing stop modification are fine, but if I calculate enter/exit market condition using some internal indicatiors, terminal will be freezed in minutes or hours. Am too greedy, too many symbols? 

Please remove your .com reference because promotions are against the rules. Couple of recommendations:

1> Decrease the number of Bars_in_Chart. Tools>Options>Charts.

2> Run 1_Expert on 1_Chart. [ If you're not already doing so ] 

3> Don't open 43 Windows. Occasionally open another then close.

4> Loop shows you're processing all 43-Symbols within 1_Sub loop.

-if this EA is attached to more than 1_chart, this'll become a processor hog for every loop which has that TOTALTRADESYMBOLS.

5> Try using Once_Per_Minute or Once_Per_Bar. [ If system's not tick sensitive ].

6> Don't duplicate Calculations. Save Calculations to File|GlobalVarSet|Static.

- Kinda like the same concept of Standard_Indicators. [ not processing every_bar on every_tick ]

If the same EA_Logic applies to all Instruments, then write the expert like you're doing it for one. Then pass the Symbol's Name one_at_a_time. Example Here. However, if different Instruments have different trading logics, then make each it's own Expert.

7> If all else fails, purchase a more powerful computer ;) 

 
soarowl:

I'm using one EA in multicurrency on multiframe, the terminal sometimes freeze, I don't know why? The protype as following:

  If I comment all iRSI, iMA and other indicator calculations, the EA will be fine, but useless. Any solutions or idea, please. 


every new tick on chartsymbol you do all calculations again 

when the loop is ended the calculated functions you have are only the calculated values you did for your last symbol

so inside the loop you have to do everything for every symbol  separatly

.. 

double r_mn1_0[TOTALTRADESYMBOLS];  ???? 

for (int i = 0; i < TOTALTRADESYMBOLS; i++)
{
  string symbol = AllTradeSymbols[i];
  ...
  r_mn1_0[i] = iRSI(symbol, PERIOD_MN1, 3, PRICE_CLOSE, 0);
 

My EA logic as following:

for (int i = 0; i < TOTALTRADESYMBOLS; i++)
{
  string symbol = AllTradeSymbols[i];
  ...
  double r_mn1_0 = iRSI(symbol, PERIOD_MN1, 3, PRICE_CLOSE, 0);
  double r_mn1_1 = iRSI(symbol, PERIOD_MN1, 3, PRICE_CLOSE, 1);

  double mh4_5_0 = iMA(symbol, PERIOD_H4, 5, 0, MODE_SMA, PRICE_CLOSE, 0);
  double mh4_5_1 = iMA(symbol, PERIOD_H4, 5, 0, MODE_SMA, PRICE_CLOSE, 1);
  double ch4_0 = iClose(symbol, PERIOD_H4, 0);
  ...
  // For each symbol Enter/exit logic here 
}

// For each order, trailing stop logic as following:
int total = OrdersTotal();
for (int i = total - 1; i >= 0; i--)
{
  if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
  {
    // Adjust trailing stop logic here.
    ...
  }
}

 Thanks to ubzen, I will refine my EA. 

 
I change "Max bars in history" and "Max bars in chart" to 5000, everything is fine now. Many thanks to ubzen again.
 
soarowl: I change "Max bars in history" and "Max bars in chart" to 5000, everything is fine now. Many thanks to ubzen again. 
You're welcome.
 

Max bars in history determine size of the disk files - minimizing that just removed history you might have wanted for the tester

max bars in chart determines the size of ram used and initial number of bars to process.

 
I perfer forward testing other than backtesting, so those options are OK.