I have this indicator showing high/low for the day, but the text above saying "Daily high" & "Daily low" is jumping around on the chart when i change time frame and also when i zoom in and out.
How can i have it the exact the same distance from the right side and also from the price whenever i zoom or change tf?
How can i have it the exact the same distance from the right side and also from the price whenever i zoom or change tf?
Inserted Code
//+------------------------------------------------------------------+ //| #Highs-Lows.mq4 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window string label2="Daily High"; string label3="Daily Low"; double DHigh,DLow,WHigh,WLow,MHigh,MLow; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping DHigh = iHigh(NULL,PERIOD_D1,0); DLow = iLow(NULL,PERIOD_D1,0); WHigh = iHigh(NULL,PERIOD_W1,0); WLow = iLow(NULL,PERIOD_W1,0); MHigh = iHigh(NULL,PERIOD_MN1,0); MLow = iLow(NULL,PERIOD_MN1,0); Trend_Line("DHigh_TrendLine", Time[0]+0*PeriodSeconds(),Time[0]+1*PeriodSeconds(),DHigh,DHigh,Gold,STYLE_SOLID); Trend_Line("DLow_TrendLine", Time[0]+0*PeriodSeconds(),Time[0]+1*PeriodSeconds(),DLow,DLow,Gold,STYLE_SOLID); //Write_Text("DailyHigh"); //Write_Text("DailyLow"); ObjectCreate("Daily High", OBJ_TEXT, 0, TimeCurrent()+20*PeriodSeconds(), DHigh+450*Point); ObjectSetText("Daily High",label2, 8, "Open Sans", clrBlack); ObjectCreate("Daily Low", OBJ_TEXT, 0, TimeCurrent()+20*PeriodSeconds(), DLow+450*Point); ObjectSetText("Daily Low",label3, 8, "Open Sans", clrBlack); //--- return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { ObjectDelete(0,"DHigh_TrendLine"); ObjectDelete(0,"Daily High"); ObjectDelete(0,"DLow_TrendLine"); ObjectDelete(0,"Daily Low"); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ void Trend_Line( string label, datetime x1, datetime x2, double y1, double y2, color lineColor, double style){ ObjectDelete(label); ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0); ObjectSet(label, OBJPROP_RAY, 1); ObjectSet(label, OBJPROP_COLOR, lineColor); ObjectSet(label, OBJPROP_STYLE, style); } //void Write_Text( // string label2){ // ObjectDelete(label2); // ObjectCreate(label2, OBJ_TEXT, 0, TimeCurrent(), DHigh); // ObjectSetText(label2, OBJ_TEXT, 8, "Open Sans", clrBlack); //}
Blindly following others will make you blind!