well it displayed some lines,but isn't there a way to draw lines only on recent candle whose hour is defined, there are way too many lines
so initially i placed everything i can make sense of , but now i have removed the unwanted code and it looks a lot better now.
//+------------------------------------------------------------------+//| HLine indicator.mq4 |//+------------------------------------------------------------------+#property indicator_chart_windowexternint HOUR = 4; //Hour to draw the linesexternint MINUTE = 0; //Minute to draw the linesexternstring LineName="MyLineL";
externstring LineName1="MyLineH";
externcolor Line_Color = clrYellow; //Color of the linesinputENUM_LINE_STYLE Line_Style = STYLE_SOLID; //Style of the linesstring name = "TimeLine";
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicators//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----ObjectsDeleteAll(0,name);
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+void start()
{
int Counted_bars=IndicatorCounted();
int i=Bars-Counted_bars-1;
while(i>=0)
{
if(TimeHour(Time[i]) == HOUR && TimeMinute(Time[i]) == MINUTE)
{
if (ObjectFind(name+DoubleToStr(Time[i])) != 0)
{
ObjectCreate(name+DoubleToStr(Time[i]), OBJ_HLINE, 0, 0, Low[i]);
ObjectCreate(LineName1, OBJ_HLINE, 0, 0, High[i]);
}
}
i--;
}
}
//+------------------------------------------------------------------+
but i can not figure out a way to make it so that it draw the lines only at the most recent 4:00 candle and not all the 4:00 candle . the current indicator is drawing the lines on all the 4:00 candles on the chart
lippmaje: When you draw a new line, remove the old one with ObjDelete.
can you take a look at the code and tell me if thats where the objdelete is supposed to be ? i have highlighted it because when i run the code it only display one line (neither high nor low it is places like this )
//+------------------------------------------------------------------+//| HLine indicator.mq4 |//+------------------------------------------------------------------+#property indicator_chart_windowexternint HOUR = 4; //Hour to draw the linesexternint MINUTE = 0; //Minute to draw the linesexternstring LineName="MyLineL";
externstring LineName1="MyLineH";
externcolor Line_Color = clrYellow; //Color of the linesinputENUM_LINE_STYLE Line_Style = STYLE_SOLID; //Style of the linesstring name = "TimeLine";
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicators//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----ObjectsDeleteAll(0,name);
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+void start()
{
int Counted_bars=IndicatorCounted();
int i=Bars-Counted_bars-1;
while(i>=0)
{
if(TimeHour(Time[i]) == HOUR && TimeMinute(Time[i]) == MINUTE)
{
if (ObjectFind(name+DoubleToStr(Time[i])) != 0)
{
ObjectsDeleteAll(0,name);ObjectCreate(name+DoubleToStr(Time[i]), OBJ_HLINE, 0, 0, Low[i]);
ObjectCreate(LineName1, OBJ_HLINE, 0, 0, High[i]);
}
}
i--;
}
}
//+------------------------------------------------------------------+
15732
although there is no error in the code but the indicator is not drawing any horizontal lines
You return after the first execution of the while loop
} return(0); } }
you can remove the return altogether
or move it
} } return; }
Somewhere at the end of the while loop body you need to add an
or else your loop runs forever.You return after the first execution of the while loop
you can remove the return altogether
or move it
yup did that already still no luck, there isn't any error or warning but its still not drawing any horizontal lines
Somewhere at the end of the while loop body you need to add an
or else your loop runs forever.yeah thats exactly what happened , when ever i try to attach the indicator to the chart, mt4 terminal stops responding.
after adding i--; , mt4 is not crashing anymore
as for the indicator, its still not showing any horizontal lines
15732
Replace
with
You will get a lot of horizontal lines though.
You may also wish to put
In OnDeinit so that you are not left with all the lines when you remove the indicator.
Replace
with
You will get a lot of horizontal lines though.
You may also wish to put
In OnDeinit so that you are not left with all the lines when you remove the indicator.
well it displayed some lines,but isn't there a way to draw lines only on recent candle whose hour is defined, there are way too many lines
well it displayed some lines,but isn't there a way to draw lines only on recent candle whose hour is defined, there are way too many lines
so initially i placed everything i can make sense of , but now i have removed the unwanted code and it looks a lot better now.
but i can not figure out a way to make it so that it draw the lines only at the most recent 4:00 candle and not all the 4:00 candle . the current indicator is drawing the lines on all the 4:00 candles on the chart
When you draw a new line, remove the old one with ObjDelete.
can you take a look at the code and tell me if thats where the objdelete is supposed to be ? i have highlighted it
because when i run the code it only display one line (neither high nor low it is places like this )