TRUE Forex

Просмотр кода форекс индикатора !MT4 TF DUO.mq4

#property indicator_chart_window

string         MM_Mode           =  "auto tf octaves3";
extern double  AutoTF3           =  0.125;
extern bool    AutoSelect_TF3    =  true;
extern double  TradingFrame      =  32;
double         ManualFractal     =  0.0006;
int            P                 =  256;
int            Octave_Offset     =  0;
int            StepBack          =  0;
extern int     win               =  1;
extern bool    show_symbol_price =  false;
double         gda_unused_76[];
//+------------------------------------------------------------------+
int            Adjust_Side_to_side  = 10;
int            Shift_UP_DN          = 0;
//+------------------------------------------------------------------+
bool           HM_Date_Auto      =  true;
//+------
int            Table_X_Offset    =  420;
int            Table_Y_Offset    =  0;
//+------------------------------------------------------------------+
int            Price_Size        =  70;
int            Table2_X_Offset   =  -800;
int            Table2_Y_Offset   =  -128;
//+------------------------------------------------------------------+
datetime       HM_Date           =  D'2008.09.15 04:00';
bool           intra_day_lines   =  False;
int            Day_Offset        =  0;
int            TL_Line_Size      =  1;//2;
bool           TL_Labels_On      =  false;
bool           TL_Hide           =  False;
//+------------------------------------------------------------------+
bool           Show_Symbol_Status      =  true;
bool           Symbol_Status_DayLevels =  false;
color          Symbol_Status_BarTime   =  Honeydew;
color          Symbol_Status_Label     =  LightSkyBlue;
//+------------------------------------------------------------------+
extern bool    Hide_All_Comments       =  true;
bool           Show_Time_Comments      =  false;
bool           Comments_Align_Centre   =  True;
double         Time_Expand_By          =  1.0;
int            Font_Size               =  10;
color          Text_Color              =  Black;
bool           Text_Color_Line         =  True;
//+------------------------------------------------------------------+
extern int     Hide_MM_Lines           =  0;
extern int     MM_Line_Style           =  0;
extern int     MM_Line_Width           =  1;
extern bool    color_frame             =  true;
extern color   MM2Color                =  C'83,20,20';
extern color   MMColor                 =  CLR_NONE;//C'17,72,17';
extern color   MM3Color                =  CLR_NONE;//C'0,0,70';
//+------------------------------------------------------------------+
extern color             PlusMinus2_8=SteelBlue;//Red;
extern color             PlusMinus1_8=SteelBlue;//Orange;
extern color             ZeroEight_8=SteelBlue;//DodgerBlue;
extern color             OneSeven_8=SteelBlue;//Yellow;
extern color             TwoSix_8=SteelBlue;//HotPink;
extern color             ThreeFive_8=SteelBlue;//Lime;
extern color             Four_8=SteelBlue;//DodgerBlue;
//+------------------------------------------------------------------+
int               octave_jump = 0;
double            octave_shift_by_price=0.0000;
// Auto adjust parameters
int               Plus_Minus_Eighth_Limit_Level=2;
int               Octave_Limit_Bar_Count=1;
//+------------------------------------------------------------------+
extern bool       show_bml_33_lines=false;
int               bml_33_Style=0;
int               bml_33_Width=1;
extern color      bml_33_Color2=C'62,62,62';

bool              mp_Alpha=true;
bool              Franka_Lines=true;
int               Franka_Style=1;
int               Franka_Width=1;
color             Franka_Color2=SteelBlue;
//+------------------------------------------------------------------+
bool              PopUp_Alert_On=false;
bool              Email_Alert_On=false;
int               Frame_Alert_Mode=1;
bool              Enable_Wick_High_Low_Alert=true;
int               PopUp_Alert_Interval_Secs=300;
int               Email_Alert_Interval_Secs=900;
//+------------------------------------------------------------------+
#define           FF1 "FF1"
#define           FF2 "FF2"
#define           FF3 "FF3"
#define           FF4 "FF4"
#define           FF5 "FF5"
#define           YC "YC"
//+------------------------------------------------------------------+
double  bml_33[27], DecNos;
double  dmml=0, dvtl=0, sum=0, v4=0, v1=0, v2=0, mn=0, mx=0, x1=0, x2=0, x3=0, x4= 0,
        x5=0, x6=0, y1=0, y2=0, y3=0, y4=0, y5=0, y6=0, valcalc=0, octave=0,
        fractal=0, range=0, finalH=0, finalL=0, xmml=0, disp_price=0,
        mmlglobal[13], mml[13], MM_H_Levels[12];
//+------------------------------------------------------------------+        
string  ln_txt[13], buff_str = "", buff_str2 = "", buff_str3 = "", buff_str4 = "",
        sConv="                 ", head1="", head2="", head3="", globalMsg="";
//+------------------------------------------------------------------+        
int bn_v4=0, bn_v1=0, bn_v2=0, OctLinesCnt=13, mml_thk=8, mml_clr[13], mml_shft=3, nTime=0, CurPeriod=0, x33 = 0,
    nDigits=0, frametemp=0, i=0, gb=0, gb_T=0, mP=0, lperiod=0, d=0,ts=0, mml_wdth[13],
    bml_33_Cnt = 27;
