Estaba acostumbrado a usar 8 MTF_MA.mq4 y los empaqueté en una plantilla. Sin embargo, quiero consolidarlos en 1 mq4. Modifico el código, pero consume muchos recursos de CPU y ralentiza mi computadora.

¿Hay algo mal en el programa? ¡Por favor ayuda!

----------------------------

#property copyright Copyright? 2007-08, TrendLaboratory
# enlace de propiedad http://finance.groups.yahoo.com/group/TrendLaboratory

#property indior_chart_window
#property indior_buffers 8
#property indior_color1 Chocolate
#property indior_color2 FireBrick
#property indior_color3 FireBrick
#property indior_color4 Chocolate
#property indior_color5 FireBrick
#property indior_color6 FireBrick
#property indior_color7 FireBrick
#property indior_color8 FireBrick
#property indior_width1 1
#property indior_width2 1
#property indior_width3 1
#property indior_width4 1
#property indior_width5 1
#property indior_width6 2
#property indior_width7 2
#property indior_width8 2


//string short_name;

// ----------------------------------------------- -------------------
//| Función de inicialización interior personalizado |
// ----------------------------------------------- -------------------
int init ()
{
//----
//IndiorDigits (MarketInfo (Symbol (), MODE_DIGITS) 2);
SetIndexStyle (0, DRAW_LINE);
SetIndexStyle (1, DRAW_LINE);
SetIndexStyle (2, DRAW_LINE);
SetIndexStyle (3, DRAW_LINE);
SetIndexStyle (4, DRAW_LINE);
SetIndexStyle (5, DRAW_LINE);
SetIndexStyle (6, DRAW_LINE);
SetIndexStyle (7, DRAW_LINE);
retorno (0);
}
// ----------------------------------------------- -------------------
//| AllAverages_v2.2 |
// ----------------------------------------------- -------------------
int start ()
{

DrawEMA (5, 10, 0);
DrawEMA (5, 50, 1);
DrawEMA (15, 50, 2);
DrawEMA (60, 10, 3);
DrawEMA (60, 50, 4);
DrawEMA (60, 200, 5);
DrawEMA (1440, 10, 6);
DrawEMA (1440, 50, 7);
retorno (0);
}


int DrawEMA (int TimeFrame, int MA_Period, int LineNo)
{
límite de int, y, i, shift, mBars, mcnt_bars, draw_begin, cnt_bars = IndiorCounted ();
doble aPrice [], MA [], mMA [];

interruptor (TimeFrame)
{
caso 1: cadena TF = M1; descanso;
caso 5: TF = M5; descanso;
caso 15: TF = M15; descanso;
caso 30: TF = M30; descanso;
caso 60: TF = H1; descanso;
caso 240: TF = H4; descanso;
caso 1440: TF = D1; descanso;
}
draw_begin = MA_Period * TimeFramePeriod ();
SetIndexDrawBegin (LineNo, draw_begin);
SetIndexLabel (LineNo, TF ( MA_Period ));
SetIndexBuffer (LineNo, MA);

if (TimeFrame! = Period ()) mBars = iBars (NULL, TimeFrame); else mBars = Bars;

ArrayResize (aPrice, mBars);
ArrayResize (mMA, mBars);

if (cnt_barslt; 1)
{
para (i = 1; ilt; = draw_begin; i )
{
MA [Bars-i] = iMA (NULL, TimeFrame, 1,0,0,0, Bars-i);
}
mcnt_bars = 0;
}

if (mcnt_bars gt; 0) mcnt_bars--;

para (y = mcnt_bars; ylt; mBars; y )
{
aPrice [y] = iMA (NULL, TimeFrame, 1,0,0,0, mBars-y-1);
mMA [y] = EMA (aPrice [y], mMA, MA_Period, y);
if (TimeFrame == Period ())
{
MA [mBars-y-1] = mMA [y];
}
}
mcnt_bars = mBars-1;

if (TimeFrame gt; Period ())
{
if (cnt_barsgt; 0) cnt_bars--;
limit = Bars-cnt_bars TimeFramePeriod () - 1;

para (shift = 0, y = 0; shiftlt; limit; shift )
{
if (Time [shift] lt; iTime (NULL, TimeFrame, y)) y ;
MA [cambio] = mMA [mBars-y-1];
}
}
regreso;
}


doble EMA (precio doble, doble matriz [], int per, int bar)
{
if (bar == 2) doble ema = precio;
más
if (barra gt; 2) ema = matriz [barra-1] 2.0(1 por) * (precio - matriz [barra-1]);
retorno (ema);
}