TRUE Forex

Просмотр кода форекс индикатора !XARD TIMEFRAME.mq4

// +----------------------------------------------------------------------------------------+ //
// |                                      !XARD TIMEFRAME  \¦/                              | //
// |                            Knowledge of the ancients (т у)                             | //
// |_________________________________________________o0o___(_)___o0o________________________| //
// |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____|_____| //
// |                                                                                XARD777 | //
// |----------------------------------------------------------------------------------------| //
// | Programming language:     MQL4                                                         | //
// | Development platform:     MetaTrader 4                                                 | //
// |          End product:     Indicator for MetaTrader 4 designed                          | //
// |                           for Build 226 (current version)                              | //
// +----------------------------------------------------------------------------------------+ //

#property indicator_chart_window
/*#import "TimeFrameLib-v0.3.ex4"
   string DHM(datetime ztime, bool extended,bool lseconds=False);
   string TextAllignS(string ltext,string position,int psize,int cChar);
#import*/
//+------------------------------------------------------------------+
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 02:00';
bool       intra.day.lines       =  False;
int        Day.Offset            =  0;
int        TL.Line.Size          =  1;
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    =  false;
extern color      MM2Color       =  C'85,0,0';
extern color      MMColor        =  C'0,85,0';
extern color      MM3Color       =  C'0,0,85';
//+------------------------------------------------------------------+
extern color      PlusMinus2.8   =  Red;
extern color      PlusMinus1.8   =  Orange;
extern color      ZeroEight.8    =  DodgerBlue;
extern color      OneSeven.8     =  Yellow;
extern color      TwoSix.8       =  HotPink;
extern color      ThreeFive.8    =  Lime;
extern color      Four.8         =  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      =  1;
int               bml.33.Width      =  1;
extern color      bml.33.Color2     =  C'60,40,100';

bool              mp.Alpha          =  true;
bool              Franka.Lines      =  true;
int               Franka.Style      =  1;
int               Franka.Width      =  1;
color             Franka.Color2     =  OrangeRed;
//+------------------------------------------------------------------+
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.5; TradingFrame=1; break;
         case 5 :     AutoTF3=0.5; TradingFrame=4; break;
         case 15 :    AutoTF3=0.5; TradingFrame=4; break;
         case 30 :    AutoTF3=0.25; TradingFrame=4; break;
         case 60 :    AutoTF3=0.25; TradingFrame=8; break;
         case 240 :   AutoTF3=0.1250; TradingFrame=32; break;
         case 1440 :  AutoTF3=0.0625; TradingFrame=128; break;
         case 10080 : AutoTF3=0.015625; TradingFrame=512; break;//TradingFrame=512 or 1024
         case 43200 : AutoTF3=0.015625; TradingFrame=512; break;//TradingFrame=1024 or 2048
      }
   }
  ////////////////////////////////// 
  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("X TF 2009");
   //---- 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] = 2;
   mml_wdth[3] = 1;
   mml_wdth[4] = 1;
   mml_wdth[5] = 1;
   mml_wdth[6] = 2;
   mml_wdth[7] = 1;
   mml_wdth[8] = 1;
   mml_wdth[9] = 1;
   mml_wdth[10] = 2;
   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 Bold", mml_clr[i]);
               } else {
                  ObjectSetText(buff_str, ln_txt[i]+DoubleToStr(mml[i],DecNos)+sConv, Font.Size, "Arial Bold", 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 = 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) {
   if( TimeCurrent() <= StrToTime("2014.09.09 9:00") && TimeCurrent()> StrToTime("2013.09.19 9:00") )
     xHM.Date =D'2013.09.19 9:00';
   else
     if( TimeCurrent() <= StrToTime("2013.09.19 9:00") && TimeCurrent()> StrToTime("2012.09.30 9:00") )
     xHM.Date =D'2012.09.30 9:00';
   else
     if( TimeCurrent() <= StrToTime("2012.09.30 9:00") && TimeCurrent()> StrToTime("2011.09.12 9:00") )
     xHM.Date =D'2011.09.12 9:00';
   else
     if( TimeCurrent() <= StrToTime("2011.09.12 9:00") && TimeCurrent()> StrToTime("2010.09.23 9:00") )
     xHM.Date =D'2010.09.23 9:00';
   else
     if( TimeCurrent() <= StrToTime("2010.09.15 9:00") && TimeCurrent()> StrToTime("2009.10.04 9:00") )
     xHM.Date =D'2009.10.04 9:00';
   else
     if( TimeCurrent() <= StrToTime("2009.10.04 9:00") && TimeCurrent()> StrToTime("2008.09.15 9:00") )
     xHM.Date =D'2008.09.15 9:00'; 

//NB Time adjusted to 12am....Xard777 allowing for +2hr server time
   
   
   
   return (xHM.Date);
//+------------------------------------------------------------------+   
}



//+------------------------------------------------------------------+
//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);
}

