1. text marks in a separate window, positioned on candle (time) positions. 2. colored lines or histograms

 

 

Hi traders, I’m quite new on MT4 forums and couldn’t quickly find answers on my 2 questions below.

 

For study of price patterns I indent to print MT4 chart-pictures, each containing basic info, linked to time-price bar-positions  [ ObjectCreate (objname, OBJ_TEXT,0,time,price) ].
For instance text blocks a few pips below the Low or above the High of the candle, see attachment and the code for this below.

Better is to plot these text marks in a small indicator_separate_window on the correct time (X) positions. Price (Y) is irrelevant then, Y is fixed in height.
Those 2nd chart windows normally are used for double Buffer[ ] indicator values like stochastics.

1.  How to plot text marks ‘00’  ‘01’…’23’ vertically on the correct time positions ?

      Alternative is to plot double buffer values 0  1…23 with spaces in between, or numbers in background color.

 

2. In the same way I could plot several small colored horizontal lines above each other in another separated window to indicate different MA crossing positions.
I saw these lines or bands on this forum, but could not find a mq4 source.

 

I appreciate clues a lot and will upload the tested results and mq4 sources back to this forum.

=====================

MQ4 code for attached screenshot:

=====================


/*
 TODO's:
 Hour indication (text objects) and MA-crossing positions in indicator_separate_window
                        to avoid textobjects fall below  bottom of chart window.
 Marketclose, no LMAX_GMT 21:00-21:05 bar, i.e. CEST 23:00, use 1 minute earlier (HH:59).
 skip sunday part of LMAX via DayOfWeek LMAX-GMT, 2 hours corrected for CEST Amsterdam
                        (see functies timeGMTOffset en TimeGMT en TimeDaylightSavings)
 Separate string and double values in arrays and processing via iteration-loop.
 Calculations via screen resolution specs & chart settings.
 TimeShift summertime: Sun 20150329 2:00H->3:00H (=GMT+2)   Sun 20151025 3:00H->2:00H (=GMT+1).
*/

//+------------------------------------------------------------------+
//|                               #-GMT-CEST-CET TimeMarks.mq4 V1.02 |
//|            cdeleeuw - Netherlands - Copyright © 2015 DaVinci-ICT |
//|        plot time per hour & HH/LL info for each day & quarterday |
//| To use this indicator properly each 6 hour chart must zoom in/out|
//|       to show one day quarter 00-06, 06-12, 12-18, 18-00 exactly |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2015 DaVinci-ICT"
#property link      "www.mail@davinci-ict.com"
//#property indicator_separate_window       // ONLY FOR PLOTTING GRAPHICAL BUFFERS, NOT OBJECTS ?
#property indicator_chart_window

extern color  cFontColor       = Blue;      // WERKT pas na verwijderen, herstart, reïnstall
extern color  cLineColor       = Silver;
extern int    iFontSize        = 10;        // idem
extern string sFontChar        = "Arial";   // idem

extern int    iCorner          = 0;         // 0=top-left,1=top-right,2=bottom-left,3=bottom-right;
extern int    iScreenResolX    = 1600;      // my screen - via systemcall ?
extern int    iScreenResolY    = 900;       // my screen - via systemcall ?
extern int    iScreenOffsetX   = 244;       // calculate from iScreenResolX
extern int    iScreenOffsetY   = 400;       // calculate from iScreenResolX

extern double dBarOffsetY      = 0.00015;   // pipettes, but better calculate via points
extern bool   bPlotBarSize     = false;
extern bool   bPlotMACrossings = true;      // not implemented yet

