Hello guys,
I have tried to put this indicator together, but it does not work correctly
It should draw a line for each candle that e.g. have a low inside the gap on the big candle, but it only show one line like in the chart pic below
I get an error code 4200 in the terminal window which normally means there's already another object with the same name, so there's something in the code that keeps stopping the indicator from draw more lines, i just can't see the bug after 8 hours lol
This is what i have so far
Can anyone see what wrong in the code?
I have tried to put this indicator together, but it does not work correctly
It should draw a line for each candle that e.g. have a low inside the gap on the big candle, but it only show one line like in the chart pic below
I get an error code 4200 in the terminal window which normally means there's already another object with the same name, so there's something in the code that keeps stopping the indicator from draw more lines, i just can't see the bug after 8 hours lol
This is what i have so far
Inserted Code
#property indicator_chart_window extern int BarsBack = 1000; input string InpNameUp="GapUp"; // Line name input string InpNameDown="GapDown"; // Line name input color InpColor=clrRed; // Line color input color InpColor1=clrBlue; // Line color input ENUM_LINE_STYLE InpStyle=STYLE_SOLID; // Line style input int InpWidth=1; // Line width input bool InpBack=false; // Background line input bool InpSelection=false; // Highlight to move input bool InpRayRight=false; // Line's continuation to the right input bool InpHidden=false; // Hidden in the object list input long InpZOrder=0; // Priority for mouse click double Poin; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { Poin = Point; //Checking for unconvetional Point digits number if ((Point == 0.00001) || (Point == 0.001)) Poin *= 10; return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { for (int i = 0; i < Bars; i++) { ObjectDelete("TrendlineUp" + i); ObjectDelete("TrendlineDown" + i); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); if (counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if (limit > BarsBack) limit = BarsBack; //Comment(BarsBack); for (int i = 0; i <= limit; i++) { //GapDown if(High[i+1] < Low[i+3]) { int j=4; while(Low[i+4] < Low[i+3] && Low[i+4] > High[i+1]) { if(!GapDownCreate(i+j, 0,InpNameUp,0,Time[i+j],Low[i+j],Time[0],Low[i+j],InpColor,InpStyle,InpWidth,InpBack,InpSelection,InpRayRight,InpHidden,InpZOrder)) { return(0); } j = j++; } } //TimeCurrent() + 10 * 365 * 24 * 60 * 60, HighCandle_1, i, clrRed); //GapUp if(Low[i+1] > High[i+3]) { int k=4; while(High[i+4] > High[i+3] && High[i+4] < Low[i+1]) { if(!GapUpCreate(i+k, 0,InpNameDown,0,Time[i+k],Low[i+k],Time[0],Low[i+k],InpColor1,InpStyle,InpWidth,InpBack,InpSelection,InpRayRight,InpHidden,InpZOrder)) { return(0); } k = k++; } } //TimeCurrent() + 10 * 365 * 24 * 60 * 60, HighCandle_1, i, clrRed); } return (0); } //+------------------------------------------------------------------+ //| Create a line by the given coordinates | //+------------------------------------------------------------------+ bool GapUpCreate(const int j, const long chart_ID=0, // chart's ID const string name="GapUp", // line name const int sub_window=0, // subwindow index datetime time1=0, // first point time double price1=0, // first point price datetime time2=0, // second point time double price2=0, // second point price const color clr=clrBlue, // line color const ENUM_LINE_STYLE style=STYLE_SOLID, // line style const int width=1, // line width const bool back=false, // in the background const bool selection=false, // highlight to move const bool ray_right=false, // line's continuation to the right const bool hidden=false, // hidden in the object list const long z_order=0) // priority for mouse click { ResetLastError(); if(!ObjectCreate(chart_ID,name+j,OBJ_TREND,sub_window,time1,price1,time2,price2)) { Print(__FUNCTION__, ": failed to create a trend line! Error code = ",GetLastError()); return(false); } ObjectSetInteger(chart_ID,name+j,OBJPROP_COLOR,clr); ObjectSetInteger(chart_ID,name+j,OBJPROP_STYLE,style); ObjectSetInteger(chart_ID,name+j,OBJPROP_WIDTH,width); ObjectSetInteger(chart_ID,name+j,OBJPROP_BACK,back); ObjectSetInteger(chart_ID,name+j,OBJPROP_SELECTABLE,selection); ObjectSetInteger(chart_ID,name+j,OBJPROP_SELECTED,selection); ObjectSetInteger(chart_ID,name+j,OBJPROP_RAY_RIGHT,ray_right); ObjectSetInteger(chart_ID,name+j,OBJPROP_HIDDEN,hidden); ObjectSetInteger(chart_ID,name+j,OBJPROP_ZORDER,z_order); return(true); } //+------------------------------------------------------------------+ //| Create another line by the given coordinates | //+------------------------------------------------------------------+ bool GapDownCreate(const int k, const long chart_ID=0, // chart's ID const string name="GapDown", // line name const int sub_window=0, // subwindow index datetime time1=0, // first point time double price1=0, // first point price datetime time2=0, // second point time double price2=0, // second point price const color clr=clrRed, // line color const ENUM_LINE_STYLE style=STYLE_SOLID, // line style const int width=1, // line width const bool back=false, // in the background const bool selection=false, // highlight to move const bool ray_right=false, // line's continuation to the right const bool hidden=false, // hidden in the object list const long z_order=0) // priority for mouse click { ResetLastError(); if(!ObjectCreate(chart_ID,name+k,OBJ_TREND,sub_window,time1,price1,time2,price2)) { Print(__FUNCTION__, ": failed to create a trend line! Error code = ",GetLastError()); return(false); } ObjectSetInteger(chart_ID,name+k,OBJPROP_COLOR,clr); ObjectSetInteger(chart_ID,name+k,OBJPROP_STYLE,style); ObjectSetInteger(chart_ID,name+k,OBJPROP_WIDTH,width); ObjectSetInteger(chart_ID,name+k,OBJPROP_BACK,back); ObjectSetInteger(chart_ID,name+k,OBJPROP_SELECTABLE,selection); ObjectSetInteger(chart_ID,name+k,OBJPROP_SELECTED,selection); ObjectSetInteger(chart_ID,name+k,OBJPROP_RAY_RIGHT,ray_right); ObjectSetInteger(chart_ID,name+k,OBJPROP_HIDDEN,hidden); ObjectSetInteger(chart_ID,name+k,OBJPROP_ZORDER,z_order); return(true); }
Can anyone see what wrong in the code?
Blindly following others will make you blind!