/*
                                                            
                                                          
                              ud$$$**$$$$$$$bc.                          
                          u@**"        4$$$$$$$Nu                       
                        J                ""#$$$$$$r                     
                       @                       $$$$b                    
                     .F                        ^*3$$$                   
                    :% 4                         J$$$N                  
                    $  :F                       :$$$$$                  
                   4F  9                       J$$$$$$$                 
                   4$   k             4$$$$bed$$$$$$$$$                 
                   $$r  'F            $$$$$$$$$$$$$$$$$r                
                   $$$   b.           $$$$$$$$$$$$$$$$$N                
                   $$$$$k 3eeed$$b    XARD777."$$$$$$$$$                
    .@$**N.        $$$$$" $$$$$$F'L $$$$$$$$$$$  $$$$$$$                
    :$$L  'L       $$$$$ 4$$$$$$  * $$$$$$$$$$F  $$$$$$F         edNc   
   @$$$$N  ^k      $$$$$  3$$$$*%   $F4$$$$$$$   $$$$$"        d"  z$N  
   $$$$$$   ^k     '$$$"   #$$$F   .$  $$$$$c.u@$$$          J"  @$$$$r 
   $$$$$$$b   *u    ^$L            $$  $$$$$$$$$$$$u@       $$  d$$$$$$ 
    ^$$$$$$.    "NL   "N. z@*     $$$  $$$$$$$$$$$$$P      $P  d$$$$$$$ 
       ^"*$$$$b   '*L   9$E      4$$$  d$$$$$$$$$$$"     d*   J$$$$$r   
            ^$$$$u  '$.  $$$L     "#" d$$$$$$".@$$    .@$"  z$$$$*"     
              ^$$$$. ^$N.3$$$       4u$$$$$$$ 4$$$  u$*" z$$$"          
                '*$$$$$$$$ *$b      J$$$$$$$b u$$P $"  d$$P             
                   #$$$$$$ 4$ 3*$"$*$ $"$'c@@$$$$ .u@$$$P               
                     "$$$$  ""F~$ $uNr$$$^&J$$$$F $$$$#                 
                       "$$    "$$$bd$.$W$$$$$$$$F $$"                   
                         ?k         ?$$$$$$$$$$$F'*                     
                          9$$bL     z$$$$$$$$$$$F                       
                           $$$$    $$$$$$$$$$$$$                        
                            '#$$c  '$$$$$$$$$"                          
                             .@"#$$$$$$$$$$$$b                          
                           z*      $$$$$$$$$$$$N.                       
                         e"      z$$"  #$$$k  '*$$.                     
                     .u*      u@$P"      '#$$c   "$$c                   
              u@$*"""       d$$"            "$$$u  ^*$$b.               
            :$F           J$P"                ^$$$c   '"$$$$$$bL        
           d$$  ..      @$#                      #$$b         '#$       
           9$$$$$$b   4$$                          ^$$k         '$      
            "$$6""$b u$$                             '$    d$$$$$P      
              '$F $$$$$"                              ^b  ^$$$$b$       
               '$W$$$$"                                'b@$$$$"         
                                                        ^$$$*  
*/

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

  • X
  • 0% загружено
« индикатор !X-UK.TREND.mq4
индикатор !XPS FX OBOS.mq4 »