Drawing HLine of specific candle
Yellowbeard1881:
Does anyone know how to draw a horizonal line from the open of a specific candle to the end of the day. For example, the open of the 2:00 am hourly candle. I know how to draw a line from the start of each day to the end. Just having difficulty figuring out how to start at a specific hour.
Thanks!
start_time=iTime(_Symbol, PERIOD_D1, 0)+2*3600; int bar_index=iBarShift(_Symbol, PERIOD_H1, start_time, false); double open=iOpen(_Symbol, PERIOD_H1, bar_index);
That's the second hour in todays date and you didn't handle 4066 errors.
Yellowbeard1881: Does anyone know how to draw a horizonal line from the open of a specific candle to the end of the day.
You have the start time (the candle). Compute tomorrow's time. Draw a trendline between.Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)
I'm trying to draw a line, each day, from the open of the 2:00 am candle till the end of day. The platform that I have starts the day at 5:00 pm EST. No matter what I try, I can only get the line to start at 5:00 pm. Not 2:00 am. I've attached the code. Perhaps someone could show me what I'm doing wrong or what I'm missing? Thanks!
//+------------------------------------------------------------------+ //| 2:00AM Open.mq4 | //| | //| | //+------------------------------------------------------------------+ #property indicator_chart_window extern int Hour_Num = 1; extern int Minute_Num = 0; int o = -9; // Draws line starting at current day //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- int ObjectCount = ObjectsTotal(); for (int i=ObjectCount-1; i>=0; i--) { if(StringFind(ObjectName(i),"Op_Line") != -1) { ObjectDelete(ObjectName(i)); } //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { datetime BeginTime, EndTime; int Counted_bars=IndicatorCounted(); int i=Bars-Counted_bars-1; while(i>=0) { if(TimeHour(Time[i]) == Hour_Num && TimeMinute(Time[i]) == Minute_Num) { o=o+1; double vO=iOpen(NULL, PERIOD_D1,o); // iOpen(NULL, PERIOD_H1,o); if(i > 0) { BeginTime = iTime(NULL, PERIOD_D1, o); // iTime( NULL, PERIOD_D1, o ); EndTime = (BeginTime + 86400); } ObjectDelete("Op_Line"+o); ObjectCreate("Op_Line"+o, OBJ_TREND, 0, BeginTime, vO, EndTime, vO ); ObjectSet("Op_Line"+o, OBJPROP_COLOR, Blue); ObjectSet("Op_Line"+o, OBJPROP_STYLE, STYLE_DASH); ObjectSet("Op_Line"+o, OBJPROP_WIDTH, 1); ObjectSet("Op_Line"+o, OBJPROP_RAY, False); } i--; ObjectSet("Op_Line"+o,OBJ_TREND,EndTime); ChartRedraw(ChartID()); } //---- return(0); } //+------------------------------------------------------------------+
Does anyone know how to draw a horizonal line from the open of a specific candle to the end of the day. For example, the open of the 2:00 am hourly candle. I know how to draw a line from the start of each day to the end. Just having difficulty figuring out how to start at a specific hour.
Thanks!
Topic has been moved to the section: MQL4 e MetaTrader 4 — In the future, please consider which section is most appropriate for your query.