[Help Please] - Inserting Horizontal Line with Fix Range of 50pips from support/resistance New comment Mohamad Zulhairi Baba 2010.05.16 19:54 Hi fellow Brothers, Recently, i've design an indicator for support / resistance line using zigzag methods. Now, i want to add some features as possible target line for GBPUSD range within support/resistance line as per below picture. attached is my code. hope anyone can help me on this. #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 White #property indicator_color2 White #property indicator_width1 2 #property indicator_width2 2 extern bool GU_TargetLine = true; int GU_Range = 50; int Sub_GU_Range = 25; int GU_MaxRange = 550; int Risk = 5; int Candles = 240; double SwingHigh[]; double SwingLow[]; int CurrentBar[]; double CandleSwingHigh, CandleSwingLow; double Shift; int init() { SetIndexStyle(0, DRAW_ARROW); SetIndexArrow(0, 159); SetIndexBuffer(0, SwingHigh); SetIndexEmptyValue(0, 0.0); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, 159); SetIndexBuffer(1, SwingLow); SetIndexEmptyValue(1, 0.0); if (Period() > Candles) { Alert("New Support/Resistance Alert ", Candles); return (0); } ArrayCopySeries(CurrentBar, 5, Symbol(), Candles); return (0); } int deinit() { int obj_total= ObjectsTotal(); for (int i= obj_total; i>=0; i--) { string name= ObjectName(i); if (StringSubstr(name,0,11)=="[GU Level]") ObjectDelete(name); } return(0); } int start() { int ZigZagBarCount; double ZigZagBarCustoms; double FinalTargetUp, FinalTargetDown; double MeasureStart=0.0; double StartSupport=0.0; double StartResistance=0.0; double PlotSupport=0.0; double PlotResistance=0.0; if (Year() >= 2007 && Month() >= 12 && Day() >= 12) return (0); int BarCheck = IndicatorCounted(); int TotalBar = 300; if (BarCheck < 0) return (-1); if (BarCheck > 0) BarCheck--; TotalBar = Bars - BarCheck; for (int BarMeasure = 0; BarMeasure < TotalBar; BarMeasure++) { int BarSignal=BarMeasure+1; int BarSignalPrev=BarMeasure+2; int BarMeasureFwd=BarMeasure-1; if (Time[BarMeasure] >= CurrentBar[0]) ZigZagBarCount = 0; else { ZigZagBarCount = ArrayBsearch(CurrentBar, Time[BarMeasureFwd], WHOLE_ARRAY, 0, MODE_DESCEND); if (Period() <= Candles) ZigZagBarCount++; } for (int ZigZagBar = ZigZagBarCount; ZigZagBar < ZigZagBarCount + 100; ZigZagBar++) { ZigZagBarCustoms = iCustom(NULL, Candles, "ZigZag", Risk, 5, 3, 0, ZigZagBar + 1); if (ZigZagBarCustoms != 0.0) break; } if (iClose(NULL, 0, BarSignal) <= ZigZagBarCustoms) SwingLow[BarMeasure] = ZigZagBarCustoms; else SwingLow[BarMeasure] = 0.0; if (iClose(NULL, 0, BarSignal) >= ZigZagBarCustoms) SwingHigh[BarMeasure] = ZigZagBarCustoms; else SwingHigh[BarMeasure] = 0.0; ObjectsRedraw(); } //+------------------------------------------------------------------+ //| GBPUSD TARGET LINE START | //+------------------------------------------------------------------+ if (GU_TargetLine==true) { Shift=iBarShift(NULL, 0,Time[BarMeasure]); CandleSwingHigh = iHigh(NULL,0,Shift); CandleSwingLow = iLow(NULL,0,Shift); FinalTargetDown = CandleSwingHigh - (GU_MaxRange*Point); FinalTargetUp = CandleSwingLow + (GU_MaxRange*Point); // ------- This coding here need modification to plot price range of Max_GU Range ( 550 ) with increment of GU_Range ( 50 ) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (ZigZagBarCustoms && SwingLow[BarMeasure] != 0.0) { for (int a1=0; a1<=11; a1++) { StartSupport = StartSupport + (a1*GU_Range); PlotSupport = CandleSwingLow + StartSupport*Point; SetLevel(DoubleToStr(PlotSupport,Digits), PlotSupport); } } else if (ZigZagBarCustoms && SwingHigh[BarMeasure] != 0.0) { for (int a2=0; a2<=11; a2++) { StartResistance = StartResistance + (a2*GU_Range); PlotResistance = CandleSwingHigh - StartResistance*Point; SetLevel(DoubleToStr(PlotResistance,Digits), PlotResistance); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------- This coding here need modification to plot price range of Max_GU Range ( 550 ) with increment of GU_Range ( 50 ) } //+------------------------------------------------------------------+ //| GBPUSD TARGET LINE END | //+------------------------------------------------------------------+ return (0); } //+------------------------------------------------------------------+ //| TARGET LINE DRAW | //+------------------------------------------------------------------+ void SetLevel(string text, double level) { int digits= Digits; string linename= "[GU Range] " + text + " Line", pricelabel; if(ObjectFind("GU Level") != 0) { ObjectCreate("GU Level", OBJ_HLINE, 0, Time[0],level); ObjectSet("GU Level", OBJPROP_STYLE, STYLE_DASHDOTDOT); ObjectSet("GU Level", OBJPROP_COLOR,SpringGreen ); } else { ObjectMove("GU Level",0, Time[0],level ); } } ting Please Help... Support and Resistance indicator Trend indicators Help with a support/resistance indicator New comment
Hi fellow Brothers,
Recently, i've design an indicator for support / resistance line using zigzag methods.
Now, i want to add some features as possible target line for GBPUSD range within support/resistance line as per below picture.
attached is my code. hope anyone can help me on this.