• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 7:07pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:07pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

MT4 check CPU resources 1 reply

Why cpu busy was busy on news 1 reply

indicator taking up cpu resources??? 3 replies

Help ! this Indicator causes CPU spikes 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: Why does this program use up CPU resources? Please Help!
Cancel

Why does this program use up CPU resources? Please Help!

  • Post #1
  • Quote
  • First Post: Mar 14, 2011 10:20am Mar 14, 2011 10:20am
  •  kk007
  • Joined Feb 2009 | Status: Commercial Member <- Don't trust me | 2,976 Posts
I was used to use 8 MTF_MA.mq4 and packed them in a template. Nevertheless, I want to consolidate them into 1 mq4. I modify the code, but it draw a lot of CPU resource and slow down my computer.

Is there anything wrong in the program? Please help!

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

#property copyright "Copyright ?2007-08, TrendLaboratory"
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Chocolate
#property indicator_color2 FireBrick
#property indicator_color3 FireBrick
#property indicator_color4 Chocolate
#property indicator_color5 FireBrick
#property indicator_color6 FireBrick
#property indicator_color7 FireBrick
#property indicator_color8 FireBrick
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 1
#property indicator_width6 2
#property indicator_width7 2
#property indicator_width8 2


//string short_name;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//IndicatorDigits(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);
return(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);
return(0);
}


int DrawEMA(int TimeFrame, int MA_Period, int LineNo)
{
int limit, y, i, shift,mBars, mcnt_bars, draw_begin, cnt_bars=IndicatorCounted();
double aPrice[], MA[], mMA[];

switch(TimeFrame)
{
case 1 : string TF = "M1"; break;
case 5 : TF = "M5"; break;
case 15 : TF = "M15"; break;
case 30 : TF = "M30"; break;
case 60 : TF = "H1"; break;
case 240 : TF ="H4"; break;
case 1440 : TF="D1"; break;
}
draw_begin=MA_Period*TimeFrame/Period();
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_bars<1)
{
for(i=1;i<=draw_begin;i++)
{
MA[Bars-i]=iMA(NULL,TimeFrame,1,0,0,0,Bars-i);
}
mcnt_bars = 0;
}

if(mcnt_bars > 0) mcnt_bars--;

for(y=mcnt_bars;y<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 > Period())
{
if(cnt_bars>0) cnt_bars--;
limit = Bars-cnt_bars+TimeFrame/Period()-1;

for(shift=0,y=0;shift<limit;shift++)
{
if (Time[shift] < iTime(NULL,TimeFrame,y)) y++;
MA[shift] = mMA[mBars-y-1];
}
}
return;
}


double EMA(double price,double array[],int per,int bar)
{
if(bar == 2) double ema = price;
else
if(bar > 2) ema = array[bar-1] + 2.0/(1+per)*(price - array[bar-1]);
return(ema);
}
  • Platform Tech
  • /
  • Why does this program use up CPU resources? Please Help!
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023