// TimeShift: Sun 20150329 2:00H->3:00H (=GMT+2)   Sun 20151025 3:00H->2:00H (=GMT+1):
int      iTimeShift, iCest=200, iCet=100;   // time zines, better via MT4 functions
string   sObjName;
int      iCountedBars = 0;
int      iBarsBack    = 0;
int      iWindow      = 0;
int      iBar         = 0;
double   dBarSize;
datetime tTime1, tTime2;
double   dPrice1, dPrice2, dPrice3;
int      i, iH, iM, iHM;                    // indexes, Hour, Minute, HourMinute
string   sSize;
double   dRuler;
int      iObjectCount = 0;
double   dHH00, dHH06, dHH12, dHH18, dHHPrevDay; // Highest & Lowest of previous day & day quarters
double   dLL00, dLL06, dLL12, dLL18, dLLPrevDay;
// -- could be an array
string   GMT00,GMT01,GMT02,GMT03,GMT04,GMT05,GMT06,GMT07,GMT08,GMT09,GMT10,GMT11,
         GMT12,GMT13,GMT14,GMT15,GMT16,GMT17,GMT18,GMT19,GMT20,GMT21,GMT22,GMT23;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
  Alert ("For pipsizes charts must show one quarterday of 6 hours");
//Comment ("For pipsizes charts must show one quarterday of 6 hours");

  dHH00=-999.9; dHH06=-999.9; dHH12=-999.9; dHH18=-999.9; dHHPrevDay=-999.9; // -999.9 for test higher
  dLL00= 999.9; dLL06= 999.9; dLL12= 999.9; dLL18= 999.9; dLLPrevDay= 999.9; //  999.9 for test lower

  GMT00 = "00";  GMT01 = "01";  GMT02 = "02";  GMT03 = "03";  GMT04 = "04";  GMT05 = "05";
  GMT06 = "06";  GMT07 = "07";  GMT08 = "08";  GMT09 = "09";  GMT10 = "10";  GMT11 = "11";
  GMT12 = "12";  GMT13 = "13";  GMT14 = "14";  GMT15 = "15";  GMT16 = "16";  GMT17 = "17";
  GMT18 = "18";  GMT19 = "19";  GMT20 = "20";  GMT21 = "21";  GMT22 = "22";  GMT23 = "23";

  return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
///ObjectsDeleteAll();                           // NO, DELETE USED OBJECTS HERE OBJECTS ONLY !!!
   ObjectsDeleteAll(0,OBJ_VLINE);                // main charts ?
   ObjectsDeleteAll(0,OBJ_TEXT);
   ObjectsDeleteAll(0,OBJ_TREND);
   ObjectsDeleteAll(1,OBJ_VLINE);                // more charts ?
   ObjectsDeleteAll(1,OBJ_TREND);
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
// TICK PROCESSING STARTS HERE:
// (no tick processing)

// BAR PROCESSING STARTS HERE:
   if (!bIsNewBar()) return(0);                     // check if a new bar started
   if (DayOfWeek()==0 || DayOfWeek()==6) return(0); // doesn't work not for CEST propery
   iCountedBars = IndicatorCounted ();              // IndicatorCounted = total of uncounted bars
   iBarsBack    = Bars - iCountedBars;              // Bars = total bars

