Download MetaTrader 5

How to hide bars of certain period of time?

To add comments, please log in or register
Ricky
128
Ricky  
My mt4 is using Eastern standard time so london opens at 4pm and close at 11.30pm what i want to do is to hide 11.31pm to 3.59pm bars how to do that??
gordon
2326
gordon  
ricx:
My mt4 is using Eastern standard time so london opens at 4pm and close at 11.30pm what i want to do is to hide 11.31pm to 3.59pm bars how to do that??
Even if it's possible it would result in a large gap in the chart (between those hours), since the time axis is fixed (only scaling can be changed). I am guessing u don't want that...
whroeder1
16324
whroeder1  
ricx:
My mt4 is using Eastern standard time so london opens at 4pm and close at 11.30pm what i want to do is to hide 11.31pm to 3.59pm bars how to do that??

Option one is to use offline charts and remove the periods. Search for Constant Range Bars and Renko Charts.

Option two is to simply draw a rectangle over the area

//+------------------------------------------------------------------+
//| Adjust variables for a new bar.                                  |
//+------------------------------------------------------------------+
double  Tokyo.channel.high, Tokyo.channel.low,                      // openNew
//      H.H,    L.L,    ATR.value;                                  // setDIR
void    NewBar(){
    /*++++ Tokyo Channel*/{                                         datetime
    TimeUTC             = Time[0] + Server.Time.To.UTC,
    TimeUTC0000         = TimeUTC - (TimeUTC) % 86400,              // 24*60*60
    TimeWellingtonOpen  = TimeUTC0000 + 79200 - Server.Time.To.UTC, // 22*60*60
    TimeNYmidnight      = TimeWellingtonOpen + 21600; /*6Hr 22..4 GMT*/
    while(                TimeNYmidnight      > Time[0]     // In the past only.
         || TimeDayOfWeek(TimeNYmidnight)     > 5           // Market is closed
         || TimeDayOfWeek(TimeWellingtonOpen) > 5 ){        // Saturdays
            TimeWellingtonOpen -= 86400;    TimeNYmidnight -= 86400;    }
    int TKcPeriod       = MathMin( PERIOD_H1, Period() ),
        TKcStart        = iBarShift(NULL,TKcPeriod, TimeWellingtonOpen),
        TKcEnd          = iBarShift(NULL,TKcPeriod, TimeNYmidnight-1),
        TKcLength       = TKcStart - TKcEnd + 1;
    Tokyo.channel.high  = High[Highest(NULL,TKcPeriod, MODE_HIGH, TKcLength, TKcEnd)];
    Tokyo.channel.low   =  Low[ Lowest(NULL,TKcPeriod, MODE_LOW,  TKcLength, TKcEnd)];
    if (Show.Objects){                                  #define WINDOW_MAIN 0
        static string   TKcRect = "Tokyo Channel";                             {
        if(!(ObjectMove(TKcRect, 0, TimeWellingtonOpen, Tokyo.channel.high)
          && ObjectMove(TKcRect, 1, TimeNYmidnight - 1, Tokyo.channel.low )))
            if (!ObjectCreate( TKcRect, OBJ_RECTANGLE, WINDOW_MAIN
                             , TimeWellingtonOpen, Tokyo.channel.high
                             , TimeNYmidnight - 1, Tokyo.channel.low))    Alert(
                "ObjectCreate(", TKcRect, "Rectangle) failed: ",GetLastError());
            else if (!ObjectSet( TKcRect, OBJPROP_COLOR, Color.TKc ))   Alert(
                "ObjectSet(", TKcRect, "Color) [1] failed: ", GetLastError()); }
        static string   TKcWell = "Wellington Opens";                          {
        if(!ObjectMove( TKcWell, 0, TimeWellingtonOpen, EMPTY ))
            if (!ObjectCreate( TKcWell, OBJ_VLINE, WINDOW_MAIN
                             , TimeWellingtonOpen, EMPTY))              Alert(
                "ObjectCreate(", TKcWell, "Vline) [1] failed: ",GetLastError());
            else if (!ObjectSet( TKcWell, OBJPROP_COLOR, Color.TKc ))   Alert(
                "ObjectSet(", TKcWell, "Color) [4] failed: ", GetLastError()); }
        static string   TKcNYMid= "NY Midnight";                               {
        if(!ObjectMove( TKcNYMid, 0, TimeNYmidnight, EMPTY ))
            if (!ObjectCreate( TKcNYMid, OBJ_VLINE, WINDOW_MAIN, TimeNYmidnight
                             , EMPTY))                                  Alert(
                "ObjectCreate(", TKcNYMid, "Vline) [2] failed: ",GetLastError());
            else if (!ObjectSet( TKcNYMid, OBJPROP_COLOR, Color.TKc ))  Alert(
                "ObjectSet(", TKcNYMid, "Color) [5] failed: ", GetLastError());}
    }
    /*---- Tokyo Channel*/}
Ricky
128
Ricky  

Thank you guys, i tried to write the code for this :)

https://forum.mql4.com/37482#404944

To add comments, please log in or register