#property copyright "" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 RoyalBlue #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 double EMA_H[]; double EMA_L[]; double EMA_C[]; string Sym = ""; int TimeFrame = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); SetIndexBuffer(0,EMA_H); SetIndexBuffer(1,EMA_L); SetIndexBuffer(2,EMA_C); SetIndexStyle( 0, DRAW_LINE ); SetIndexStyle( 1, DRAW_LINE ); SetIndexStyle( 2, DRAW_LINE ); //---- Sym = Symbol(); CleanUp(); //---- return(0); } int deinit() { CleanUp(); return(0); } int start() { double C = 0.0; double O = 0.0; datetime T = 0; for(int i = MathMax(Bars-1-IndicatorCounted(),1); i>=0; i--) { EMA_H[i] = iMA(Sym, TimeFrame, 34, TimeFrame, MODE_EMA, PRICE_HIGH, i ); EMA_L[i] = iMA(Sym, TimeFrame, 34, TimeFrame, MODE_EMA, PRICE_LOW, i ); EMA_C[i] = iMA(Sym, TimeFrame, 34, TimeFrame, MODE_EMA, PRICE_CLOSE, i ); C = iClose( Sym, TimeFrame, i ); O = iOpen( Sym, TimeFrame, i ); T = iTime( Sym, TimeFrame, i ); datetime T2 = iTime( Sym, TimeFrame, i +1 ); if( C > EMA_H[i] ) { ObjectCreate( "RC-"+i, OBJ_RECTANGLE, 0, T, O, T2, C ); ObjectSet("RC-"+i, OBJPROP_XDISTANCE, 15 ); ObjectSet( "RC-"+i, OBJPROP_BACK, True ); ObjectSet( "RC-"+i, OBJPROP_COLOR, Green ); } else if( C < EMA_L[i] ) { ObjectCreate( "RC-"+i, OBJ_RECTANGLE, 0, T, O, T2, C ); ObjectSet("RC-"+i, OBJPROP_XDISTANCE, 15 ); ObjectSet( "RC-"+i, OBJPROP_BACK, True ); ObjectSet( "RC-"+i, OBJPROP_COLOR, Red ); } else { ObjectCreate( "RC-"+i, OBJ_RECTANGLE, 0, T, O, T2, C ); ObjectSet("RC-"+i, OBJPROP_XDISTANCE, 15 ); ObjectSet( "RC-"+i, OBJPROP_BACK, True ); ObjectSet( "RC-"+i, OBJPROP_COLOR, Blue ); } } //---- return(0); } void CleanUp() { int x = 0; while( ObjectFind("RC-"+x ) != -1 ) { ObjectDelete( "RC-"+x ); x++; } }