Right-justify label at Time[0]

 

Hello, in the working source code below, on lines 74 we see:

 

   ObjectCreate("H4_SMA", OBJ_LABEL, 0, Time[1], H4_SMA);
   ObjectSetText("H4_SMA","H4 SMA",14,"Tahoma",Gold);

 

I would like to modify these lines such that the label is right-justified and all the way to the right on the chart at Time[1] or so. Right now, for some reason, the label appears left of center in the chart. Complete source code follows:

 

 

// Three Ducks

// A technique developed by Captain Currency
// Discussion thread
// http://www.trade2win.com/boards/forex/123288-3-ducks-trading-system-413.html

// Author
// Terrence Brannon - http://IwantYoutoProsper.com

#property copyright ""
#property link      ""

extern int magic_number=66178;

string TradeCode="THREE_DUCKS_1.0";
double H4_SMA,H1_SMA,M5_SMA;
string H4_direction;
bool H1_confirms_H4;
double high;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() 
  {

   ObjectsDeleteAll();

   H1_confirms_H4=false;
   calculate_moving_averages();
   determine_and_confirm_direction();
   Print("H4 direction",H4_direction);
   Print("H1 confirms",H1_confirms_H4);

   return(0);

  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+-------------------------General Functions------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

int calculate_moving_averages() 
  {

   int averaging_period=60;
   int ma_shift=0;
   int shift= 0;
   int mode = MODE_SMA;
   int applied_price=PRICE_CLOSE;

   H4_SMA = iMA(Symbol(), PERIOD_H4, averaging_period, ma_shift, mode, applied_price, shift);
   H1_SMA = iMA(Symbol(), PERIOD_H1, averaging_period, ma_shift, mode, applied_price, shift);
   M5_SMA = iMA(Symbol(), PERIOD_M5, averaging_period, ma_shift, mode, applied_price, shift);

   ObjectCreate("H4_SMA", OBJ_LABEL, 0, Time[1], H4_SMA);
   ObjectSetText("H4_SMA","H4 SMA",14,"Tahoma",Gold);
   
      ObjectCreate("H1_SMA", OBJ_LABEL, 0, Time[1], H1_SMA);
   ObjectSetText("H1_SMA","H1 SMA",14,"Tahoma",Blue);

                return(0);

                }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int determine_and_confirm_direction() 
  {

   if(H4_SMA>Bid) 
     {
      H4_direction="sell";
      if(H1_SMA>Bid) 
        {
         H1_confirms_H4=true;
         draw_low();
        }
     }

   if(H4_SMA<Bid) 
     {
      H4_direction="buy";
      if(H1_SMA<Bid) 
        {
         H1_confirms_H4=true;
         draw_high();
        }
     }

   if(H4_SMA==Bid)
      H4_direction="neither";

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int draw_high() 
  {

   for(int i=3; i<999;++i) 
     {
      double bar_max=MathMax(Open[i],Close[i]);
      if(bar_max>M5_SMA) 
        {
         high=bar_max;
         int window_number=0;
         ObjectCreate("high_line",OBJ_HLINE,window_number,Time[i],high);
         break;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int draw_low() 
  {

   for(int i=3; i<999;++i) 
     {
      double bar_max=MathMin(Open[i],Close[i]);
      if(bar_max<M5_SMA) 
        {
         Print("The bar index that is below the SMA =", i);
         high=bar_max;
         int window_number=0;
         ObjectCreate("high_line",OBJ_HLINE,window_number,Time[i],high);
         break;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
 
princepawn:

Hello, in the working source code below, on lines 74 we see:

 

 

I would like to modify these lines such that the label is right-justified and all the way to the right on the chart at Time[1] or so. Right now, for some reason, the label appears left of center in the chart. Complete source code follows:

 

 


Hello. I added an an input parameter  Shifr_text so as to move the label:


// Three Ducks

// A technique developed by Captain Currency
// Discussion thread
// http://www.trade2win.com/boards/forex/123288-3-ducks-trading-system-413.html

// Author
// Terrence Brannon - http://IwantYoutoProsper.com

#property copyright ""
#property link      ""

extern int magic_number=66178;
extern int Shifr_text=3;
string TradeCode="THREE_DUCKS_1.0";
double H4_SMA,H1_SMA,M5_SMA;
string H4_direction;
bool H1_confirms_H4;
double high;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() 
  {

   ObjectsDeleteAll();

   H1_confirms_H4=false;
   calculate_moving_averages();
   determine_and_confirm_direction();
   Print("H4 direction",H4_direction);
   Print("H1 confirms",H1_confirms_H4);

   return(0);

  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+-------------------------General Functions------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

int calculate_moving_averages() 
  {

   int averaging_period=60;
   int ma_shift=0;
   int shift= 0;
   int mode = MODE_SMA;
   int applied_price=PRICE_CLOSE;
   int period=60*Shifr_text*Period();

   H4_SMA = iMA(Symbol(), PERIOD_H4, averaging_period, ma_shift, mode, applied_price, shift);
   H1_SMA = iMA(Symbol(), PERIOD_H1, averaging_period, ma_shift, mode, applied_price, shift);
   M5_SMA = iMA(Symbol(), PERIOD_M5, averaging_period, ma_shift, mode, applied_price, shift);

   ObjectCreate("H4_SMA", OBJ_TEXT, 0, Time[0]+period, H4_SMA);
   ObjectSetText("H4_SMA","H4 SMA",14,"Tahoma",Gold);
   
      ObjectCreate("H1_SMA", OBJ_TEXT, 0, Time[0]+period, H1_SMA);
   ObjectSetText("H1_SMA","H1 SMA",14,"Tahoma",Blue);

                return(0);

                }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int determine_and_confirm_direction() 
  {

   if(H4_SMA>Bid) 
     {
      H4_direction="sell";
      if(H1_SMA>Bid) 
        {
         H1_confirms_H4=true;
         draw_low();
        }
     }

   if(H4_SMA<Bid) 
     {
      H4_direction="buy";
      if(H1_SMA<Bid) 
        {
         H1_confirms_H4=true;
         draw_high();
        }
     }

   if(H4_SMA==Bid)
      H4_direction="neither";

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int draw_high() 
  {

   for(int i=3; i<999;++i) 
     {
      double bar_max=MathMax(Open[i],Close[i]);
      if(bar_max>M5_SMA) 
        {
         high=bar_max;
         int window_number=0;
         ObjectCreate("high_line",OBJ_HLINE,window_number,Time[i],high);
         break;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int draw_low() 
  {

   for(int i=3; i<999;++i) 
     {
      double bar_max=MathMin(Open[i],Close[i]);
      if(bar_max<M5_SMA) 
        {
         Print("The bar index that is below the SMA =", i);
         high=bar_max;
         int window_number=0;
         ObjectCreate("high_line",OBJ_HLINE,window_number,Time[i],high);
         break;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
Reason: