//+------------------------------------------------------------------+ //| GG-TrendBar.mq4 | //| John Taylor | //| http://www.linkedin.com/in/johntaylorhk | //| Original code by "G.Gekko". | //| Replaced PSAR/ADX trend detection method with Close comparison. | //| Factored/rewrote majority of code. | //| Fixed bug where indicator was reversed if placed right of screen | //+------------------------------------------------------------------+ #property copyright "John Taylor" #property link "http://www.linkedin.com/in/johntaylorhk" #property indicator_chart_window #property show_inputs #include extern int E_Corner=3; //0=TL,1=TR,2=BL,3=BR int timeFrame[]={PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1,PERIOD_W1,PERIOD_MN1}; string tf[]={"M1","M5","M15","M30","H1","H4","D1","W1","MN1"}; int nTimeFrames=9; void deleteLabels() { for(int i=0;i=0) ObjectDelete(objName); } } void initLabels() { for(int i=0;i=0) ObjectDelete(objName); ObjectCreate(objName,OBJ_LABEL,0,0,0,0,0); ObjectSet (objName,OBJPROP_CORNER,E_Corner); if(E_Corner==0 || E_Corner==2) { ObjectSet(objName,OBJPROP_XDISTANCE,i*23+15); ObjectSet(objName,OBJPROP_YDISTANCE,20); } else { ObjectSet(objName,OBJPROP_XDISTANCE,(nTimeFrames-1-i)*23+15); ObjectSet(objName,OBJPROP_YDISTANCE,20); } ObjectSetText(objName,objName,8,"Tahoma",Aqua); } } void deleteIndicators() { for(int i=0;i=0) ObjectDelete(objName); } } void initIndicators() { for(int i=0;i=0) ObjectDelete(objName); ObjectCreate (objName,OBJ_LABEL,0,0,0,0,0); ObjectSet (objName,OBJPROP_CORNER,E_Corner); if(E_Corner==0 || E_Corner==2) { ObjectSet (objName,OBJPROP_XDISTANCE,i*23+15); ObjectSet (objName,OBJPROP_YDISTANCE,30); } else { ObjectSet (objName,OBJPROP_XDISTANCE,(nTimeFrames-1-i)*23+15); ObjectSet (objName,OBJPROP_YDISTANCE,30); } setIndicator(i,White); } } void setIndicator(int i,color clr) { ObjectSetText(StringConcatenate("Ind",i),CharToStr(110),12,"Wingdings",clr); } int init() { // Set up text labels correctly oriented for selected corner ... initLabels(); initIndicators(); return(0); } int deinit() { deleteIndicators(); deleteLabels(); return(0); } int start() { color UpColor =Lime; color DnColor =Red; color FlatColor=Yellow; for(int i=0;i lastClose) clr=UpColor; else if(thisClose < lastClose) clr=DnColor; setIndicator(i,clr); } } } return(0); }