// ===================================================================
   for(i=iBarsBack; i>=0; i--)                   // zie for-loop in SYM, both Objects and Buffer
   {
       iBar++;                                   // BARCOUNTS USED AS SUFFIX IN OBJECTNAME, BECAUSE LOOPINDEX i BELOW IS NOT UNIQUE !!!
       sObjName   = "GMT"+iBar;                  // LMAX GMT time (add iBar iso. i to sObjectName)
       tTime1     = Time[i];                     // tTime ofwel tXpos, dPrice ofwel dYpos
       tTime2     = Time[i+40];                  // plot dayly pips info to the
       dPrice1    = Low[i] - dBarOffsetY*2;      // BETTER TO RECALCULATE PER dLL<hmm> OF EACH Q<i> iso last bar
       iH         = TimeHour  (Time[i]);         // Hour 12
       iM         = TimeMinute(Time[i]);         // Minute 30
       iTimeShift = iCest;     // iCet           // iCest & iCet should be assigned via date function
       iHM        = iH * 100 + iM + iTimeShift;  // 1230 GMT or timeshift to CET/CEST
       if (iHM >= 2400) iHM -= 2400;             // in case of iTimeShift, every timezone runs from 0:00-23:59

//     ---------------------------------------------------------------
//     -- calculate HH & LL values here via iHM, not in sections below via index i which may be shifted.
//     -- plot hours on lowest part of Q<i> screen via LL

       if (iHM >= 0 && iHM <= 2359)              // whole day, whether GMT or shifted for timezone
       {
         if (High[i] > dHHPrevDay) dHHPrevDay = High[i];
         if (Low[i]  < dLLPrevDay) dLLPrevDay = Low[i];
       }
       if (iHM >= 0 && iHM <= 559)               // Q1 day quarter
       {
         if (High[i] > dHH00) dHH00 = High[i];
         if (Low[i]  < dLL00) dLL00 = Low[i];
       }
       if (iHM >= 600 && iHM <= 1159)            // Q2 day quarter
       {
         if (High[i] > dHH06) dHH06 = High[i];
         if (Low[i]  < dLL06) dLL06 = Low[i];
       }
       if (iHM >= 1200 && iHM <= 1759)           // Q3 day quarter
       {
         if (High[i] > dHH12) dHH12 = High[i];
         if (Low[i]  < dLL12) dLL12 = Low[i];
       }
       if (iHM >= 1800 && iHM <= 2359)           // Q4 day quarter
       {
         if (High[i] > dHH18) dHH18 = High[i];
         if (Low[i]  < dLL18) dLL18 = Low[i];
       }
/*
//     -- or HH LL MinMax calculations above via mathmax & mathmin or in this way:
       if (iHM == 0)                             // start new day, process previous day
       {
//       -- 4 periods of 360 minutes per day: 2359-1800 1759-1200 1159-600 559-0
         dHHPrevDay = iHighest (NULL,0,MODE_HIGH,1440,1);
         dLLPrevDay = iLowest  (NULL,0,MODE_LOW, 1440,1);
         dHH00      = iHighest (NULL,0,MODE_HIGH,360,1);
         dLL00      = iLowest  (NULL,0,MODE_LOW, 360,1);
         dHH06      = iHighest (NULL,0,MODE_HIGH,360,361);
         dLL06      = iLowest  (NULL,0,MODE_LOW, 360,361);
         dHH12      = iHighest (NULL,0,MODE_HIGH,360,721);
         dLL12      = iLowest  (NULL,0,MODE_LOW, 360,721);
         dHH18      = iHighest (NULL,0,MODE_HIGH,360,1081);
         dLL18      = iLowest  (NULL,0,MODE_LOW, 360,1081);
       }
*/

//     -- !!! code below could be an iteration loop
//     -- !!! LL is calculated first, then plot objects on lowest part of each Q<i> screen

//     ---------------------------------------------------------------
       if (iHM == 0)                             // EndOfQ4 & StartOfQ1 for GMT 0:00 or CEST 0:00
       {
        dPrice2 = dHH18 + dBarOffsetY;           // HH per Q<hmm> iso. high last bar

//      -- show full hour GMT time;
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT00, iFontSize, sFontChar, cFontColor);

//      -- plot vertical line:
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);

//      -- show screendimensions in pips of previous dayquarter dHH18-dLL18;
        ObjectCreate  (sObjName+"Q4", OBJ_TEXT, iWindow, tTime1, dPrice2);
        ObjectSetText (sObjName+"Q4", DoubleToString((dHH18-dLL18)*10000,1)+
                       " pips Q4 v                   ", iFontSize, sFontChar, cFontColor);

//      -- show screendimensions in pips of previous full day;
/////   ObjectCreate  (sObjName+"prevday", OBJ_TEXT, iWindow, tTime1, dPrice2+2*dBarOffsetY);  // above
        ObjectCreate  (sObjName+"prevday", OBJ_TEXT, iWindow, tTime2, dPrice2);                // left
        ObjectSetText (sObjName+"prevday", DoubleToString((dHHPrevDay-dLLPrevDay)*10000,1)+
                       " pips DAY", iFontSize, sFontChar, cFontColor);

//      -- draw 10-pips ruler:
        dRuler = dHH18;
