Help with learning MQl4 / label spacing ?

 

Hi everyone .  I am learning MQL4 very beginner level .

I had a code that did the following output  on the chart window( first pic) .

picture 1


 Learning from here and there I changed it so that the output is displayed on separate window and everything is horizontal instead of vertical as shown in the second picture . Only thing I cannot figure out is how to make the gaps between the symbols same in 2nd picture for all the timeframes. The gaps are different for different rows !

picture 2

1.Part of the code that creates timeframes and timer heading . Which I understand and changed correctly to appear as picture 2 .


........

void createdashboardheader()
  {
         
   int w = 2*FontSize;
   int x = 10;
   int y = 3*FontSize;
   
   
   for(int i = 0; i<ArraySize(timeframes); i++)
     {
      string objn = "lbl_title"+EnumToString(timeframes[i]);
      ObjectDelete(objn);
      ObjectCreate(ChartID(),objn,OBJ_LABEL,1,0,0);
      ObjectSetInteger(ChartID(),objn,OBJPROP_FONTSIZE,FontSize);
      ObjectSetInteger(ChartID(),objn,OBJPROP_COLOR,HeadColumnColor);
      ObjectSetString(ChartID(),objn,OBJPROP_TEXT,StringSubstr(EnumToString(timeframes[i]),7));
      ObjectSetInteger(ChartID(),objn,OBJPROP_XDISTANCE,x);
      ObjectSetInteger(ChartID(),objn,OBJPROP_YDISTANCE,y);
      ObjectSetInteger(ChartID(),objn,OBJPROP_XSIZE,w);

      if(ShowTimer && timeframes[i] < PERIOD_W1)
        {
         objn += "tcnt";
         ObjectDelete(objn);
         ObjectCreate(ChartID(),objn,OBJ_LABEL,1,0,0);
         string tcnt = "";
         tcnt = TimeToString(PeriodSeconds(timeframes[i])-(TimeCurrent() - iTime(Symbol(),timeframes[i],0)),TIME_SECONDS);
         ObjectSetInteger(ChartID(),objn,OBJPROP_FONTSIZE,FontSize-2);
         ObjectSetInteger(ChartID(),objn,OBJPROP_COLOR,TimerColor);
         ObjectSetString(ChartID(),objn,OBJPROP_TEXT,tcnt);
         ObjectSetInteger(ChartID(),objn,OBJPROP_XDISTANCE,x+FontSize*2);
         ObjectSetInteger(ChartID(),objn,OBJPROP_YDISTANCE,y);
         ObjectSetInteger(ChartID(),objn,OBJPROP_XSIZE,w);
        }


     y+=w;

     }
  }

............

 2 Part of the main code , which I understand and works fine

.................

 if(prev_calculated >= rates_total)
      return rates_total;


   int tfs = ArraySize(timeframes);
   int stochs = ArraySize(Symbname);

   ObjectsDeleteAll(0,"lbl_Period_");
   for(int j = 0; j<tfs; j++)
     {
      int ii = 0;
      int find = false;
      for(int i = 0; i< stochs; i++)
        {
         int shift = 1;
         
           {
            
            double mv90 = iMA(Symbname[i],timeframes[j],MA100,0,method100,price100,shift);
            double sv90 = iMA(Symbname[i],timeframes[j],MA200,0,method200,price200,shift);


            double mv91 = iMA(Symbname[i],timeframes[j],MA100,0,method100,price100,shift+1);
            double sv91 = iMA(Symbname[i],timeframes[j],MA200,0,method200,price200,shift+1);

                    
            
               if(sv91 >= mv91 && sv90 < mv90)
                 {
                  setstochlabel(i,j,shift,ii);
                  find = true;
                  ii++;
                 }
               if(sv91 <= mv91 && sv90 > mv90)
                 {
                  shift = -shift;
                  setstochlabel(i,j,shift,ii);
                  find = true;
                  ii++;
                 }
              
              
           }
        }
     }

   return rates_total;
  }


void setstochlabel(int i, int j, int shift,int ii)
  {

   int h = 5.5*FontSize + j*1.2*FontSize;
   int y   ;
   int x = 70 + ii*h; 
   
   y+=h;
   
   string objn = "lbl_Period_"+IntegerToString(i)+"_"+IntegerToString(j);
   ObjectDelete(objn);
   ObjectCreate(ChartID(),objn,OBJ_LABEL,1,0,0);
   
...........................
3. part of the code  from above which I dont understand and needs changing for the gaps between symbols/ label in picture 2 to be equal. I know I just need to change these lines below somehow. But I don't know change what or how ?
input int      FontSize=9; 
..........
..........

int h = 5.5*FontSize + j*1.2*FontSize;
   int y   ;
   int x = 70 + ii*h; 
   
   y+=h;
   
............
Can someone please tell me how/what do i need to change in the above lines so that gaps between symbols/label in picture 2 are unifrom . Thank you so much . Sorry of rthe long post.
 
Start by using a mono-spaced font.
 
William Roeder #:
Start by using a mono-spaced font.

Thank you for your reply . How do i do that ?

 
Clearly each next row has a multiplication going on. I'd look for that.
 
deral5 #: How do i do that ?

Perhaps you should read the manual. MQL5 ReferenceObject FunctionsObjectSetStringOBJPROP_FONT
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

Try "Courier New"
 
Krzysztof Jan Debski #:
Clearly each next row has a multiplication going on. I'd look for that.

 Thank you for the input .I definitely think that is the culprit . But when I change the multiplication to addition as below it produces everything one on top of another like the picture below

int h = 5.5*FontSize + j*1.2*FontSize;
   int y   ;
  
   int x = 70 + ii+h; 
  
   
   y+=h;


 
William Roeder #:

Perhaps you should read the manual. MQL5 ReferenceObject FunctionsObjectSetStringOBJPROP_FONT
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

Try "Courier New"
Changed the font  as you suggested
ObjectSetString(ChartID(),objn,OBJPROP_FONT,"Courier New");

The result is same only the font changes the initial problem is not sorted.


Reason: