//+------------------------------------------------------------------+ //| Candle_Range_in_pips.mq4 | //| Zen_Leow | //| | //+------------------------------------------------------------------+ #property copyright "Zen_Leow" #property link "" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 SkyBlue #property indicator_width1 3 double Range_Buffer[]; double Range_Buffers0; double Range_Buffers1; double Range_Buffers2; double Range_Buffers3; double Range_Buffers4; double Range_Buffers5; double Range_Buffers6; color PlusColor = clrLime; color MinusColor = clrRed; color NameColor = clrGray; int PipFactor = 1; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- drawing settings SetIndexStyle(0,DRAW_NONE); SetIndexBuffer(0,Range_Buffer); SetIndexLabel(0,"Range"); //---- name for DataWindow and indicator subwindow label IndicatorShortName("Candle Range"); IndicatorDigits(2); // Cater for fractional pips if (Digits == 3 || Digits == 5) { PipFactor = 10; } //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("CRP0"); ObjectDelete("CRP1"); ObjectDelete("CRP2"); ObjectDelete("CRP3"); ObjectDelete("CRP4"); ObjectDelete("CRP5"); ObjectDelete("CRPL0"); ObjectDelete("CRPL1"); ObjectDelete("CRPL2"); ObjectDelete("CRPL3"); ObjectDelete("CRPL4"); ObjectDelete("CRPL5"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i Range_Buffers1) ObjectSetText("CRP0", DoubleToStr(Range_Buffers0,1) + " Pips", 10, "Arial Bold", PlusColor); else if (Range_Buffers0 < Range_Buffers1) ObjectSetText("CRP0", DoubleToStr(Range_Buffers0,1) + " Pips", 10, "Arial Bold", MinusColor); ObjectCreate("CRPL0", OBJ_LABEL, 0, 0, 0); ObjectSet("CRPL0", OBJPROP_CORNER, 1); ObjectSet("CRPL0", OBJPROP_XDISTANCE, 90); ObjectSet("CRPL0", OBJPROP_YDISTANCE, 5); ObjectSetText("CRPL0", "0 Candle ", 10, "Arial Bold", NameColor); ObjectCreate("CRP1", OBJ_LABEL, 0, 0, 0); ObjectSet("CRP1", OBJPROP_CORNER, 1); ObjectSet("CRP1", OBJPROP_XDISTANCE, 5); ObjectSet("CRP1", OBJPROP_YDISTANCE, 20); if (Range_Buffers1 > Range_Buffers2) ObjectSetText("CRP1", DoubleToStr(Range_Buffers1,1) + " Pips", 10, "Arial Bold", PlusColor); else if (Range_Buffers1 < Range_Buffers2) ObjectSetText("CRP1", DoubleToStr(Range_Buffers1,1) + " Pips", 10, "Arial Bold", MinusColor); ObjectCreate("CRPL1", OBJ_LABEL, 0, 0, 0); ObjectSet("CRPL1", OBJPROP_CORNER, 1); ObjectSet("CRPL1", OBJPROP_XDISTANCE, 90); ObjectSet("CRPL1", OBJPROP_YDISTANCE, 20); ObjectSetText("CRPL1", "1 Candle ", 10, "Arial Bold", NameColor); ObjectCreate("CRP2", OBJ_LABEL, 0, 0, 0); ObjectSet("CRP2", OBJPROP_CORNER, 1); ObjectSet("CRP2", OBJPROP_XDISTANCE, 5); ObjectSet("CRP2", OBJPROP_YDISTANCE, 35); if (Range_Buffers2 > Range_Buffers3) ObjectSetText("CRP2", DoubleToStr(Range_Buffers2,1) + " Pips", 10, "Arial Bold", PlusColor); else if (Range_Buffers2 < Range_Buffers3) ObjectSetText("CRP2", DoubleToStr(Range_Buffers2,1) + " Pips", 10, "Arial Bold", MinusColor); ObjectCreate("CRPL2", OBJ_LABEL, 0, 0, 0); ObjectSet("CRPL2", OBJPROP_CORNER, 1); ObjectSet("CRPL2", OBJPROP_XDISTANCE, 90); ObjectSet("CRPL2", OBJPROP_YDISTANCE, 35); ObjectSetText("CRPL2", "2 Candle ", 10, "Arial Bold", NameColor); ObjectCreate("CRP3", OBJ_LABEL, 0, 0, 0); ObjectSet("CRP3", OBJPROP_CORNER, 1); ObjectSet("CRP3", OBJPROP_XDISTANCE, 5); ObjectSet("CRP3", OBJPROP_YDISTANCE, 50); if (Range_Buffers3 > Range_Buffers4) ObjectSetText("CRP3", DoubleToStr(Range_Buffers3,1) + " Pips", 10, "Arial Bold", PlusColor); else if (Range_Buffers3 < Range_Buffers4) ObjectSetText("CRP3", DoubleToStr(Range_Buffers3,1) + " Pips", 10, "Arial Bold", MinusColor); ObjectCreate("CRPL3", OBJ_LABEL, 0, 0, 0); ObjectSet("CRPL3", OBJPROP_CORNER, 1); ObjectSet("CRPL3", OBJPROP_XDISTANCE, 90); ObjectSet("CRPL3", OBJPROP_YDISTANCE, 50); ObjectSetText("CRPL3", "3 Candle ", 10, "Arial Bold", NameColor); ObjectCreate("CRP4", OBJ_LABEL, 0, 0, 0); ObjectSet("CRP4", OBJPROP_CORNER, 1); ObjectSet("CRP4", OBJPROP_XDISTANCE, 5); ObjectSet("CRP4", OBJPROP_YDISTANCE, 65); if (Range_Buffers4 > Range_Buffers5) ObjectSetText("CRP4", DoubleToStr(Range_Buffers4,1) + " Pips", 10, "Arial Bold", PlusColor); else if (Range_Buffers4 < Range_Buffers5) ObjectSetText("CRP4", DoubleToStr(Range_Buffers4,1) + " Pips", 10, "Arial Bold", MinusColor); ObjectCreate("CRPL4", OBJ_LABEL, 0, 0, 0); ObjectSet("CRPL4", OBJPROP_CORNER, 1); ObjectSet("CRPL4", OBJPROP_XDISTANCE, 90); ObjectSet("CRPL4", OBJPROP_YDISTANCE, 65); ObjectSetText("CRPL4", "4 Candle ", 10, "Arial Bold", NameColor); ObjectCreate("CRP5", OBJ_LABEL, 0, 0, 0); ObjectSet("CRP5", OBJPROP_CORNER, 1); ObjectSet("CRP5", OBJPROP_XDISTANCE, 5); ObjectSet("CRP5", OBJPROP_YDISTANCE, 80); if (Range_Buffers5 > Range_Buffers6) ObjectSetText("CRP5", DoubleToStr(Range_Buffers5,1) + " Pips", 10, "Arial Bold", PlusColor); else if (Range_Buffers5 < Range_Buffers6) ObjectSetText("CRP5", DoubleToStr(Range_Buffers5,1) + " Pips", 10, "Arial Bold", MinusColor); ObjectCreate("CRPL5", OBJ_LABEL, 0, 0, 0); ObjectSet("CRPL5", OBJPROP_CORNER, 1); ObjectSet("CRPL5", OBJPROP_XDISTANCE, 90); ObjectSet("CRPL5", OBJPROP_YDISTANCE, 80); ObjectSetText("CRPL5", "5 Candle ", 10, "Arial Bold", NameColor); } //---- done return(0); } //+------------------------------------------------------------------+