////    ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TREND, iWindow, tTime1, dHH18, tTime1, dLL18);
////    ObjectSet     (sObjName+"ruler"+iObjectCount, OBJPROP_RAY, false);        // VLINE already plotted
////    ObjectSet     (sObjName+"ruler"+iObjectCount, OBJPROP_COLOR, Gray);
        while (dRuler <= dHH18 && dRuler >= dLL18)    // only >= dLL18
        {                                  // text "=" or line from iTime1-iTime2 or line over whole quart
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dRuler);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "== ", iFontSize, sFontChar, cFontColor);
          dRuler -= 0.00100;                          // lower with 10 pips until dLLPrevDay
        }
        if (dRuler < dLL18)                           // last step was too far, plot endmarker on LL
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dLL18);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "<-- ", iFontSize, sFontChar, cFontColor);
        }

        dHH18=-999.9;      dLL18=999.9;               // initialize for Q4 of next day
        dHHPrevDay=-999.9; dLLPrevDay=999.9;          // initialize for next day
       }
//     ---------------------------------------------------------------
       if (iHM == 100)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT01, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 200)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT02, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 300)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT03, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 400)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT04, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 500)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT05, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 600)
       {
        dPrice2 = dHH00 + dBarOffsetY;

        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT06, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);

        ObjectCreate  (sObjName+"Q1", OBJ_TEXT, iWindow, tTime1, dPrice2);
        ObjectSetText (sObjName+"Q1", DoubleToString((dHH00-dLL00)*10000,1)+
                       " pips Q1 v                   ", iFontSize, sFontChar, cFontColor);

        dRuler = dHH00;
        while (dRuler <= dHH00 && dRuler >= dLL00)
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dRuler);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "== ", iFontSize, sFontChar, cFontColor);
          dRuler -= 0.00100;                          // lower with 10 pips until dLLPrevDay
        }
        if (dRuler < dLL00)                           // last step was too far, plot endmarker on LL
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dLL00);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "<-- ", iFontSize, sFontChar, cFontColor);
        }

        dHH00=-999.9; dLL00=999.9;
       }
//     ---------------------------------------------------------------
       if (iHM == 700)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT07, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 800)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT08, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 900)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT09, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1000)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT10, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1100)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT11, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1200)
       {
        dPrice2 = dHH06 + dBarOffsetY;

        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT12, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);

        ObjectCreate  (sObjName+"Q2", OBJ_TEXT, iWindow, tTime1, dPrice2);
        ObjectSetText (sObjName+"Q2", DoubleToString((dHH06-dLL06)*10000,1)+
                       " pips Q2 v                   ", iFontSize, sFontChar, cFontColor);

        dRuler = dHH06;
        while (dRuler <= dHH06 && dRuler >= dLL06)
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dRuler);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "== ", iFontSize, sFontChar, cFontColor);
          dRuler -= 0.00100;                          // lower with 10 pips until dLLPrevDay
        }
        if (dRuler < dLL06)                           // last step was too far, plot endmarker on LL
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dLL06);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "<-- ", iFontSize, sFontChar, cFontColor);
        }

        dHH06=-999.9; dLL06=999.9;
       }
//     ---------------------------------------------------------------
       if (iHM == 1300)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT13, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1400)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT14, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1500)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT15, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1600)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT16, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1700)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT17, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 1800)
       {
        dPrice2 = dHH12 + dBarOffsetY;

        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT18, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);

        ObjectCreate  (sObjName+"Q3", OBJ_TEXT, iWindow, tTime1, dPrice2);
        ObjectSetText (sObjName+"Q3", DoubleToString((dHH12-dLL12)*10000,1)+
                       " pips Q3 v                   ", iFontSize, sFontChar, cFontColor);

        dRuler = dHH12;
        while (dRuler <= dHH12 && dRuler >= dLL12)
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dRuler);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "== ", iFontSize, sFontChar, cFontColor);
          dRuler -= 0.00100;                          // lower with 10 pips until dLLPrevDay
        }
        if (dRuler < dLL12)                           // last step was too far, plot endmarker on LL
        {
          iObjectCount +=1;
          ObjectCreate  (sObjName+"ruler"+iObjectCount, OBJ_TEXT, iWindow, tTime1, dLL12);
          ObjectSetText (sObjName+"ruler"+iObjectCount, "<-- ", iFontSize, sFontChar, cFontColor);
        }

        dHH12=-999.9; dLL12=999.9;
       }