//+------------------------------------------------------------------+
bool process_intra_day=True, intra_day_status=True, l_grid_change=True, TimeLines=True;
//+------------------------------------------------------------------+
int MMLineDrawArray[13] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
bool Draw_MM=True;
//+------------------------------------------------------------------+
string TimePointObjects[18];
datetime TimePointTime[18],TimePointTimeT[18],TimeGrid[1],TimeGridByDay[1];
color TimePointColor[18];
double TimePeriodHighLow[2];
int GlobalFrames[13] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096};//{1,2,4,8,16,32,64,128,256};
static datetime BlockStart,BlockEnd,BlockEndText,dt;
static double mp_a=0,one_eighth_v=0;
//+------------------------------------------------------------------+
int init() {
  //// Auto Select TF3/////
   if (AutoSelect_TF3) {
      int aPeriod=Period();
      switch(aPeriod) {
         case 1 :     AutoTF3=0.25; TradingFrame=8; break;
         case 5 :     AutoTF3=0.25; TradingFrame=8; break;
         case 15 :    AutoTF3=0.25; TradingFrame=8; break;
         case 30 :    AutoTF3=0.25; TradingFrame=8; break;
         case 60 :    AutoTF3=0.25; TradingFrame=8; break;
         case 240 :   AutoTF3=0.125; TradingFrame=32; break;
         case 1440 :  AutoTF3=0.0625; TradingFrame=128; break;
         case 10080 : AutoTF3=0.0625; TradingFrame=512; break;
         case 43200 : AutoTF3=0.015625; TradingFrame=2048; break;
      }
   }
  ////////////////////////////////// 
  bn_v1 = Lowest(NULL,0,MODE_LOW,64);
  bn_v4 = Highest(NULL,0,MODE_HIGH,64);

  v1 = Low[bn_v1];
  v4 = High[bn_v4];
  
   IndicatorShortName("!MT4 TimeFrame");
   //---- indicators
   ln_txt[0]  = "                    [-2/8]    ";
   ln_txt[1]  = "                    [-1/8]    ";
   ln_txt[2]  = "                     [0/8]    ";
   ln_txt[3]  = "                     [1/8]    ";
   ln_txt[4]  = "                     [2/8]    ";
   ln_txt[5]  = "                     [3/8]    ";
   ln_txt[6]  = "                     [4/8]    ";
   ln_txt[7]  = "                     [5/8]    ";
   ln_txt[8]  = "                     [6/8]    ";
   ln_txt[9]  = "                     [7/8]    ";
   ln_txt[10] = "                     [8/8]    ";
   ln_txt[11] = "                    [+1/8]    ";
   ln_txt[12] = "                    [+2/8]    ";
//+------------------------------------------------------------------+    
   mml_shft = 5;//original was 3
   mml_thk  = 3;
//+------------------------------------------------------------------+
   mml_wdth[0] = 1;
   mml_wdth[1] = 1;
   mml_wdth[2] = 1;
   mml_wdth[3] = 1;
   mml_wdth[4] = 1;
   mml_wdth[5] = 1;
   mml_wdth[6] = 1;
   mml_wdth[7] = 1;
   mml_wdth[8] = 1;
   mml_wdth[9] = 1;
   mml_wdth[10] = 1;
   mml_wdth[11] = 1;
   mml_wdth[12] = 1;
//+------------------------------------------------------------------+   
   mml_clr[0]  = PlusMinus2_8;
   mml_clr[1]  = PlusMinus1_8;
   mml_clr[2]  = ZeroEight_8;
   mml_clr[3]  = OneSeven_8;
   mml_clr[4]  = TwoSix_8;
   mml_clr[5]  = ThreeFive_8;
   mml_clr[6]  = Four_8;
   mml_clr[7]  = ThreeFive_8;
   mml_clr[8]  = TwoSix_8;
   mml_clr[9]  = OneSeven_8;
   mml_clr[10] = ZeroEight_8;
   mml_clr[11] = PlusMinus1_8;
   mml_clr[12] = PlusMinus2_8;
//+------------------------------------------------------------------+   
   l_grid_change=True;  bool Draw_MM=True;
//+------------------------------------------------------------------+
   // Horizontal level defaults
   if (MM_Mode == "manual" || MM_Mode == "dynamic" || MM_Mode == "manual and dynamic" 
      || MM_Mode == "auto tf octaves1" || MM_Mode == "auto tf octaves2" || MM_Mode == "classic octaves"
      || MM_Mode == "auto tf octaves3" || MM_Mode == "auto tf flex") {
   } else { MM_Mode = "default"; }  
//+------------------------------------------------------------------+   
   //HM_Date Auto Selection
   if (HM_Date_Auto) { HM_Date=HMAuto(HM_Date) ; }  
//+------------------------------------------------------------------+
   // Init timelines code
   if (TimeLines) {
      gb=0;
      // Load Time Grid
      LoadTimeGrid(TimeGrid,TimeGridByDay);
      // Process global vars for plugin display
      frametemp = TradingFrame;
      gb_T = ArraySize(GlobalFrames);
      //intra_day_status=intra_day_lines;
      //intra_day_lines = True;
      while (gb < gb_T) {
         TradingFrame=GlobalFrames[gb];
         TimePointProcess(TimePointObjects,TimePointTime,TimePointTimeT,TimePointColor,process_intra_day);
         ManageGlobals("update",TradingFrame);
         if (process_intra_day) {
            ManageGlobals("intra.day_update");
            process_intra_day=False;
            //intra_day_lines=intra_day_status;
         }
         gb++;
      }
      GlobalVariableSet(StringConcatenate(Symbol(),Period(),"TFStatus"),frametemp);
      TradingFrame=frametemp;
      TimePointProcess(TimePointObjects,TimePointTime,TimePointTimeT,TimePointColor,True);
   }
   CreateMM3(False,Period(),mmlglobal);
   ManageGlobals("h.update",TradingFrame);    
//+------------------------------------------------------------------+ 
   // Plug-in marker
   MathSrand(LocalTime());
   GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"PluginMark"),MathRand());
   
   // Frame alert variables
   GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastPopUpTime"),CurTime());
   GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastEmailTime"),CurTime());
   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() {
//---- Clear screen text
   Comment("\n","  ");   
   for(i=0;i<OctLinesCnt;i++) {
       buff_str = "mml"+i;
       ObjectDelete(buff_str);
       buff_str = "mml_txt"+i;
       ObjectDelete(buff_str);
       ObjectDelete("PRICE_BID:");
   }
//---- Screen Background
   ObjectDelete(FF1);
   ObjectDelete(FF2);
   ObjectDelete(FF3);
   ObjectDelete(FF4);
   ObjectDelete(FF5);
   ObjectDelete("cTiME");
//----   

//----      
   ObjectsDeleteAll(0,OBJ_TREND);
   ObjectsDeleteAll(0,OBJ_TEXT); 
   ObjectsDeleteAll(0,OBJ_LABEL);
   ObjectsDeleteAll(0,OBJ_VLINE);
   ObjectDelete("xb2");
   ObjectDelete("x2");
   ObjectDelete("x2b");
   ObjectDelete("v4");
   ObjectDelete("v1");
//+------------------------------------------------------------------+ 
   // destroy plugin globals
   ManageGlobals("delete");
   ManageGlobals("h.delete",TradingFrame);
   ManageGlobals("intra.day_delete");
//----
   GlobalVariableDel(StringConcatenate(Symbol(),Period(),TradingFrame,"PluginMark"));
   GlobalVariableDel(StringConcatenate(Symbol(),Period(),TradingFrame,"LastPopUpTime"));
   GlobalVariableDel(StringConcatenate(Symbol(),Period(),TradingFrame,"LastEmailTime"));
//----   
   return(0);
}
//+------------------------------------------------------------------+
int start() {
   
   if (StringFind (Symbol(), "JPY", 0) != -1){ DecNos = 2;}
   else { DecNos = 4; } 
   
   int li_8 = Time[0] + 60 * Period() - TimeCurrent();
   double ld_0 = li_8 / 60.0;
   int li_12 = li_8 % 60;
   li_8 = (li_8 - li_8 % 60) / 60;
   
   ObjectDelete("time");
   if (ObjectFind("time") != 0) {
      //ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0] + 0.0005);
      //ObjectSetText("time", "                        " + li_8 + ":" + li_12, 17, "Tahoma", White);
   } else ObjectMove("time", 0, Time[0], Close[0] + 0.0005);

//+------------------------------------------------------------------+
   // if Global Vars Mising
   bool gcheck=True;
   bool gc=false;
   gcheck = GlobalVariableCheck( StringConcatenate(Symbol(),Period(),"TFStatus") );
   if (!gcheck) { reinit(); }
   // Main MM 
   if (l_grid_change) { CreateMM3(True,Period(),mmlglobal);  l_grid_change = false; }
//----     
   // Symbol Status
   disp_price = iMA(Symbol(),Period(),1,0,MODE_EMA,PRICE_CLOSE,0);
   if (Show_Symbol_Status) { SymbolStatus(disp_price); }
//----      
   if (GridChange()) {
      l_grid_change=true; 
      if (Day_Offset==0 && octave_jump==0) { reinit(); }
   }
}
//+------------------------------------------------------------------+
void CreateMM3(bool lfull_run, int cperiod, double& mmlg[]) {
//----      
   lperiod=cperiod; 
   ////////  MM TimeFrame Modes
   if( (nTime != Time[0]) || (CurPeriod != lperiod) ) {
      // Horizontal levels based on current Trading Frame reflection
      if (MM_Mode=="dynamic" || MM_Mode =="manual and dynamic") {
         globalMsg=PreviousFrameRange(TradingFrame,BlockStart,TimePeriodHighLow,lperiod);
         if (StringLen(globalMsg) < 2) {
            globalMsg=StringConcatenate("  * ",MM_Mode);
            v1=TimePeriodHighLow[0];  v2=TimePeriodHighLow[1];
            if (Octave_Offset > 0) {
               valcalc=(v2-v1)+v2; v1=v2;  v2=valcalc;
            }
            if (Octave_Offset < 0) {
               valcalc=v1-(v2-v1);  v2=v1;  v1=valcalc;
            }
         } else {
            globalMsg=StringConcatenate(" using default => ",globalMsg);
            v1=iLow(Symbol(),lperiod,Lowest(NULL,0,MODE_LOW,P+StepBack,0));
            v2=iHigh(Symbol(),lperiod,Highest(NULL,0,MODE_HIGH,P+StepBack,0));
         }
      }
//+------------------------------------------------------------------+    
      // default 
      if (MM_Mode=="default") {
         globalMsg=StringConcatenate("  *  Default ","");
         v1=iLow(Symbol(),lperiod,Lowest(NULL,0,MODE_LOW,P+StepBack,0));
         v2=iHigh(Symbol(),lperiod,Highest(NULL,0,MODE_HIGH,P+StepBack,0));
      }
      // Manual
      if (MM_Mode=="manual") {
         v1=iLow(Symbol(),lperiod,Lowest(NULL,0,MODE_LOW,P+StepBack,0));
         v2=iHigh(Symbol(),lperiod,Highest(NULL,0,MODE_HIGH,P+StepBack,0));
      }
      // Auto TF range
      if (MM_Mode == "auto tf flex") {
         // Calculate 'P' value
         P = iBarShift(Symbol(),lperiod,BlockStart);  //Bars from TF start date 
         //Fractals=False;  // using alternative fractals
         globalMsg=StringConcatenate("  *  Integrated TF Flex Octave","");
         v1=iLow(Symbol(),lperiod,Lowest(NULL,0,MODE_LOW,P+StepBack,0));
         v2=iHigh(Symbol(),lperiod,Highest(NULL,0,MODE_HIGH,P+StepBack,0));
      }
      // Integrated Auto-Octave TimeFrame
      if (MM_Mode=="auto tf octaves1") {
         globalMsg=StringConcatenate("  *  Integrated Auto-TF Octaves-Type 1","");
         v2 = iMA(Symbol(),lperiod,1,0,MODE_EMA,PRICE_CLOSE,0);
      }
      if (MM_Mode=="auto tf octaves2") {
         globalMsg=StringConcatenate("  *  Integrated Auto-TF Octaves-Type 2","");
         v2 = iMA(Symbol(),lperiod,1,0,MODE_EMA,PRICE_CLOSE,0);
      }
      if (MM_Mode=="auto tf octaves3") {
         globalMsg=StringConcatenate("  *  Integrated Auto-TF Octaves-Type 3 | ","F",AutoTF3*128);
         v2 = iMA(Symbol(),lperiod,1,0,MODE_EMA,PRICE_CLOSE,0);
      }
      if (MM_Mode=="classic octaves") {
         v2 = iMA(Symbol(),lperiod,1,0,MODE_EMA,PRICE_CLOSE,0);
         globalMsg=StringConcatenate("  *  Classic Octaves","");
      }
   }
//+------------------------------------------------------------------+
//determine fractal.....
   if( v2<=250000 && v2>25000 )
   fractal=100000;
   else
     if( v2<=25000 && v2>2500 )
     fractal=10000;
     else
       if( v2<=2500 && v2>250 )
       fractal=1000;
       else
         if( v2<=250 && v2>25 )
         fractal=100;
         else
           if( v2<=25 && v2>12.5 )
           fractal=12.5;
           else
             if( v2<=12.5 && v2>6.25)
             fractal=12.5;
             else
               if( v2<=6.25 && v2>3.125 )
               fractal=6.25;
               else
                 if( v2<=3.125 && v2>1.5625 )
                 fractal=3.125;
                 else
                   if( v2<=1.5625 && v2>0.390625 )
                   fractal=1.5625;
                   else
                     if( v2<=0.390625 && v2>0)
                     fractal=0.1953125;
//+------------------------------------------------------------------+ 
   // Bypass Fractal settings
   if (MM_Mode=="manual" || MM_Mode=="manual and dynamic") {
      globalMsg=StringConcatenate("  *  ",MM_Mode);
      fractal = ManualFractal;
   }                   
//----
   if (!TimeLines) {
      BlockStart=iTime(NULL,Period(),P);
      BlockEnd = FutureBarTime(-48);
      BlockEndText = FutureBarTime(-44);
   }    
   // Calculating Our TimeFrame    
   range=(v2-v1);
   sum=MathFloor(MathLog(fractal/range)/MathLog(2));
   octave=fractal*(MathPow(0.5,sum));
   mn=MathFloor(v1/octave)*octave;
   if( (mn+octave)>v2 )
      mx=mn+octave; 
   else
     mx=mn+(2*octave);

   // calculating xx
   //x2
    if( (v1>=(3*(mx-mn)/16+mn)) && (v2<=(9*(mx-mn)/16+mn)) )
    x2=mn+(mx-mn)/2; 
    else x2=0;
   //x1
    if( (v1>=(mn-(mx-mn)/8))&& (v2<=(5*(mx-mn)/8+mn)) && (x2==0) )
    x1=mn+(mx-mn)/2; 
    else x1=0;

   //x4
    if( (v1>=(mn+7*(mx-mn)/16))&& (v2<=(13*(mx-mn)/16+mn)) )
    x4=mn+3*(mx-mn)/4; 
    else x4=0;

   //x5
    if( (v1>=(mn+3*(mx-mn)/8))&& (v2<=(9*(mx-mn)/8+mn))&& (x4==0) )
    x5=mx; 
    else  x5=0;

   //x3
    if( (v1>=(mn+(mx-mn)/8))&& (v2<=(7*(mx-mn)/8+mn))&& (x1==0) && (x2==0) && (x4==0) && (x5==0) )
    x3=mn+3*(mx-mn)/4; 
    else x3=0;

   //x6
    if( (x1+x2+x3+x4+x5) ==0 )
    x6=mx; 
    else x6=0;

    finalH = x1+x2+x3+x4+x5+x6;
   // calculating yy
   //y1
    if( x1>0 )
    y1=mn; 
    else y1=0;

   //y2
    if( x2>0 )
    y2=mn+(mx-mn)/4; 
    else y2=0;

   //y3
    if( x3>0 )
    y3=mn+(mx-mn)/4; 
    else y3=0;

   //y4
    if( x4>0 )
    y4=mn+(mx-mn)/2; 
    else y4=0;

   //y5
    if( x5>0 )
    y5=mn+(mx-mn)/2; 
    else y5=0;

   //y6
    if( (finalH>0) && ((y1+y2+y3+y4+y5)==0) )
    y6=mn; 
    else y6=0;

    finalL = y1+y2+y3+y4+y5+y6;

    for( i=0; i<OctLinesCnt; i++) {
         mml[i] = 0;
    }
//+------------------------------------------------------------------+    
    // bypass range calculation if octave mode selected - auto jump 
    if (MM_Mode=="auto tf octaves1") { ProcessOctaves(finalL, finalH, 1); }
    if (MM_Mode=="auto tf octaves2") { ProcessOctaves(finalL, finalH, 2); } 
    if (MM_Mode=="auto tf octaves3") { ProcessOctaves(finalL, finalH, 3); } 
    if (MM_Mode=="classic octaves") { ProcessOctaves(finalL, finalH, 4); }
//+------------------------------------------------------------------+ 

    //creating our octave/////////////////////////
    xmml = ((finalH-finalL)/2);
    double xmm = xmml/8;
    finalH += (octave_jump * xmml);
    finalL += (octave_jump * xmml);
    ///////////////////////////////////////////////
    /// shift by price after jump_.
    finalH += octave_shift_by_price;
    finalL += octave_shift_by_price; 
    //////////////////////////////////////////////
    dmml = (finalH-finalL)/8;
    mml[0] =(finalL-dmml*2); //-2/8
    for( i=1; i<OctLinesCnt; i++) {
        mml[i] = mml[i-1] + dmml;
    }
    ArrayCopy(mmlg,mml);   // copy rates to global array

//+------------------------------------------------------------------+
if (lfull_run) {   
   // Draw Horizontals
   Draw_MM=True; 
   for( i=0; i<OctLinesCnt; i++ ){
      buff_str = "mml"+i;
   
      if (Hide_MM_Lines != 0) {
         if (Hide_MM_Lines == 1 || Hide_MM_Lines == 2 || Hide_MM_Lines == 3) {  
            if (Hide_MM_Lines == 1) { selectMMdraw(1, MMLineDrawArray); }
            if (Hide_MM_Lines == 2) { selectMMdraw(2, MMLineDrawArray); }
            if (Hide_MM_Lines == 3) { selectMMdraw(3, MMLineDrawArray); }
         
            if (InList(i,MMLineDrawArray)) { Draw_MM=True; } else { Draw_MM=False; }
            Print ("Draw_MM Value " ,Draw_MM,"  ",i);
            
            for (int v=0; v<ArraySize(MMLineDrawArray);v++) {
               Print ("Values ",MMLineDrawArray[v],"...");
            }   
         }
      }
//+------------------------------------------------------------------+      
if (Draw_MM) {
         if(ObjectFind(buff_str) == -1) {
            ObjectCreate(buff_str, OBJ_TREND, 0, BlockEnd, mml[i], BlockStart, mml[i]);
            ObjectSet(buff_str, OBJPROP_STYLE, MM_Line_Style);
            ObjectSet(buff_str, OBJPROP_COLOR, mml_clr[i]);
            ObjectSet(buff_str, OBJPROP_BACK, 1);
            ObjectSet(buff_str, OBJPROP_RAY, false);
            ObjectSet(buff_str, OBJPROP_WIDTH,mml_wdth[i]);
            ObjectMove(buff_str, 0, BlockEnd, mml[i]);
         } else {
            ObjectMove(buff_str, 0, BlockEnd, mml[i]);
         }    
//----         

//+------------------------------------------------------------------+          
        ts=0;
         while (ts < 9) { 
            buff_str = "mml_txt"+i+ts;
         
            if(ObjectFind(buff_str) == -1) {
               ObjectCreate(buff_str, OBJ_TEXT, 0, Time[0], mml_shft);
               ObjectSet(buff_str, OBJPROP_BACK, 1);
               if (Text_Color_Line) {
                  ObjectSetText(buff_str, ln_txt[i]+DoubleToStr(mml[i],DecNos)+sConv, Font_Size, "Arial", mml_clr[i]);
               } else {
                  ObjectSetText(buff_str, ln_txt[i]+DoubleToStr(mml[i],DecNos)+sConv, Font_Size, "Arial", Text_Color);
               }
               ObjectMove(buff_str, 0, TimePointTimeT[ts],  mml[i]);  
            } else {
               ObjectMove(buff_str, 0, TimePointTimeT[ts],  mml[i]);    
            }
            ts++;
         }    
//+------------------------------------------------------------------+ 
      }
   } 
   nTime    = Time[0];
   CurPeriod= Period();
//+------------------------------------------------------------------+
// Calculate bml_33 Lines
bml_33[1] = (mml[0]-(mml[2]-mml[1])/3);
bml_33[2] = ((mml[1]-mml[0])/3)+mml[0];
bml_33[3] = ((mml[1]-mml[0])/3)*2+mml[0];
bml_33[4] = ((mml[2]-mml[1])/3)+mml[1];
bml_33[5] = ((mml[2]-mml[1])/3)*2+mml[1];
bml_33[6] = ((mml[3]-mml[2])/3)+mml[2];
bml_33[7] = ((mml[3]-mml[2])/3)*2+mml[2];
bml_33[8] = ((mml[4]-mml[3])/3)+mml[3];
bml_33[9] = ((mml[4]-mml[3])/3)*2+mml[3];
bml_33[10] = ((mml[5]-mml[4])/3)+mml[4];
bml_33[11] = ((mml[5]-mml[4])/3)*2+mml[4];
bml_33[12] = ((mml[6]-mml[5])/3)+mml[5];
bml_33[13] = ((mml[6]-mml[5])/3)*2+mml[5];
bml_33[14] = ((mml[7]-mml[6])/3)+mml[6];
bml_33[15] = ((mml[7]-mml[6])/3)*2+mml[6];
bml_33[16] = ((mml[8]-mml[7])/3)+mml[7];
bml_33[17] = ((mml[8]-mml[7])/3)*2+mml[7];
bml_33[18] = ((mml[9]-mml[8])/3)+mml[8];
bml_33[19] = ((mml[9]-mml[8])/3)*2+mml[8];
bml_33[20] = ((mml[10]-mml[9])/3)+mml[9];
bml_33[21] = ((mml[10]-mml[9])/3)*2+mml[9];
bml_33[22] = ((mml[11]-mml[10])/3)+mml[10];
bml_33[23] = ((mml[11]-mml[10])/3)*2+mml[10];
bml_33[24] = ((mml[12]-mml[11])/3)+mml[11];
bml_33[25] = ((mml[12]-mml[11])/3)*2+mml[11];
bml_33[26] = ((mml[12]-mml[11])/3)+mml[12];
//----
if (show_bml_33_lines) {
   Drawbml_33("vbml.331", bml_33[1], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.332", bml_33[2], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.333", bml_33[3], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.334", bml_33[4], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.335", bml_33[5], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.336", bml_33[6], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.337", bml_33[7], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.338", bml_33[8], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.339", bml_33[9], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3310", bml_33[10], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3311", bml_33[11], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3312", bml_33[12], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3313", bml_33[13], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3314", bml_33[14], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3315", bml_33[15], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3316", bml_33[16], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3317", bml_33[17], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3318", bml_33[18], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3319", bml_33[19], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3320", bml_33[20], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3321", bml_33[21], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3322", bml_33[22], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3323", bml_33[23], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3324", bml_33[24], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3325", bml_33[25], bml_33_Style, bml_33_Width, bml_33_Color2);
   Drawbml_33("vbml.3326", bml_33[26], bml_33_Style, bml_33_Width, bml_33_Color2);   
}
//+------------------------------------------------------------------+


// Calculate Franka Lines
double fn_m2_b;
double fn_p2_a;
double fn_2_a,fn_6_b;
double franka_factor=0; franka_factor=(dmml*2/3);
//----
fn_m2_b = mml[0]-franka_factor;
fn_p2_a = mml[12]+franka_factor;  
fn_2_a  = mml[4]+franka_factor;   
fn_6_b = mml[8]-franka_factor;
//+------------------------------------------------------------------+
if (color_frame) { 
CreateObj3(FF1, mml[5], mml[7], MMColor);
CreateObj3(FF2, mml[0], mml[2], MM2Color);
CreateObj3(FF3, mml[10], mml[12], MM2Color);
CreateObj3(FF4, mml[7], mml[10], MM3Color);
CreateObj3(FF5, mml[2], mml[5], MM3Color);
}
//+------------------------------------------------------------------+
// Draw Time Lines here
if (TimeLines) {
   DrawTimePoints();
}
ObjectsRedraw();
//+------------------------------------------------------------------+
// Franka Lines
if (Franka_Lines) {
   DrawFranka("vfn.m2.b", fn_m2_b, Franka_Style, Franka_Width, Franka_Color2);
   DrawFranka("vfn.p2.a", fn_p2_a, Franka_Style, Franka_Width, Franka_Color2);
   //DrawFranka("vfn.2.a", fn_2_a, Franka_Style, Franka_Width, Franka_Color2);
   //DrawFranka("vfn.6.b", fn_6_b, Franka_Style, Franka_Width, Franka_Color2);   
}
//+------------------------------------------------------------------+
ObjectsRedraw();
  
// Screen Header
one_eighth_v=((finalH-finalL)/8);
double xpf=0,xmf=0;
xpf=finalH+((finalH-finalL)*1/3); xmf=finalL-((finalH-finalL)*1/3);
//+------------------------------------------------------------------+
if (Comments_Align_Centre) {
head1=StringConcatenate("Fractal: ",fractal,"    Octave: ",dmml*8,"    Frame: ",fractal/(dmml*8),"   1/8: ",dmml,"   2/8: ",dmml*2,"   3/8: ",dmml*3,"   4/8: ",dmml*4,"   5/8: ",dmml*5,"   6/8: ",dmml*6,"   7/8: ",dmml*7,"   8/8: ",dmml*8,"   High: ",v4,"   Low: ",v1);
head2=StringConcatenate("                                                                                         ",
      "Price  -  8/8: ",one_eighth_v*8,"   7/8: ",one_eighth_v*7,"   6/8: ",one_eighth_v*6,"   5/8: ",one_eighth_v*5,
      "   4/8: ",one_eighth_v*4,"   3/8: ",one_eighth_v*3,"   2/8: ",one_eighth_v*2,"   1/8: ",one_eighth_v*1);
head3=StringConcatenate("                                                   ",
      "Time    -  8/8: ",TimeC(8),"   7/8: ",TimeC(7),"   6/8: ",TimeC(6),"   5/8: ",TimeC(5),
      "   4/8: ",TimeC(4),"   3/8: ",TimeC(3),"   2/8: ",TimeC(2),"   1/8: ",TimeC(1));
} else {
head1=StringConcatenate("::::: DateTime: ",TimeToStr(LocalTime()),"  TimeFrame-2007-v0.08 ", globalMsg, " ::::: ");
head2=StringConcatenate("Price  -  8/8: ",one_eighth_v*8,"   7/8: ",one_eighth_v*7,"   6/8: ",one_eighth_v*6,"   5/8: ",one_eighth_v*5,
      "   4/8: ",one_eighth_v*4,"   3/8: ",one_eighth_v*3,"   2/8: ",one_eighth_v*2,"   1/8: ",one_eighth_v*1);
head3=StringConcatenate("Time    -  8/8: ",TimeC(8),"   7/8: ",TimeC(7),"   6/8: ",TimeC(6),"   5/8: ",TimeC(5),
      "   4/8: ",TimeC(4),"   3/8: ",TimeC(3),"   2/8: ",TimeC(2),"   1/8: ",TimeC(1));
}
if (!Hide_All_Comments) {
   if (Show_Time_Comments) { Comment(head1,"\n",head2,"\n",head3); }
   else { Comment(head1); }
   }

}  // close l.full.run condition
//----
return(0);
}
//---- End Of Program
//+------------------------------------------------------------------+
void CreateObj3(string objName3, double start, double end, color clr) {
   ObjectCreate(objName3, OBJ_RECTANGLE, 0, BlockStart, start, BlockEnd, end);
   ObjectSet(objName3, OBJPROP_COLOR, clr);
}
//+------------------------------------------------------------------+ 
// Calculate Future Bar 
datetime FutureBarTime(int xbar) {
   int bar_seconds,add_bars;
   datetime past_bar_time,future_time;
   
   bar_seconds = Period()*60;
   // Start counting from bar one to future
   if (xbar > -1) xbar=-1;
   
   add_bars = MathAbs(1 - xbar);
   past_bar_time = iTime(Symbol(),Period(),1);  // bar before current Bar
   future_time = past_bar_time + (add_bars * bar_seconds);
   return(future_time);
}
//+------------------------------------------------------------------+  
int FutureTimeBar(datetime xtime) {
   int bar_seconds,add_time;
   int future_bar;
   
   bar_seconds = Period()*60;
   // Start counting from bar one to future
   if (xtime < CurTime()) xtime=CurTime();
   
   add_time = xtime;
   //past_bar_time = iTime(Symbol(),Period(),1);  // bar before current Bar
   future_bar = -(xtime - CurTime()) / bar_seconds;
   return(future_bar);
}
//+------------------------------------------------------------------+
void DrawTimePoints() {
   int t_list,i;
   i=0;
   t_list = ArraySize(TimePointObjects);
   //Delete Objects from chart 
   for (i=t_list-1;i>=0;i--) {
      if (StringLen(TimePointObjects[i]) > 5) {
         ObjectDelete(TimePointObjects[i]);
      }
   }
   // Draw new points
   i=0;
   while (i < t_list) {
      if (!intra_day_lines) {
         if (i > 8) { break; }
      } else {
         if (Period() > 90 && i > 8) {break;}
      }
//+------------------------------------------------------------------+    
      ObjectCreate(TimePointObjects[i],OBJ_TREND,0, TimePointTime[i],mml[12],TimePointTime[i],mml[0]);
      ObjectSet(TimePointObjects[i], OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(TimePointObjects[i],OBJPROP_RAY,false);
      ObjectSet(TimePointObjects[i], OBJPROP_WIDTH, TL_Line_Size);
      ObjectSet(TimePointObjects[i], OBJPROP_BACK, !(TL_Labels_On));
      ObjectSet(TimePointObjects[i], OBJPROP_COLOR, TimePointColor[i]);
      ObjectSet(TimePointObjects[i],OBJPROP_TIME1,TimePointTime[i]);
      i++;
      if (TL_Hide) { break; }
   }
   return(0);
}    
//+------------------------------------------------------------------+
void TimePointProcess(string& tpO[],datetime& tpT[], datetime& tpTT[], color& tpC[], bool TFCurrent = True) {
   string myLabel,xLine;
   myLabel= StringConcatenate(Symbol(), Period());
    
   // Default Trading Frame if not 256,128,64,32,16 ,8 ,4 ...Days
   if (TradingFrame != 1 && TradingFrame != 2 && TradingFrame != 4 && TradingFrame != 8 && TradingFrame != 16 &&
        TradingFrame != 32 && TradingFrame != 64 && TradingFrame != 128  && TradingFrame != 256  && TradingFrame != 512  && TradingFrame != 3072) {
      TradingFrame = 4;
   }
   bool isFuture=False;
   int day_pos=0, z=0, limit=0, ie=0, filter_secs=0, lx=0, day_offset_int=0, days_to_process=0;
   int full_day= 1440*60;
   double block_increment,day_interval,day_offset_double;
   datetime end_day,start_day,compare_end,cCurrent,x_date,eblock,old_block,old_block_c,d_scale_date;
   datetime x_now=CurTime();
   string intra_day_start_time=StringConcatenate(TimeToStr(CurTime(),TIME_DATE)," ",
            TimeToStr(HM_Date,TIME_MINUTES));
   day_interval = TradingFrame;
   day_interval = day_interval/8;
   block_increment = (day_interval*1440)*60;  // Seconds
   day_offset_double = Day_Offset;
   day_offset_double = MathAbs(day_offset_double);
   day_offset_int = day_offset_double;
//+------------------------------------------------------------------+   
   // Find Start poistion
   start_day = FindFrameStart(TradingFrame);
   // Find start on day Increment Grid
   day_pos=ArrayBsearch(TimeGridByDay,start_day);
   // Process Day Offset
   //if (TFCurrent) {
      if (Day_Offset != 0) {
         if (Day_Offset > 0) {
            if ((day_pos+day_offset_int) < ArraySize(TimeGridByDay)) {
               if (CurTime() > TimeGridByDay[day_pos+day_offset_int]) {
                  start_day = TimeGridByDay[day_pos+day_offset_int];
                  day_pos=day_pos+day_offset_int;
               }
            }
         } else {
            if ((day_pos-day_offset_int) >= 0) {
               start_day = TimeGridByDay[day_pos-day_offset_int];
               day_pos=day_pos-day_offset_int;
            }
         }
      }
//+------------------------------------------------------------------+
   cCurrent = start_day;  x_date = cCurrent; eblock = x_date;
   for( z=0; z<9; z++) {
      xLine = StringConcatenate("  ",z,"/8"); 
      if (z==0 || z==8) { tpC[z]=ZeroEight_8; }
      if (z==1 || z==7) { tpC[z]=OneSeven_8; }
      if (z==2 || z==6) { tpC[z]=TwoSix_8; }
      if (z==3 || z==5) { tpC[z]=ThreeFive_8; }
      if (z==4 ) { tpC[z]=Four_8; }
//+------------------------------------------------------------------+
      // initialize time point arrays
      tpT[z]= cCurrent;
      tpTT[z] = x_date;
      tpO[z]= StringConcatenate(myLabel, xLine,"-",TimeToStr(x_date,TIME_DATE|TIME_MINUTES));
      // True grid increment
      old_block = x_date;  old_block_c = cCurrent; 
      if (block_increment > full_day) {
         filter_secs = 0; lx = 0;
         days_to_process = day_interval;
         while (lx < days_to_process) {
            eblock += full_day;
            eblock = FilterNonTradingPeriod(eblock,full_day,filter_secs);
            lx++;
         }
      } else {
         filter_secs=0;
         eblock += block_increment;
         eblock = FilterNonTradingPeriod(eblock,block_increment,filter_secs);
      }
//+------------------------------------------------------------------+      
      // check block position...       
      if (isFuture) {
         cCurrent += block_increment;
         x_date = eblock;
      } else {
         d_scale_date = TrackEightBlock(old_block,eblock,block_increment,isFuture);
         cCurrent = eblock;
         x_date = eblock;
         if (isFuture) { cCurrent=d_scale_date; }
      }
   }
//+------------------------------------------------------------------+
   if (TFCurrent) {
      // Establish static var block variables
      BlockStart=start_day;
      BlockEnd=old_block_c;
      BlockEndText=FutureBarTime((FutureTimeBar(BlockEnd)));
   
      if (intra_day_lines && Period() <= 90) {   // 90M
         cCurrent = StrToTime(intra_day_start_time);
         if (CurTime() < cCurrent) {
            if (TimeDayOfWeek(cCurrent) == 1) { cCurrent -= (1440*60)*3; }  
            else { cCurrent -= (1440*60); } 
         }                                                                             
         x_date=cCurrent;
         for( z=0; z<9; z++) {
            xLine = StringConcatenate("  baby ",z,"/8"); 
            if (z==0 || z==8) { tpC[z+9]=ZeroEight_8; }
            if (z==1 || z==7) { tpC[z+9]=OneSeven_8; }
            if (z==2 || z==6) { tpC[z+9]=TwoSix_8; }
            if (z==3 || z==5) { tpC[z+9]=ThreeFive_8; }
            if (z==4 ) { tpC[z+9]=Four_8; }
         
            if (cCurrent < CurTime() ) {
               tpO[z+9]= StringConcatenate(myLabel, xLine,"-",TimeToStr(cCurrent,TIME_DATE|TIME_MINUTES));
            } else {
               tpO[z+9]= StringConcatenate(myLabel, xLine,"-",TimeToStr(x_date,TIME_DATE|TIME_MINUTES));
            }
            tpT[z+9]= cCurrent;
            cCurrent += (180*60); x_date += (180*60);  filter_secs=0;
            if (cCurrent < CurTime()) {
               cCurrent = FilterNonTradingPeriod(cCurrent,(180*60),filter_secs);
            } else {
               x_date = FilterNonTradingPeriod(x_date,(180*60),filter_secs);
            }
         }
      }
   }
   return(0);
}
//+------------------------------------------------------------------+
void LoadTimeGrid(datetime& T_Grid[], datetime& T_GridByDay[]) {
   int p=0, e256_secs=0, s=0, z_pos=0;
   int one_day=(1440*60);
   int four_days=one_day*4;
    bool isHoliday=False;
   datetime calcStart;

   // Create 4-Day Grid
   calcStart = HM_Date;
   T_Grid[0]=calcStart;
   T_GridByDay[0]=calcStart;
   while (p < 64) {

      for( s=0; s<4; s++) {
         e256_secs = 0;
         calcStart += one_day;
         calcStart = FilterNonTradingPeriod(calcStart,one_day,e256_secs);
         
         // Load Grid with days excluding weekends & holidays
         z_pos++;
         ArrayResize(T_GridByDay,z_pos+1);
         T_GridByDay[z_pos]=calcStart;
      }
        //--add to grid
       p++;
      ArrayResize(T_Grid,p+1);
      T_Grid[p]=calcStart;
   }
    return(0);
}
//+------------------------------------------------------------------+
datetime FindFrameStart(int xFrame) {
   int xLimit,xCnt,s_pos,e_pos,insFrame; insFrame=0;
   datetime comp_date,intra_day_start_time; 
   ////////////////////////////////////////////////////////////////////////////
   intra_day_start_time=StrToTime(StringConcatenate(TimeToStr(CurTime(),TIME_DATE),
         " ",TimeToStr(HM_Date,TIME_MINUTES)));
   //////  conditional adjustment to intraday start_.
   if (CurTime() < intra_day_start_time) {
      if (TimeDayOfWeek(intra_day_start_time) == 1) { intra_day_start_time -= (1440*60)*3; }  
      else { intra_day_start_time -= (1440*60); } 
   }                                   
   ///////////////////////////////////////////////////////////////////////////      
   if (xFrame==2) { xFrame=4; insFrame=2; }
   if (xFrame==1) { xFrame=4; insFrame=1; }
   
   xCnt = 0; 
   xLimit = ArraySize(TimeGrid);
   while (xCnt < xLimit) {
      comp_date = TimeGrid[xCnt];
      s_pos=ArrayBsearch(TimeGridByDay,comp_date);
      e_pos=s_pos+xFrame;
      if (CurTime() < TimeGridByDay[e_pos]) {
         break;
      } 
      xCnt = xCnt + (xFrame/4);
   }
   /// SubFrame insert
   if (insFrame==2) {
      if (CurTime() > TimeGridByDay[s_pos+2]) { comp_date = TimeGridByDay[s_pos+2]; }
   }
   if (insFrame==1) { comp_date = intra_day_start_time; }
   return (comp_date);
}
//+------------------------------------------------------------------+
datetime TrackEightBlock(datetime old_block, datetime new_block, double block_incr, bool& lfuture) {
   int time_past=0,time_outstanding=0;
   datetime draw_scale_date;
   draw_scale_date=CurTime();
   lfuture = False;   
   
   if (new_block > CurTime()) {
      lfuture = True;
      time_past = TimeRangeFilterSecs(old_block,CurTime());
      time_outstanding = block_incr - time_past;
      /////////////////////////////////////////////
      draw_scale_date = CurTime() + time_outstanding;
   }
    return(draw_scale_date);
}
//+------------------------------------------------------------------+
// global Time functions

void reinit() {
   deinit();
   init();
   return(0);
}

void ManageGlobals(string lJob,int xFrame =0) {
   string gVar="",sVar="";
   int gb=0,gb_T=0,tx=0;
   gb_T = ArraySize(GlobalFrames);
   
   if (lJob == "update") {
      sVar="";
      gVar=StringConcatenate(Symbol(),Period(),"TF",xFrame,"data");
         
      while (tx < 9) {
         // set global var
         sVar = StringConcatenate(gVar,tx);
         GlobalVariableSet(sVar, TimePointTimeT[tx]);
         tx++;
      }
   }
   
   if (lJob == "delete") {
   
      while (gb < gb_T) {
         sVar=""; tx=0;
         gVar=StringConcatenate(Symbol(),Period(),"TF",GlobalFrames[gb],"data");
         
         while (tx < 9) {
            // del global var
            sVar = StringConcatenate(gVar,tx);
            GlobalVariableDel(sVar);
            tx++;
         }
         gb++;
      }
      GlobalVariableDel(StringConcatenate(Symbol(),Period(),"TFStatus") );
   }  
   
   if (lJob == "h.update") {
      sVar=""; tx=0;
      gVar=StringConcatenate(Symbol(),Period(),"H",xFrame,"dataMML");
         
      while (tx < 13) {
         // set global var
         sVar = StringConcatenate(gVar,tx);
         GlobalVariableSet(sVar, mml[tx]);
         tx++;
      }
   }
   
   if (lJob == "h.delete") {

      //while (gb < gb_T) {
        sVar=""; tx=0;
         //gVar=StringConcatenate(Symbol(),Period(),"H",GlobalFrames[gb],"dataMML");
         gVar=StringConcatenate(Symbol(),Period(),"H",xFrame,"dataMML");
         while (tx < 13) {
            // del global var
            sVar = StringConcatenate(gVar,tx);
            GlobalVariableDel(sVar);
            tx++;
         }
        // gb++;
      //}
   }
//+------------------------------------------------------------------+   
   // intra day globals
   if (lJob == "intra.day_update") {
      sVar=""; tx= 9;
      gVar=StringConcatenate(Symbol(),Period(),"TFintradaydata");
         
      while (tx < 18) {
         // set global var
         sVar = StringConcatenate(gVar,tx);
         GlobalVariableSet(sVar, TimePointTime[tx]);
         tx++;
      }
   }
   
   if (lJob == "intra.day_delete") {
   
      sVar=""; tx=9;
      gVar=StringConcatenate(Symbol(),Period(),"TFintradaydata");
         
      while (tx < 18) {
         // del global var
         sVar = StringConcatenate(gVar,tx);
         GlobalVariableDel(sVar);
         tx++;
      }
   }
   return(0);
}
//+------------------------------------------------------------------+
//=== Day filters
datetime FilterNonTradingPeriod(datetime b_date,int b_increment,int& b_filter_total) {
   // works for one day maximum
   int ic=0,f_total=0,b_s_partial=0,b_e_partial=0,secs_filter=0;
   datetime r_date,end_trading_date,e_temp_date,start_trading_day;
   
   while (isNonTradingDay(b_date)) {
      if (ic==0) {   // take first part of partial period 
         e_temp_date = b_date - b_increment;
         end_trading_date = StrToTime(StringConcatenate(TimeToStr(b_date,TIME_DATE)," 00:00:00"));   // end of day  
         b_s_partial = end_trading_date - e_temp_date;
         secs_filter = b_date - end_trading_date;
      }
      b_date += b_increment;
      secs_filter += b_increment;
      ic++;
   }
   if (ic > 0) {
      start_trading_day = StrToTime(StringConcatenate(TimeToStr(b_date,TIME_DATE)," 00:00:00"));   // beginning of day
      b_e_partial = b_increment - b_s_partial;
      r_date = start_trading_day + b_e_partial; // start time on new trading day 
      secs_filter -= (b_date - start_trading_day);
   } else {
      r_date = b_date;
   }
   b_filter_total = secs_filter;
   return(r_date);
}  
   
bool isNonTradingDay(datetime n_time) {
   bool isNonTradingDay_x=False;
   if (isWeekEndDay(n_time) || isHoliday(n_time)) {isNonTradingDay_x = True; }
   return (isNonTradingDay_x);
}

bool isWeekEndDay(datetime w_time) {
   bool isWeekEndDay_x=False;
   if (TimeDayOfWeek(w_time)==6) { isWeekEndDay_x=True; }
   if (TimeDayOfWeek(w_time)==0) { isWeekEndDay_x=True; }
   return (isWeekEndDay_x);
}

bool isHoliday(datetime h_time) {
    bool isHoliday_x=False;
   // Add additional holidays if necessary  ... format : Month then day
   if (TimeMonth(h_time) == 12 && TimeDay(h_time) == 25) { isHoliday_x=True; }
   if (TimeMonth(h_time) == 1 && TimeDay(h_time) == 1) { isHoliday_x=True; }
   
   //--------------------------------------------------------------------------//
   return (isHoliday_x);
}
//+------------------------------------------------------------------+
int TimeRangeFilterSecs(datetime ftime1, datetime ftime2) {
   datetime ltime1,ltime2;
   int filter_seconds=0,lday=0,one_day_seconds=0,time_range_seconds=0,rtime=0;
   one_day_seconds= 1440*60;
   ltime1=ftime1; ltime2=ftime2;
   time_range_seconds = ltime2 - ltime1;
   
   if (time_range_seconds > one_day_seconds) {
      while (ltime1 < ltime2) {
         if (isNonTradingDay(ltime1)) {
            filter_seconds += one_day_seconds;
         }
         ltime1 += one_day_seconds;
      }
   }
   rtime = (ftime2 - ftime1) - filter_seconds;
   return (rtime);
}
//+------------------------------------------------------------------+
string PreviousFrameRange(int xFrame, datetime s_date, double& T_P_HighLow[],int lperiod) {
   int bars_period_start=0;
   int bars_xframe_total=0;
   int bars_fbp_start=0;
   double fbp_l=0, fbp_h=0;
   string rMsg="";
   
   T_P_HighLow[0]=0; T_P_HighLow[1]=0;
   bars_period_start=iBarShift(Symbol(),lperiod,s_date);
   bars_xframe_total=(xFrame*1440)/lperiod;    // total bars in frame
   bars_fbp_start=bars_period_start+bars_xframe_total;
   if (bars_period_start > iBars(Symbol(),lperiod)) rMsg="Insufficient history to process 1st past Frame!";
   if (bars_fbp_start > iBars(Symbol(),lperiod)) rMsg="Insufficient history to process 2nd past Frame!";
   if (bars_xframe_total < 1) rMsg="MT TimeFrame too large for current Trading Frame!";
   T_P_HighLow[0]=iLow(Symbol(),lperiod,Lowest(NULL,0,MODE_LOW,bars_xframe_total,bars_period_start));
   T_P_HighLow[1]=iHigh(Symbol(),lperiod,Highest(NULL,0,MODE_HIGH,bars_xframe_total,bars_period_start));
   // Check with Frame before previous_...   
   fbp_l=iLow(Symbol(),lperiod,Lowest(NULL,0,MODE_LOW,bars_xframe_total,bars_fbp_start));
   fbp_h=iHigh(Symbol(),lperiod,Highest(NULL,0,MODE_HIGH,bars_xframe_total,bars_fbp_start));
   // modify high or low the 'frame berore previous' extreeme if lower or higher
   if ((T_P_HighLow[0] < fbp_h) && (fbp_h-T_P_HighLow[0]<T_P_HighLow[1]-fbp_h) && (T_P_HighLow[1] > fbp_h)) T_P_HighLow[0]=fbp_h;
   if ((T_P_HighLow[1] > fbp_l) && (T_P_HighLow[0]-fbp_l>fbp_l-T_P_HighLow[0]) && (T_P_HighLow[0] < fbp_l)) T_P_HighLow[1]=fbp_l;

   return(rMsg);
}
//+------------------------------------------------------------------+
void SymbolStatus(double xard) {
   double H2DAILY = iMA(Symbol(),PERIOD_D1,0,0,MODE_HIGH,PRICE_HIGH,0);
   double LDAILY = iMA(Symbol(),PERIOD_D1,0,0,MODE_LOW,PRICE_LOW,0);
   string xBar="",speriod="";
   int bar_total=0,b_secs=0,P=0;
   datetime bar_start,curT,old_bar,new_T,bar_end;
   bool bar_elapsed=False;
     
   curT=CurTime();
   old_bar=Time[1];
   bar_total = Period()*60;
   bar_start=Time[0];
   bar_end=bar_start+bar_total;
   
   // Symbol Status Frame levels
   if (!Symbol_Status_DayLevels) {
       P = iBarShift(Symbol(),Period(),BlockStart);  //Bars from TF start date 
       LDAILY=iLow(Symbol(),Period(),Lowest(NULL,0,MODE_LOW,P,0));
       H2DAILY=iHigh(Symbol(),Period(),Highest(NULL,0,MODE_HIGH,P,0));
   }
   
   if (bar_elapsed) {
      new_T = curT - bar_start;
   } else {
      new_T = bar_end - curT;
   }
//+------------------------------------------------------------------+   
   xBar = DHM(new_T,False,True);
     
   speriod=StringConcatenate(Period(),"M ",TradingFrame,"TF");

if (show_symbol_price) {   
ObjectDelete("x2");
   ObjectCreate("x2", OBJ_LABEL, win, 0, 0);
   ObjectSetText("x2",DoubleToStr(Bid,DecNos) , 25, "Arial Bold", DarkGray);
   ObjectSet("x2", OBJPROP_CORNER, 1);
   ObjectSet("x2", OBJPROP_XDISTANCE, Adjust_Side_to_side + 5);
   ObjectSet("x2", OBJPROP_YDISTANCE, Shift_UP_DN + 30);
   
   ObjectDelete("x2b");
   ObjectCreate("x2b", OBJ_LABEL, win, 0, 0);
   ObjectSetText("x2b",Symbol() , 18, "Arial Bold", DodgerBlue);
   ObjectSet("x2b", OBJPROP_CORNER, 1);
   ObjectSet("x2b", OBJPROP_BACK, 0);
   ObjectSet("x2b", OBJPROP_XDISTANCE, Adjust_Side_to_side + 7);
   ObjectSet("x2b", OBJPROP_YDISTANCE, Shift_UP_DN + 10);   
}   
  
   return(0);
}
//+------------------------------------------------------------------+
void ProcessOctaves(double& zfL, double& zfH, int o_mode) {
   double s_price=0,e_limit_L=0,e_limit_H=0;
   int i=0,s_bar=0,e_bar=0,g=0,bars_xframe_total=0,ul_frame=0;
   string eVar,fVar,sMessage,sSubject;
   datetime p_frame_start,e_Time; 
   bool lclc=false;
   e_Time = CurTime(); 
   /// auto jump fix... now using previous frame to start counting
   bars_xframe_total=(TradingFrame*1440)/Period();  // total bars in frame
   //////////////////////////////////////////////////////////////////////////
   s_bar = iBarShift(Symbol(),Period(),BlockStart)+ bars_xframe_total;
   if (BlockEnd < CurTime()) { e_bar=iBarShift(Symbol(),Period(),BlockEnd); }
   s_price = iClose(Symbol(),Period(),s_bar); // frame opening price
   GetOctaveLimit(e_limit_L,e_limit_H,zfL,zfH,s_price,o_mode,lclc,ul_frame); // opening octave limits
   // scan for changes
   i=s_bar;
   while (i > e_bar) {
      s_price = iClose(Symbol(),Period(),i);
      if (s_price > e_limit_H || s_price < e_limit_L) {
         lclc=true; g++; if (s_price > e_limit_H) { ul_frame=1; } if (s_price < e_limit_L) { ul_frame=-1; }
      } else { g=0; }
      if (g >= Octave_Limit_Bar_Count) {
         g=0; GetOctaveLimit(e_limit_L,e_limit_H,zfL,zfH,s_price,o_mode,lclc,ul_frame); // recalculate octave limits
      }
      i--;
   }
   return(0);
}
//+------------------------------------------------------------------+
void GetOctaveLimit(double& limitL, double& limitH, double& xfL, double& xfH, double xprice, int o_mode, bool lm_calc, int ul_fm) {
   double tf_factor=0,octave_mid=0,one_eight=0,octave_L=0,octave_H=0,xmml=0;
   int octave_jump=ul_fm; 
   // default Plus_Minus_Limit_Level 
   if (Plus_Minus_Eighth_Limit_Level == 1 || Plus_Minus_Eighth_Limit_Level == 2 ) {
   } else { Plus_Minus_Eighth_Limit_Level = 1; } 
   // Octave Modes_.. no range calculations
   if (o_mode==1 || o_mode==2 || o_mode==3) {
      // TF adjustment
      if (TradingFrame==4) { tf_factor = 8; }
      if (TradingFrame==8) { tf_factor = 6; }
      if (TradingFrame==16) { tf_factor = 4; }
      if (TradingFrame==32) { tf_factor = 3; }
      if (TradingFrame==64) { tf_factor = 2; }
      if (TradingFrame==128) { tf_factor = 1.5; }
      if (TradingFrame==256) { tf_factor = 1; }
      if (o_mode==2) {
         if (TradingFrame==8) { tf_factor = 4; }
         if (TradingFrame==32) { tf_factor = 2; }
         if (TradingFrame==128) { tf_factor = 1; }
      } 
      if (o_mode==3) { tf_factor=AutoTF3; }
      if (lm_calc) {
         /// octave jump
         xmml = ((xfH-xfL)/2);
         xfH += (octave_jump * xmml);
         xfL += (octave_jump * xmml);
         ///////////////////////////////////////////////
      } else {   
         octave_L = (MathFloor(xprice/(fractal/(128*tf_factor)))*(fractal/(128*tf_factor)));
         octave_H = (MathCeil(xprice/(fractal/(128*tf_factor)))*(fractal/(128*tf_factor)));
         xfL = octave_L;  xfH = octave_H;
      }
   }
   if (o_mode==4) {
      octave_L = (MathFloor(xprice/(fractal/128))*(fractal/128));
      octave_H = (MathCeil(xprice/(fractal/128))*(fractal/128));
      xfL = octave_L;  xfH = octave_H;
   }
   one_eight = (xfH-xfL)/8; mp_a=one_eight*0.6666;
   if (!mp_Alpha) {
      limitL = xfL-(one_eight*Plus_Minus_Eighth_Limit_Level);   // -1/8 or - 2/8
      limitH = xfH+(one_eight*Plus_Minus_Eighth_Limit_Level);   // +1/8 or + 2/8
   } else {
      limitL = xfL-(one_eight*Plus_Minus_Eighth_Limit_Level)-mp_a;   // -1/8 or - 2/8
      limitH = xfH+(one_eight*Plus_Minus_Eighth_Limit_Level)+mp_a;   // +1/8 or + 2/8
   }
   return(0);
}
//+------------------------------------------------------------------+
string TimeC(int elevel) {
   double one_eighth_t=0;
   string lbl;
  
   one_eighth_t= (TradingFrame*1440)/8/8;
   one_eighth_t *= elevel;
   one_eighth_t *= Time_Expand_By;
   lbl= StringConcatenate(one_eighth_t,"m"," [",one_eighth_t/60,"h]"); 
   
   return (lbl);
}
//+------------------------------------------------------------------+
void DrawFranka(string fname, double fvalue, int fstyle, int fwidth, color fcolor) {
   ObjectDelete(fname);
   ObjectCreate(fname, OBJ_TREND,0, BlockEnd, fvalue, BlockStart, fvalue);
   ObjectSet(fname, OBJPROP_COLOR, fcolor);
   ObjectSet(fname, OBJPROP_STYLE, fstyle);
   ObjectSet(fname, OBJPROP_BACK, 1);
   ObjectSet(fname, OBJPROP_RAY, false);
   ObjectSet(fname, OBJPROP_WIDTH, fwidth);
   return(0);
}

//+------------------------------------------------------------------+
void Drawbml_33(string fname2, double fvalue2, int fstyle2, int fwidth2, color fcolor2) {
   ObjectDelete(fname2);
   ObjectCreate(fname2, OBJ_TREND,0, BlockEnd, fvalue2, BlockStart, fvalue2);
   ObjectSet(fname2, OBJPROP_COLOR, fcolor2);
   ObjectSet(fname2, OBJPROP_STYLE, fstyle2);
   ObjectSet(fname2, OBJPROP_BACK, 1);
   ObjectSet(fname2, OBJPROP_RAY, false);
   ObjectSet(fname2, OBJPROP_WIDTH, fwidth2);
   return(0);
}
//+------------------------------------------------------------------+
// Optimization function.... also facilitates frame alert checking
bool GridChange() {
   double p_top=0, p_bottom=0, fa_h=0, fa_l=0;
   datetime t_left, t_right;
   string global_p, global_t;
   bool lChange=False;
   // Get global values //////////////////////////////////////////////////
   global_p = StringConcatenate(Symbol(),Period(),"H",TradingFrame,"dataMML");
   global_t = StringConcatenate(Symbol(),Period(),"TF",TradingFrame,"data"); 
   p_top = GlobalVariableGet(StringConcatenate(global_p,12));  if (mp_Alpha) {p_top += mp_a; }
   p_bottom = GlobalVariableGet(StringConcatenate(global_p,0)); if (mp_Alpha) {p_bottom -= mp_a; }   
   t_left = GlobalVariableGet(StringConcatenate(global_t,0)); 
   t_right = GlobalVariableGet(StringConcatenate(global_t,8));
   fa_h = GlobalVariableGet(StringConcatenate(global_p,10));
   fa_l = GlobalVariableGet(StringConcatenate(global_p,2));    
   ///////////////////////////////////////////////////////////////////////////
   if (Close[1] >= p_top || Close[1] <= p_bottom) {
      lChange=True;
   }
   if (CurTime() >= t_right) {
      lChange=True;
   }
   ///////// Frame Alert checking ////////////////////////////////////////
   if (Close[0]<=(fa_l+one_eighth_v) || Close[0]>=(fa_h-one_eighth_v)) {   //optimize_.. run frame check only if first limit is reached (1/8,7/8)
      switch(Frame_Alert_Mode) {
         case 0:
            FrameAlert(fa_h, fa_l, 0); break;     // 0/8, 8/8
         case 1:
            FrameAlert(fa_h+one_eighth_v, fa_l-one_eighth_v, 1);  break;   //-1/8, +1/8
         case 2:
            FrameAlert(fa_h+(one_eighth_v*2), fa_l-(one_eighth_v*2), 2);  break;   //-2/8, +2/8
         case 3:
            FrameAlert(fa_h+(one_eighth_v*2)+mp_a, fa_l-(one_eighth_v*2)-mp_a, 3);  break;   //-2/8-mp_a, +2/8+mp_a
         default:
            FrameAlert(fa_h+one_eighth_v, fa_l-one_eighth_v, 1);    //-1/8, +1/8
      }
   }
   return (lChange);
}
//+------------------------------------------------------------------+
void FrameAlert(double lpriceh, double lpricel, int fmode) {
   double LastPrice_H=0, CurrentPrice_H=0,LastPrice_L=0, CurrentPrice_L=0;
   datetime email_time,popup_time;
   bool popup_elapsed=false; 
   bool email_elapsed=false;
   string sSubject,sMessage,leveldesc,lsign;
   
   // Get Last alert times
   popup_time=GlobalVariableGet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastPopUpTime"));
   email_time=GlobalVariableGet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastEmailTime"));
   if ((CurTime()-popup_time) > PopUp_Alert_Interval_Secs) { 
      popup_elapsed=True;  
   }
   if ((CurTime()-email_time) > Email_Alert_Interval_Secs) { 
      email_elapsed=True;  
   } 
   if (!popup_elapsed && !email_elapsed) { return(-1); }
   
   // Messages 
   if (fmode==0) { leveldesc="/8th"; }
   if (fmode==1) { leveldesc="1/8th"; }
   if (fmode==2) { leveldesc="2/8th"; }
   if (fmode==3) { leveldesc="2/8th|Hm."; }
   sSubject=StringConcatenate("Trade Alert: ",TimeToStr(LocalTime(),TIME_DATE|TIME_MINUTES));
   if (Enable_Wick_High_Low_Alert) {       
      LastPrice_L = iLow(NULL, 0, 1); LastPrice_H = iHigh(NULL, 0, 1);
      CurrentPrice_L = iClose(NULL, 0, 0);  CurrentPrice_H = iClose(NULL, 0, 1);
   } else {
      LastPrice_H = iClose(NULL, 0, 1);  LastPrice_L=LastPrice_H;
      CurrentPrice_H = iClose(NULL, 0, 0);  CurrentPrice_L=CurrentPrice_H;
   }
   if((LastPrice_L < lpricel) && (CurrentPrice_L >= lpricel)) {
      if (fmode==0) { lsign="0"; } else { lsign="-"; }
      sMessage=StringConcatenate(Symbol()," ",Period(),"m: Price crossing ",lsign,leveldesc, "@ ",DoubleToStr(lpricel,Digits),"; Frame Range = ",one_eighth_v*8);
      if(PopUp_Alert_On && popup_elapsed) { Alert(sMessage); }
      if(Email_Alert_On && email_elapsed) { SendMail(sSubject, sMessage); }
      GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastPopUpTime"), CurTime());
      GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastEmailTime"), CurTime());
   }
   
   if((LastPrice_H > lpriceh) && (CurrentPrice_H <= lpriceh)) {
      if (fmode==0) { lsign="8"; } else { lsign="+"; }
      sMessage=StringConcatenate(Symbol()," ",Period(),"m: Price crossing ",lsign,leveldesc, "@ ",DoubleToStr(lpriceh,Digits),"; Frame Range = ",one_eighth_v*8);
      if(PopUp_Alert_On && popup_elapsed) { Alert(sMessage);  }
      if(Email_Alert_On && email_elapsed) { SendMail(sSubject, sMessage); }
      GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastPopUpTime"), CurTime());
      GlobalVariableSet(StringConcatenate(Symbol(),Period(),TradingFrame,"LastEmailTime"), CurTime());
   }
   return(0);
}
//+------------------------------------------------------------------+
bool InList(int lsearch, int larray[]) {
   int i=0,la=0; bool lfound=false;
   la=ArraySize(larray);
   while (i < la) {
      if (lsearch==larray[i]) { lfound=True; }
      i++;
   }
   return (lfound);
}
//+------------------------------------------------------------------+
void selectMMdraw(int hidemm, int &mma[]) {
   if (hidemm==1) {
      mma[0]=0;  mma[5]=99; mma[9]=99;
      mma[1]=99; mma[6]=6;  mma[10]=10;
      mma[2]=2;  mma[7]=99; mma[11]=99;
      mma[3]=99; mma[8]=8;  mma[12]=12;
      mma[4]=4;
   }
   if (hidemm==2) {
      mma[0]=0;  mma[5]=99; mma[9]=99;
      mma[1]=99; mma[6]=6;  mma[10]=10;
      mma[2]=2;  mma[7]=99; mma[11]=99;
      mma[3]=99; mma[8]=99; mma[12]=12;
      mma[4]=99;
   }
   if (hidemm==3) {
      mma[0]=99; mma[5]=99; mma[9]=99;
      mma[1]=99; mma[6]=99; mma[10]=99;
      mma[2]=99; mma[7]=99; mma[11]=99;
      mma[3]=99; mma[8]=99; mma[12]=99;
      mma[4]=99;
   }
   return(0);
}
//+------------------------------------------------------------------+
   datetime HMAuto(datetime xHM_Date) {
   string base=StringSubstr(Symbol(),0,3);
   if(base=="AUD" || base=="NZD" || base=="CAD" || base=="USD") return(D'2011.09.12 08:00');
   else return(D'2011.09.12 08:00');//XARD...have set time to NY Close based on server London +1hr
   return(xHM_Date); }

/*
   if( TimeCurrent() <= StrToTime("2014.09.09 23:00") && TimeCurrent()> StrToTime("2013.09.19 23:00") )
     xHM_Date =D'2013.09.19 23:00';
   else
     if( TimeCurrent() <= StrToTime("2013.09.19 23:00") && TimeCurrent()> StrToTime("2012.09.30 23:00") )
     xHM_Date =D'2012.09.30 23:00';
   else
     if( TimeCurrent() <= StrToTime("2012.09.30 08:00") && TimeCurrent()> StrToTime("2011.09.12 08:00") )
     xHM_Date =D'2011.09.12 08:00';
   else
     if( TimeCurrent() <= StrToTime("2011.09.12 23:00") && TimeCurrent()> StrToTime("2010.09.23 23:00") )
     xHM_Date =D'2010.09.23 23:00';
   else
     if( TimeCurrent() <= StrToTime("2010.09.15 23:00") && TimeCurrent()> StrToTime("2009.10.04 23:00") )
     xHM_Date =D'2009.10.04 23:00';
   else
     if( TimeCurrent() <= StrToTime("2009.10.04 23:00") && TimeCurrent()> StrToTime("2008.09.15 23:00") )
     xHM_Date =D'2008.09.15 23:00'; 

//NB Time adjusted to 10pm London = 5pm NY....Xard777 allowing for +1hr server time
//NB Time adjusted to 07am London Session.... Xard777 allowing for +1hr server time
  */ 
   
 
//+------------------------------------------------------------------+
//The end.....

/// Functions removed from TF library v0.3 ////////////////////////////////////////

string DHM(datetime ztime, bool extended,bool lseconds=False) {
   double seconds_xdays=1440*60;
   double seconds_xhours=60*60;
   double seconds_xminutes=60;
   double seconds_x=0;
   double tempcalc=0;
   int xdays=0;
   int xhours=0;
   int xminutes=0;
   double sectime = ztime - 0;
   string rtime="",xd="",xh="",xm="",xs="";
   
   xdays = sectime/seconds_xdays;
   tempcalc = MathMod(sectime,seconds_xdays); // hours remaining
   xhours = tempcalc/seconds_xhours;
   tempcalc = MathMod(tempcalc,seconds_xhours); // minutes remaining
   xminutes = tempcalc/seconds_xminutes;
   tempcalc = MathMod(tempcalc,seconds_xminutes); // seconds remaining
   seconds_x = tempcalc;
   
   if (extended) {
      xd = TextAllign(StringConcatenate(xdays,"days"),"Right",7);
      xh = TextAllign(StringConcatenate(xhours,"hrs"),"Right",7);
      xm = TextAllign(StringConcatenate(xminutes,"min"),"Right",7);
      if (lseconds) { xs = TextAllign(StringConcatenate(seconds_x,"s"),"Right",4); }
      rtime = StringConcatenate(xd,xh,xm,xs);
   } else {
      xd = TextAllign(StringConcatenate(xdays,"d"),"Right",4);
      xh = TextAllign(StringConcatenate(xhours,"h"),"Right",4);
      xm = TextAllign(StringConcatenate(xminutes,"m"),"Right",4);
      if (lseconds) { xs = TextAllign(StringConcatenate(seconds_x,"s"),"Right",4); }
      rtime = StringConcatenate(xd,xh,xm,xs);
   }
   return (rtime);
}

string TextAllign(string ltext,string position,int psize) {
   string pstring;
   int xsize=0;
   
   pstring =ltext;
   if (psize != 0) { 
      pstring = StringTrimRight(StringTrimLeft(ltext));
      xsize = StringLen(pstring);
      if (position=="Left") {
         pstring= StringConcatenate(pstring,Space(MathAbs(psize-xsize)));
      }
      if (position=="Right") {
         pstring= StringConcatenate(Space(MathAbs(psize-xsize)),pstring);
      }
      if (position=="Center") {
         pstring= StringConcatenate(Space(MathAbs(psize-xsize)/2),pstring,
              Space(MathAbs(psize-xsize)/2));
      }
   }
   return (pstring);
}  

string Space(int slen) {
   int i=0;
   string stext="";
   
   while (i < slen) {
      stext=StringConcatenate(stext,CharToStr(32));
      i++;
   }
   return (stext);
}

////////////////////////////////////////////////////////////////////////////////////////////

Комментарии к исходному коду форекс индикатора !MT4 TF DUO.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.

  • X
  • 0% загружено
« индикатор !ForbiARROWS-1.02.mq4
индикатор !MTH Renko Chart Builder Indi Ver 03.mq4 »