I was trying to code a dashboard indicator based on some sample code which I found online. The code is:
//+------------------------------------------------------------------+ //| FLI_MP_HAS.mq4 | //| Copyright ? 2009, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright ? 2009, MetaQuotes Software Corp."#property link "http://www.metaquotes.net"#property indicator_chart_window string q[] = {"EURUSD","GBPUSD","USDJPY","EURJPY","GBPJPY","USDCHF","USDCAD","NZDUSD"};
int t[] = {PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1,PERIOD_W1,PERIOD_MN1};
string TAG="FLIMPHAS";
externint maMethod = 2;
externint maPeriod = 6;
externint maMethod2 = 3;
externint maPeriod2 = 2;
int nq, nt;
externint xShift=300;
externint yShift=250;
int getHAS(string s, int tf)
{
double a, b;
a = iCustom(s,tf,"Heiken_Ashi_Smoothed",maMethod,maPeriod,maMethod2,maPeriod2,6,0);
b = iCustom(s,tf,"Heiken_Ashi_Smoothed",maMethod,maPeriod,maMethod2,maPeriod2,7,0);
if (a<b) return(1);
if (a>b) return(-1);
return(0);
}
void ObDeleteObjectsByPrefix(string Prefix)
{
int L = StringLen(Prefix);
int i = 0;
while(i < ObjectsTotal())
{
string ObjName = ObjectName(i);
if(StringSubstr(ObjName, 0, L) != Prefix)
{
i++;
continue;
}
ObjectDelete(ObjName);
}
}
int init()
{
int i, j;
deinit();
nq = ArraySize(q);
nt = ArraySize(t);
ObjectCreate(TAG+"Head",OBJ_LABEL,0,0,0,0,0);
ObjectSet(TAG+"Head",OBJPROP_CORNER,1);
ObjectSet(TAG+"Head",OBJPROP_XDISTANCE,xShift+55);
ObjectSet(TAG+"Head",OBJPROP_YDISTANCE,yShift+0);
ObjectSetText(TAG+"Head","Heiken Ashi Smoothed DB",12,"Courier",DeepSkyBlue);
for (i=0;i<nq;i++)
{
ObjectCreate(TAG+"lblCurr"+i,OBJ_LABEL,0,0,0,0,0);
ObjectSet(TAG+"lblCurr"+i,OBJPROP_CORNER,1);
ObjectSet(TAG+"lblCurr"+i,OBJPROP_XDISTANCE,xShift+180);
ObjectSet(TAG+"lblCurr"+i,OBJPROP_YDISTANCE,yShift+20*(i+1));
ObjectSetText(TAG+"lblCurr"+i,q[i],12,"Courier",Silver);
for (j=0;j<nt;j++)
{
ObjectCreate(TAG+"x"+j+"c"+i,OBJ_LABEL,0,0,0,0,0);
ObjectSet(TAG+"x"+j+"c"+i,OBJPROP_CORNER,1);
ObjectSet(TAG+"x"+j+"c"+i,OBJPROP_XDISTANCE,xShift+150-(20*j));
ObjectSet(TAG+"x"+j+"c"+i,OBJPROP_YDISTANCE,yShift+20*(i+1));
}
}
return(0);
}
int deinit()
{
ObDeleteObjectsByPrefix(TAG);
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
int a;
int i, j;
for (i=0;i<nq;i++)
{
for (j=0;j<nt;j++)
{
a = getHAS(q[i],t[j]);
if (a==1)
ObjectSetText(TAG+"x"+j+"c"+i,"B",12,"Courier",Lime);
elseif (a==-1)
ObjectSetText(TAG+"x"+j+"c"+i,"S",12,"Courier",Red);
elseif (a==0)
ObjectSetText(TAG+"x"+j+"c"+i,"W",12,"Courier",Yellow);
}
}
return(0);
}
//+------------------------------------------------------------------+
I added th e "Heiken_Ashi_Smoothed" indicator to the folder as well. And it seemed to work correctly when I had just done all of this. Now that I turned on my laptop again and try to attach the dashboard indicator to the chart, MT4 immediately crashes. I have to open the task manager to be able to close it. In order for it to work again, I have to change the code and misspell the name of the indicator called by iCustom, compile it, and only then can I get MT4 back to work. What could be causing this? What can I do to get it to work properly as it did originally?
Any help would be greatly appreciated. Thanks in advance.
I was trying to code a dashboard indicator based on some sample code which I found online. The code is:
I added th e "Heiken_Ashi_Smoothed" indicator to the folder as well. And it seemed to work correctly when I had just done all of this. Now that I turned on my laptop again and try to attach the dashboard indicator to the chart, MT4 immediately crashes. I have to open the task manager to be able to close it. In order for it to work again, I have to change the code and misspell the name of the indicator called by iCustom, compile it, and only then can I get MT4 back to work. What could be causing this? What can I do to get it to work properly as it did originally?
Any help would be greatly appreciated. Thanks in advance.