//     ---------------------------------------------------------------
       if (iHM == 1900)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT19, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
       if (iHM == 2000)
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT20, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);

       }
//     ---------------------------------------------------------------
       if (iHM == 2100)
////   if (iHM == 2059)   // or 2105, LMAX marketclose at GMT 21:00-21:05 // on LMAX-GMT
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT21, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);

       }
//     ---------------------------------------------------------------
       if (iHM == 2200)
////   if (iHM == 2159)                                                   // on CET
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT22, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------
////   if (iHM == 2300)
       if (iHM == 2259)    // or 2305                                     // on CEST
       {
        ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice1);
        ObjectSetText (sObjName, GMT23, iFontSize, sFontChar, cFontColor);
        ObjectCreate  (sObjName+"VLine", OBJ_VLINE,0, tTime1, 0);
        ObjectSet     (sObjName+"VLine", OBJPROP_COLOR, Gray);
       }
//     ---------------------------------------------------------------

//     -- plot MA crossings:
       if (bPlotMACrossings == true)
       {
      
       }
//     ---------------------------------------------------------------

//      -- plot BarSize O-C above High;     // CRASHES WHEN TOO MANY HISTORY BARS, PLOT ONLY LAST DAYS
        if (bPlotBarSize == true)            // && last 10000 bars and delete older sObjName's
        {
            sObjName = "Size"+i;
            dPrice3  = High[i] + dBarOffsetY;
            dBarSize = (Close[i]-Open[i])*10000;
            sSize    = DoubleToString (dBarSize,1);
            ObjectCreate  (sObjName, OBJ_TEXT, iWindow, tTime1, dPrice3);
            ObjectSetText (sObjName, sSize, iFontSize-4, sFontChar, cFontColor);
        }
 
   }
// ===================================================================

// RefreshRates();                          // necessary ???
// WindowRedraw ();                         // necessary ???

   return(0);
}
//+------------------------------------------------------------------+


bool bIsNewBar()
{
// -- Check whether tick started a new bar on current timeframe:
   static int prevTime;
   bool newBar = false;
   if(Time[0] != prevTime)
   {
      newBar   = true;
      prevTime = Time[0];
   }
   return(newBar);
}

//+------------------------------------------------------------------+

 

As variables have not been given names that make it obvious what they represent, the code is extremely difficult to follow, probably even for the person that wrote the code.

Change the variable names to something that makes the code easier to follow and maybe someone will help you. 

 

cdeleeuw:

For study of price patterns I indent to print MT4 chart-pictures,

For instance text blocks a few pips below the Low or above the High of the candle, see attachment and the code for this below.

Better is to plot these text marks in a small indicator_separate_window on the correct time (X) positions. Price (Y) is irrelevant then, Y is fixed in height.

MQ4 code for attached screenshot:

  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You indent? Perhaps you intend.
  3. Don't attach a image, insert the image
  4. Price is not irrelevant. You fixed it's minimum and maximum (Program Properties (#property) - MQL4 Documentation) thus it still has a low and high.
  5.  sObjName   = "GMT"+iBar;                  // LMAX GMT time (add iBar iso. i to sObjectName)
    First run you are going to create an object named GMT0. When the next bar starts you are again going to try to create GMT0 (which is now under bar one) and that will fail. Don't use bar numbers in object names; use time "GMT"+int(Time[iBar]) or similiar.
 

Thanks;

@Gumrai; next MQ4 code will be well documented. This one was a previous version, maybe attached too early.

@WHRoeder; both 5 remarks usefull, 5th doesn't work properly on pip-count part, but I know where to debug by now.

@ALL; hope to receive clues for my questions about indicator_separate_window too  <<===.

I'll post the code after testing.

 
Reason: