Navigation´╝ÜHome > Content >

#2_Access_Panel_(Black).mq4

Time: 2018-05-05 | Download file:#2_Access_Panel_(Black).mq4

//+-------------------------------------------------------------------------------------------+
//|                                                                                           |
//|                                      Access Panel.mq4                                     |
//|                                                                                           |
//+-------------------------------------------------------------------------------------------+
#property copyright "Copyright @ 2015 traderathome, caveman, pips4life"
#property link      "email: traderathome@msn.com"
#property strict
/*---------------------------------------------------------------------------------------------
User Notes:

This Access Panel indicator is coded to run on MT4 Build 600+.  It provides improved charting
features and displays, which are listed below.  It is imperative to "set up" this indicator
as described in the "Preface" immediately below.  Complete this "set up" before using this
indicator!

The "Preface" Input-

     Broker time is required by the code that features PivotsTz and vLines.  When data feed
     is live the broker time is available.  When data feed is not live it is not available.
     The purpose of this "Preface" section is to find and input the Clock location that has
     the same time as the broker server.  Then, even without live data feed we will still
     have the equivalent of the broker server time to work with, generated by the Clock, and
     the PivotsTz and vLines will always display properly.  Perform the following steps.

     When there is live data feed use the Clock to find the Clock time zone location matching
     the broker server time.  Change "Clock_Normal_vs_Find_Server" to "false".  The Clock will
     display "B" (for broker server) at the time zone location matching the broker server time.
     You can populate the Clock with all labels to find "B" (see Clock instructions below).
     Chances are the labels needed are already displayed.  If "B" shows in the "London" label
     things are not so clear because London time is GMT during the non-DST time of the year
     (winter in northern hemisphere).  During that time we can not tell from the Clock if the
     broker server is on GMT or on London time all year.  Call your broker to find out.

     You now have the Clock Proxy Server TZ location, either from the Clock or your broker.
     Type this location name, exactly as it appears in the Clock, into the Preface input called
     "Clock_Proxy_Server_Tz_Location".  Now change "Clock_Normal_vs_Find_Server_Tz" back to
     "true" for normal operation.  You have successfully completed the steps to assure the
     correct and 24/7 display of PivotsTz and market vLines.  This indicator adjusts for DST
     changeovers when they occur twice yearly, which happens at different times at different
     places.  This is fully automated.  No adjustments for DST are required by the user.

     The default "Clock_Proxy_Server_Tz_Location" is "Helsinki" because it is the most popular
     time zone used for broker servers.  If this is not the time zone your broker server uses,
     then PivotsTz and vLines will display incorrectly.  So, be sure you follow the steps
     above to confirm this default selection is correct, and if not then to find and input
     the correct Clock Proxy Server TZ location.  Without an input this indicator will not
     function.  Be sure that "Clock_Normal_vs_Find_Server" is "false" only when searching for
     the Clock Proxy Server TZ location.  It must be "true" for normal indicator operation.

Preview of the Displayed Access Panel and Other Indicator Features-
This indicator places an Access Panel in the upper left corner of the chart, consisting of
a Market Panel and a Clock Panel.  For proper display chart/Properites/Common/Show OHLC should
be unchecked.
   1. The Market Panel:
      The Market Panel can be turned on/off.  When it is turned on it displays the items
      listed below, and you can also show the Clock Panel when the Market Panel is on:
      (1) Symbol & Period:  The symbol for the currency pair and the chart TF.
      (2) Spread: The difference (cost to trade) between the Ask and the Bid price.
      (3) Ranges: The weekly and daily average ranges.
      (4) Swaps:  The long and the short swap rates.
      (5) Candle: The time remaining for the chart current TF bar.
      (6) Price:  The bid price of either currency or non-currency items.  For currencies,
          the last (fractional) digit can be set to appear smaller than the other digits.
          The price changes color when the last full size digit reverses.
      (7) The Logo.
   2. The Clock Panel:
      When the Market Panel is on the Clock Panel can be turned on/off.  It displays time and
      location for seven different time zones that can be selected out of a list of time zones
      available.  It is also used during a time of live feed to determine the difference
      between the broker server time and GMT, which is an input that must be entered manually
      in the "Preface" section of the External Inputs.  If a time zone displayed happens to
      coincide with the broker server time, your local time, GMT, or the time zone selected
      for the calculation of pivots (if pivots are displayed), an extension to the label will
      include the designators: "B", "L", "G" and "P" so you do not have to waste lines to also
      separately display the Broker, Local and GMT time zones.

In addition to the two panel sections, this multi-function indicator provides the following
services, which are listed here, and more fully described below:
   1. A special Ask line and a special Bid line.
   2. A background of level lines dividing the distance between whole numbers into quarters.
   3. Natural fibonacci numbers applied to the previous day range as well as above and below.
   4. Daily or Fibonacci pivots, including mid-pivot lines.
   5. Average Range H/L lines for the week and day.
   6. Day Separators.
   7. Vertical lines at the open of the Asian, Frankfurt, London and New York forex markets,
      and at the close of the London market.

1. Special Ask and Bid Lines-
You can select to place your own Ask and Bid Ray lines on the chart, which you can vary in
thickness and color.  The lines end just beyond the current candle.  The Bid line terminates
with a Bid Dot that can be sized and that changes color(example: green/red) as the bid price
changes(up/dn).  To display only your own Ask/Bid Ray lines, right click on the chart and
select Chart Properties/Colors.  Make sure the Grid color = "None", otherwise the MT4 bid
line is going to be beneath your own, and will be visible from the end of your line to the
chart edge.  The special Ask and Bid lines can be subordinated to appear below other chart
artifacts, such as the candles and the SonicR Dragon-Trend.  You can set the Ask line to not
show above a chosen chart TF.  By default, the Ask line is set to not show above the M5 TF.
There are other options.  Read the External Inputs.

2. Background Level Lines-
This indicator places level lines on your chart at key levels between whole numbers (00, 25,
50, 75 and 00 again).  The number of "sets" of these Whole, Half, and Quarter lines is fixed
by hard code for each TF chart.  The lines can individually be of any available color, style
and width.  With Levels "On", the half and quarter levels can be turned On/Off individually.
The whole, half and quarter levels also have separate "Max_TF" settings, which you can set so
the less significant Levels automatically cease to be displayed as you go up in chart TF.
The span between the Levels is 25 pips.  For some currency pairs and other traded instruments
this might mean the Levels lines are too close together or too far apart.  To adjust spacing
of the Level lines use "__Incr_Decr_Levels_Density" which by default is "0".  A change to
"1" will space the lines 50 pips apart.  A change to "2" will space the lines 75 pips apart.
A change to "3" will space the lines 100 pips apart, etc.  A change to "-1" will space lines
12.5 pips apart.  A change to "-2" will space lines 6.25 pips apart, etc. With the variety
of instruments available to trade, and with the manner in which the market has fixed their
pricing, there is no simple code that will automatically yield a better placement of lines.

3. Natural Fibos -
Fibonacci numbers are applied to the internal range of the previous day, as well as beyond,
both above and below that range.  The "yHI" and "yLO" lines are displayed from the start of
the previous day session.  The other lines are displayed for just the current day session.
An option called "__Use_Tz_Filter" (default is "false") diverts calculations to the time
zone shift coding in this indicator to find the correct start of the previous session
following partial days and holidays, which is the only time this option might be needed.
   A. These key fibonacci levels are applied to the internal range:
      yLO, 23.6, 38.2, 50.0, 61.8, 76.4 and yHI.
   B. These levels are applied beyond this range, both above and below:
      23.6, 38.2, 50.0, 61.8, 76.4, 100.0, 161.8, 261.8, 423.6 and 638.2.

4. Daily and Fibonacci Pivots -
   A. Main Pivot Line
      You can select to display the main pivot (PVT) for the day.  It can be constructed
      using two ines.  One can be a wide background line of a highlighting color and the
      other can be a narrow top line of a darker color (Examples: Yellow & Gray respectively).
   B. Support & Resistance Lines-
      You can select to display the support and resistance pivot lines (SR) using either the
      Daily or Fibonacci formulas.  The Fibonacci displays five levels.  Normally, the Daily
      displays only three levels, but is extended to include five levels.
   C. Broker or Time Zone Shifted Pivots
      You can display your broker server pivots, or you can select to display pivots based
      on a different time zone (PivotsTz).  New coding fully automates the complexities of
      PivotsTz, such as timing the hour shift for DST twice yearly, depending on when your
      broker does that.  Your choice to use PivotsTz requires only three simple inputs-
      I.   "__PivotsTz_On"
           Set this equal to "true".  If "false", then broker server pivots are displayed.
      II.  "____Use_Preferred_Offset"
           Set to "true" if you wish pivots displayed to be based on the Frankfurt time zone.
           if set to "false" the input for "____Alternative_GMT_Offset" will be used.
      III. "____Alternative_GMT_Offset"
           This is your alternative choice of time zone location relative to GMT in +/- hours
           (examples: for GMT use "0", for one time zone east of GMT use "1", and for four
           time zones west of GMT use "-4").
      When pivots are displayed, "P" will show in the appropriate Clock label matching the
      time zone the pivots are based on.  Realize that by choosing PivotsTz, when the next
      PivotsTz day occurs during the broker server day, the PivotsTz lines will suddenly
      change.   PivotsTz will display either "^", "<", or ">" in the labels for the lines.
      By default, PivotsTz are set to the preferred Frankfurt time zone and will display "^"
      in the labels.  If you select a PivotsTZ time zone less than the default "<" appears
      in the labels.  If you select a PivotsTZ time zone greater than the default ">" appears
      in the labels.  Broker pivots display nothing extra in the labels.

5. Range High/Low Lines for the Day and Week-
You can display two horizontal lines, one for the computed range high target, and one for
the computed range low target. The range is based on the averaging period you select
(defaults: day=15, week=13).  The special range averaging process for the Day range lines
skips any brief Sunday sessions of some brokers, which would drag the average down.  The
Week range lines use the standard ATR formula since brief Sunday sessions do not much affect
the results.
   A. Two conditions determine where range lines appear....
      1. Condition #1 - the Day/Week range has not exceeded the computed average range.
         * The RDH/RWH line is the computed average range distance above the session Low.
         * The RDL/RWL line is the computed average range distance below the session high.
         * The lines will move as new highs/lows are achieved during the session.
         * This display shows how far price can move in either direction before exceeding
           the computed average range.
      2. Condition #2 - the Day/Week range has exceeded the computed average range.
         * If price swings during the day/week TF cause the difference between the high and
           the low to equal the computed range, the range lines lock into place.
         * This display will clearly show any subsequent breakout of the range.
   B. The purpose of the range lines is to provide a perspective on how far PA might move 
      during the trading day or week.  This can be of some guidance in selecting where to
      exit a trade.  A swing trader might pay more attention to the RWH/RWL lines, and hold
      a trade into oncoming days.  However, a day trader looking for quick profits and
      limited exposure to market price swings might pay more attention to the RDH/RDL lines.
   C. The Day range lines are based on the broker's server trading day, but can be based
      on a trading day of a different time zone, just as are the pivots.  By default, the
      input "__RangeTZ_on" is set to "true" for this function.  The time zone used for the
      RangeTZ function is always the same one selected for the PivotsTZ function.  The
      day RangeTZ lines can be displayed even if PivotsTZ lines are not displayed.

6. Day Separators-
You can apply day separators to your chart with this option.  It lets you select color
and line styles.  You can elect to show separators just for today and/or for any number
of previous days.

7. Vertical Time Lines-
You can select to display vertical time lines for the London Open, New York Open, and the
London Close, with the option to also show the Asian/Sydney Open and the Frankfurt Open.
New coding in this release properly places these vLines without any special inputs required
from the user because it determines all year around the GMT offsets of the broker server,
Sydney, Frankfurt, London and NYC.  And the coding takes into account any changes at these
locations due to DST/nonDST changeovers when they are implemented, even if at different times
at each location.  This information is required to always have the vLines displayed on your
broker server chart at the places representing the proper local times in both London and NYC.
Separate External Inputs exist for control of the vLines for the Asian Open and the Frankfurt
Open.  Broker servers on GMT have very short partial days when the market opens for the week
such that maybe only the "Ao" line appears, providing little in the way of time perspective.
By using the External Inputs for "Ao" for both the current and the previous sessions you can
display the "Ao" from the previous Friday to create the missing perspective.

Addtitional Remarks On Displaying Horizontal Lines and Labels-
The horizontal line groups can be displayed differently, using display numbers "1" and "2" in
the section "Horizontal Lines Position Settings:"  If the selection number is outside the 1-2
range it will default to "2".  The line groups are: Levels, PVT (central pivot), SRM (support,
resistance and mid-pivots), and Range H/L lines for DAY/WK.
   "1" - Fullscreen: draws the lines across the chart and positions labels mid-chart.
   "2" - Session: draws the lines only thru the current session and positions labels at
         the start of current session until that moves off-chart.  Then labels are
         positioned mid-chart.
   "3" - This is not a selectable option, but it is hard coded so that if the lines are set
         to display for the current session and the chart is switched to the DAY TF or higher,
         the lines will display 7 TFs to the right from the current candle.

Additional Remarks on Displaying Horizontal Lines and vLines for Brokers at GMT-
Note that brokers at GMT will have a very short "extra" trading day, a brief two hours on
Sunday (from 5pm EST to 7pm EST).  During this time, horizontal lines selected to display
per "2", will appear as they were on the previous Friday and remain at the levels for Friday
until the short Sunday period ends.  The short Sunday period is actually the last two hours
of the Friday trading day.  The same goes for vLines.  They will appear during the short
Sunday period as they were on the previous Friday.

                                                                   - Traderathome, 05-30-2015
----------------------------------------------------------------------------------------------
Acknowlegements:
CaveMan - who generously devoted his time and programming skills to produce the PivotsTz time
          zone shift coding, designed to handle any situation involving gaps between trading
          days and/or partial trading days.
Kent    - for his "pips4life" P4L clock code to import and use time zone information.

----------------------------------------------------------------------------------------------
Suggested Settings:          White Chart              Black Chart

Panel Section-
Panel_Background_Color       C'238,238,242            C'025,025,025'
Symbol_And_TF_Color          Black                    C'208,208,208'
Spread_Color                 C'080,080,080'           C'120,120,120'
Swaps_Color                  C'080,080,080'           C'120,120,120'
Range_Color                  C'080,080,080'           C'120,120,120'
Candle_Time_Color            C'080,080,080'           C'120,120,120'
Bid_UP_Color                 C'026,132,039'           C'046,188,046'
Bid_DN_Color                 Crimson                  C'234,000,000'
Bid_Last_Digit_Normal        C'140,140,140'           C'100,100,100'
Bid_Last_Digit_Small         C'040,040,040'           C'160,160,160'
Logo                         C'046,055,169'           C'095,103,211'

Ask-Bid Line Section-
Ask_Ray_Color                DarkSlateGray            C'100,100,100'
Bid_Ray_Color                DarkSlateGray            C'100,100,100'
Bid_Dot_Up_Color             C'000,198,060'           Lime
Bid_Dot_Dn_Color             C'240,032,084'           Red
Bid_Dot_Mono_Color           Black                    White

Horizontal Line Labels Section-
Line_Labels_Color            MidnightBlue             DarkGray

Levels Section-
Whole_Number_Color           C'187,187,247'           C'028,051,089'
Half_Number_Color            C'152,220,164'           C'000,070,000'
Quarter_Number_Color         C'219,210,176'           C'064,049,028'

Fibos Section-
H_Fibo_Color                 C'078,091,186'           C'091,104,191'
M_Fibo_Color                 Black;                   C'113,111,125'
L_Fibo_Color                 C'200,079,079'           C'208,078,070'

Pivots Section-
DPV1_Back_Color              C'255,255,128'           CLR_NONE
DPV2_Top_Color               Black                    C'209,080,203'
R_Pivot_Color                C'064,064,255'           C'071,102,207'
S_Pivot_Color                C'255,053,017'           C'202,034,004'
MidPivot_Color               SaddleBrown              C'106,106,000'

Range Lines Section-
RDH_Color                    C'134,149,251'           C'107,107,220'
RDL_Color                    C'241,126,120'           C'214,072,065'
RWH_Color                    C'134,149,251'           C'091,091,217'
RWL_Color                    C'241,126,120'           C'208,060,055'

Separators Section-
Separators_Color             BlueViolet               C'085,085,085'

vLines Section-
vLines_Color                 Silver                   C'074,074,074'
vLabels_Color                MidnightBlue             Olive

Clock Section-
Clock_MktClosed              C'080,080,080'           C'120,120,120'
Location_MktClosed           C'080,080,080'           C'120,120,120'
Clock_MktOpen                C'133,084,035'           C'186,138,090'
Location_MktOpen             C'000,149,034'           C'046,186,046'
---------------------------------------------------------------------------------------------*/


//+-------------------------------------------------------------------------------------------+
//| Indicator Global Inputs                                                                   |
//+-------------------------------------------------------------------------------------------+
#property indicator_chart_window

#include 
//See function documentation at http://msdn.microsoft.com/en-us/library/ms725473(VS.85).aspx
#import "kernel32.dll"
void GetLocalTime(int& LocalTimeArray[]);
void GetSystemTime(int& systemTimeArray[]);
int  GetTimeZoneInformation(int& LocalTZInfoArray[]);
bool SystemTimeToTzSpecificLocalTime(int& targetTZinfoArray[],
     int& systemTimeArray[], int& targetTimeArray[]);
#import

//Global External Inputs-----------------------------------------------------------------------
extern bool   Indicator_On                         = true;
extern string Preface____________                  = "Find & enter Clock Proxy Server Tz Location.";
extern bool   Clock_Normal_vs_Find_Server          = true;
extern string Clock_Proxy_Server_Tz_Location       = "Helsinki";
extern string Preface_____________                 = "Read User Notes.  Contact your broker to confirm.";
extern string _                                    = "";
extern string Part_1                               = "Indicator Master Controls:";
extern bool   Show_Access_Panel                    = true;
extern bool   __Show_Logo_in_Panel                 = true;
extern bool   __Show_Clock_in_Panel                = true;
extern bool   Ask_Line_On                          = true;
extern int    __Ask_Max_TF                         = 15;
extern bool   Bid_Line_On                          = true;
extern bool   Levels_On                            = true;
extern bool   __Show_Half_Levels                   = true;
extern bool   __Show_Quarter_Levels                = true;
extern int    __Levels_Whole_Max_TF                = 1440;
extern int    __Levels_Half_Max_TF                 = 1440;
extern int    __Levels_Quarter_Max_TF              = 30;
extern int    __Incr_Decr_Levels_Density           = 0;
extern bool   Natural_Fibos                        = false;
extern bool   __Use_Tz_Filter                      = false;
extern int    __Fibos_Max_TF                       = 60;
extern bool   Pivots_Day_vs_Fibonacci              = true;
extern bool   __Pivots_PVT_On                      = false;
extern bool   __Pivots_SR_On                       = false;
extern bool   ____Pivots_Mid_Included              = true;
extern int    __Show_Levels_Thru_2345              = 5;
extern int    __PVT_Max_TF                         = 60;
extern bool   __PivotsTz_On                        = true;
extern bool   ____Use_Preferred_Offset             = true;
extern int    ____Alternative_GMT_Offset           = 0;
extern bool   Range_Day_On                         = true;
extern int    __Day_Max_TF                         = 1440;
extern bool   Range_Week_On                        = true;
extern int    __Week_Max_TF                        = 10080;
extern bool   Separators_On                        = false;
extern int    __Prior_Days_To_Show                 = 5;
extern int    __Separators_Max_TF                  = 60;
extern bool   vLines_On                            = true;
extern int    __Current_Session_Max_TF             = 60;
extern int    __Prior_Sessions_Max_TF              = 60;
extern int    __Prior_Sessions_To_Show             = 0;
extern bool   __Prior_Ao_with_Current_Session_only = false;
extern bool   __Ao_in_All_Sessions                 = true;
extern bool   __Fo_in_All_Sessions                 = true;
extern string TF_Choices                           = "1-5-15-30-60-240-1440-10080-43200";

extern string __                                   = "";
extern string Part_2                               = "Panel Settings:";
extern bool   Show_Forex_Fractional_Pip            = true;
extern int    __Shift_Fractional_Pip               = 0;
extern int    Days_In_Range_Day_Avg                = 15;
extern int    Weeks_In_Week_ATR                    = 13;
extern color  Panel_Background_Color               = C'025,025,025';
extern color  Symbol_And_TF_Color                  = C'208,208,208';
extern color  Spread_Color                         = C'120,120,120';
extern color  Range_Color                          = C'120,120,120';
extern color  Swaps_Color                          = C'120,120,120';
extern color  Candle_Time_Color                    = C'120,120,120';
extern color  Bid_UP_Color                         = C'046,188,046';
extern color  Bid_DN_Color                         = C'234,000,000';
extern color  Bid_Last_Digit_Normal                = C'100,100,100';
extern color  Bid_Last_Digit_Small                 = C'160,160,160';
extern color  Logo                                 = C'095,103,211';

extern string ___                                  = "";
extern string Part_3                               = "Ask-Bid Line Settings:";
extern color  Ask_Ray_Color                        = C'100,100,100';
extern int    Ask_Ray_LineStyle_01234              = 0;
extern int    Ask_Ray_Thickness                    = 1;
extern color  Bid_Ray_Color                        = C'100,100,100';
extern int    Bid_Ray_LineStyle_01234              = 0;
extern int    Bid_Ray_Thickness                    = 1;
extern bool   Subordinate_Ask_Bid_Lines            = true;
extern color  Ask_Dot_Color                        = Gainsboro;
extern int    Ask_Dot_Size                         = 6;
extern color  Ask_Dot_Cntr_Color                   = C'100,100,100';
extern int    Ask_Dot_Cntr_Size                    = 4;
extern color  Bid_Dot_Up_Color                     = Lime;
extern color  Bid_Dot_Dn_Color                     = Red;
extern color  Bid_Dot_Mono_Color                   = White;
extern bool   Use_Bid_Dot_Mono_Color               = false;
extern int    Bid_Dot_Size                         = 6;

extern string ____                                 = "";
extern string Part_4                               = "Horizontal Lines Position Settings:";
extern string note_4_0                             = "Choose line display number.";
extern string note_4_1                             = "1 = Fullscreen";
extern string note_4_2                             = "2 = Session";
extern int    Levels_Display_Number                = 1;
extern int    Pivots_Display_Number                = 2;
extern int    Ranges_Display_Number                = 2;
extern bool   Subordinate_Lines                    = true;

extern string _____                                = "";
extern string Part_5                               = "Horizontal Lines Labels Settings:";
extern bool   Pivot_PVT_Label_On                   = true;
extern bool   Pivot_SRM_Labels_On                  = true;
extern bool   Range_Labels_On                      = true;
extern color  Labels_Color                         = DarkGray;
extern bool   Subordinate_Labels                   = true;

extern string ______                               = "";
extern string Part_6                               = "Levels Settings:";
extern color  Level_Whole_Color                    = C'028,051,089';
extern int    Level_Whole_Style_01234              = 0;
extern int    Level_Whole_Width_12345              = 1;
extern color  Level_Half_Color                     = C'000,070,000';
extern int    Level_Half_Style_01234               = 0;
extern int    Level_Half_Width_12345               = 1;
extern color  Level_Quarter_Color                  = C'064,049,028';
extern int    Level_Quarter_Style_01234            = 0;
extern int    Level_Quarter_Width_12345            = 1;

extern string _______                              = "";
extern string Part_7                               = "Fibos Settings:";
extern color  H_Fibo_Color                         = C'091,104,191';
extern color  M_Fibo_Color                         = C'113,111,125';
extern color  L_Fibo_Color                         = C'208,078,070';
extern int    F_Style_01234                        = 0;
extern int    F_Width_12345                        = 1;
extern bool   Subordinate_Fibos                    = false;

extern string ________                             = "";
extern string Part_8                               = "Pivots Settings:";
extern color  PVT1_Back_Color                      = CLR_NONE;
extern int    PVT1_Style_01234                     = 0;
extern int    PVT1_Width_12345                     = 1;
extern color  PVT2_Top_Color                       = C'209,080,203';
extern int    PVT2_Style_01234                     = 2;
extern int    PVT2_Width_12345                     = 1;
extern color  R_Pivot_Color                        = C'071,102,207';
extern int    R_Style_01234                        = 2;
extern int    R_Width_12345                        = 1;
extern color  S_Pivot_Color                        = C'202,034,004';
extern int    S_Style_01234                        = 2;
extern int    S_Width_12345                        = 1;
extern color  MidPivots_Color                      = C'106,106,000';
extern int    mP_Style_01234                       = 2;
extern int    mP_Width_12345                       = 1;

extern string _________                            = "";
extern string Part_9                               = "Range Day Settings:";
extern color  RDH_Color                            = C'107,107,220';
extern color  RDL_Color                            = C'214,072,065';
extern int    RD_Style_01234                       = 0;
extern int    RD_Width_12345                       = 2;

extern string __________                           = "";
extern string Part_10                              = "Range Week Settings:";
extern color  RWH_Color                            = C'091,091,217';
extern color  RWL_Color                            = C'208,060,055';
extern int    RW_Style_01234                       = 0;
extern int    RW_Width_12345                       = 3;

extern string ___________                          = "";
extern string Part_11                              = "Separators Settings:";
extern color  Separators_Color                     = C'085,085,085';
extern int    Separators_Style_01234               = 2;
extern int    Separators_Width_12345               = 1;
extern bool   Separators_Thru_SubWindows           = true;

extern string ____________                         = "";
extern string Part_12                              = "vLines & Labels Settings:";
extern color  vLines_Color                         = C'074,074,074';
extern int    vLines_Style_01234                   = 2;
extern int    vLines_Width_12345                   = 1;
extern bool   vLines_Thru_SubWindows               = false;
extern bool   Sbow_vLabels                         = true;
extern color  vLabels_Color                        = Olive;

extern string _____________                        = "";
extern string Part_13                              = "Clock Settings:";
extern color  Clock_MktClosed                      = C'120,120,120';
extern color  Location_MktClosed                   = C'120,120,120';
extern color  Clock_MktOpen                        = C'186,138,090';
extern color  Location_MktOpen                     = C'046,186,046';
extern bool   Show_AMPM_Time                       = true;
extern string Note_12_1                            = "Choosing Locations to Display:";
extern string Note_12_2                            = "Select 7 maximum from list,";
extern string Note_12_3                            = "0 = display off.";
extern string Note_12_4                            = "1 = Display on.";
extern int    Broker                               = 0;
extern int    Local                                = 0; 
extern int    Auckland                             = 0;
extern int    Sydney                               = 1;
extern int    Tokyo                                = 1;
extern int    HongKong                             = 1;
extern int    Jakarta                              = 0;
extern int    India                                = 0;
extern int    Dubai                                = 0;
extern int    Moscow                               = 0;
extern int    Israel                               = 0;
extern int    Helsinki                             = 1;
extern int    Frankfurt                            = 1;
extern int 	  London                               = 1;
extern int    GMT                                  = 0;
extern int    Brazil                               = 0;
extern int    NewYork                              = 1;
extern int    Central                              = 0;
extern int    Mexico                               = 0;
extern int    Mountain                             = 0;
extern int    Pacific                              = 0;

//Buffers, Constants and Variables-------------------------------------------------------------
bool          Deinitialized;

//Deinit
int           obj_total,k;
string        name;

//Panel & Bid Line
color         Static_Price_Color, Static_Bid_Color, Bid_Dot_Color, Static_Bid_Dot_Color,
              Dot_Up_Color, Dot_Dn_Color;
double        Poin, Poin2,New_Price,Old_Price,level,Spread,ARg,RangeAchieved,
              dRange,wRange,dRG,wRG,pipValue,tic,size;
datetime      T1,T2;
int           Chart_Scale,modifier,Color,Factor,G1,G2,h,i,l,m,s,t,LP,LS;
string        item01 = "z[CP Panel] Box 1";
string        item02 = "y[CP Panel] Box 2";
string        item03 = "z[CP Text] ID&TF";
string        item04 = "z[CP Text] Spread";
string        item05 = "z[CP Text] Spread2";
string        item06 = "z[CP Text] Pip";
string        item07 = "z[CP Text] Pip2";
string        item08 = "z[CP Text] Range";
string        item09 = "z[CP Text] Range2";
string        item10 = "z[CP Text] Swap";
string        item11 = "z[CP Text] Swap2";
string        item12 = "z[CP Text] Price1";
string        item13 = "z[CP Text] Price2";
string        item14 = "z[CP Text] Logo1 S";
string        item15 = "z[CP Text] Logo1 o";
string        item16 = "z[CP Text] Logo1 n";
string        item17 = "z[CP Text] Logo1 i";
string        item18 = "z[CP Text] Logo1 c";
string        item19 = "z[CP Text] Logo1 R";
string        item20 = "d[CP Bid] Bid Line";
string        item21 = "e[CP Bid] Bid Dot";
string        item22 = "d[CP Ask] Ask Line";
string        item23 = "d[CP Ask] Ask Dot";
string        item24 = "e[CP Ask] Ask Dot Cntr";
string        ID,Price,C,tab,tab1,timeleft,Tic;

//Levels
color         linecolor;
double        linelevel, linestyle, linewidth, BL;
int           j,Line1_Color, Line2_Color, Line3_Color;
int           u1=00, u2=50, u3=25, u4=75;
int           v1, ssp, ssp1, NumberOfRanges;
string        linename;

//Fibos
bool          fib;
double        H10,H9,H8,H7,H6,H5,H4,H3,H2,H1,M1,M2,M3,M4,M5,FH,FL,FD,
              L1,L2,L3,L4,L5,L6,L7,L8,L9,L10;

//Pivots
datetime      pvtDT;
double        p,q,r1,r2,r3,r4,r5,s1,s2,s3,s4,s5;
double        today_high,today_low,today_open,today_close;
double        yesterday_high, yesterday_low, yesterday_open, yesterday_close;
int           Pdisplay,idxfirstbaryesterday,idxlastbaryesterday,idxfirstbartoday,idxbar,
              tzdiff,tzdiffsec,barsperday,dayofweektoday,dayofweektofind,Pivots_GMT_Offset;
//int            dtf1,dtf2,Hbarshift,Lbarshift;              
string        prefix;

//Range Day
datetime      d1,d2;
double        low,high,dRangeHigh,dRangeLow,HiToday,LoToday;
int           ii,iii,x,xx,r,dtf,Hbarshift,Lbarshift,rdc,rwc,Rdisplay,RDshift,idxbar2;

//Range Week
datetime      w1,w2;
double        week_open, HiWeek, LoWeek;
double        wRangeAvg, wRangeHigh, wRangeLow;
int           wtf, wHbarshift, wLbarshift, RWdisplay, RWshift;

//Horizontal Lines Placement
datetime      startline, stopline,T,T4;
int           a,b,c,R2;
string        line;

//Horizontal Labels Placement
datetime      startlabel;
string        label, spc;
string        FontStyle = "Verdana";
int           FontSize  = 7;

//vLines & Labels
datetime      T3, tme2, time4;
int           bps, MF, shift;
string        vLabels_Asian_Open       = "      Ao ";
string        vLabels_Berlin_Open      = "     F  ";
string        vLabels_London_Open      = "      Lo";
string        vLabels_NewYork_Open     = "     Ny";
string        vLabels_London_Close     = "      Lc ";
string        Label_Day_Separator      = "day";
string        vFontStyle               = "Verdana";
int           vFontSize                = 7;

//Get GMT Offsets in Support of PivotsTz and Market vLines
int           GMT_Ref_Time, Sydney_GMT_Offset, Berlin_GMT_Offset, London_GMT_Offset,
              NYC_GMT_Offset, GMT_At_Lo, GMT_At_NYo, GMT_At_Lc, GMT_At_Ao, GMT_At_Fo,
              Broker_GMT_Offset;

//Import Time Zone Data in Support of Clock, PivotsTz and Market vLines
bool          BKR_UTC_Match, FLAG_static_broker, Displaying_Pivots;
datetime      Local_Time,BrokerDT,AucklandDT,SydneyDT,TokyoDT,ChinaDT,JakartaDT,IndiaDT,
              DubaiDT,MoscowDT,IsraelDT,HelsinkiDT,BerlinDT,LondonDT,UTC,BrazilDT,NewYorkDT,
              CentralDT,MexicoDT,MountainDT,PacificDT,StaticBrokerDT;
int           ClockFontSize, TimezoneFontSize, LineSpacing, z, time, place, offset,top;
int           AucklandTZInfoArray[43],SydneyTZInfoArray[43],TokyoTZInfoArray[43],
              ChinaTZInfoArray[43],JakartaTZInfoArray[43],IndiaTZInfoArray[43],
              DubaiTZInfoArray[43],MoscowTZInfoArray[43],IsraelTZInfoArray[43],
              HelsinkiTZInfoArray[43],BerlinTZInfoArray[43],LondonTZInfoArray[43],
              BrazilTZInfoArray[43],NewYorkTZInfoArray[43],CentralTZInfoArray[43],
              MexicoTZInfoArray[43],MountainTZInfoArray[43],PacificTZInfoArray[43],
              LocalTZInfoArray[43];
int           LocalTimeArray[4],systemTimeArray[4],AucklandTimeArray[4],SydneyTimeArray[4],
              TokyoTimeArray[4],ChinaTimeArray[4],JakartaTimeArray[4],IndiaTimeArray[4],
              DubaiTimeArray[4],MoscowTimeArray[4],IsraelTimeArray[4],HelsinkiTimeArray[4],
              BerlinTimeArray[4],LondonTimeArray[4],BrazilTimeArray[4],NewYorkTimeArray[4],
              CentralTimeArray[4],MexicoTimeArray[4],MountainTimeArray[4],PacificTimeArray[4];
string        Locals,Brokers,Aucklands,Sydneys,Tokyos,Chinas,Jakartas,Indias,Dubais,
              Moscows,Israels,Helsinkis,Berlins,Londons,UTCs,Brazils,NewYorks,Centrals,
              Mexicos,Mountains,Pacifics;
string        Brokerp, Localp, Aucklandp, Sydneyp, Tokyop, Chinap, Jakartap,
              Indiap, Dubaip, Moscowp, Israelp, Helsinkip, Berlinp, Londonp, UTCp,
              Brazilp, NYp, Centralp, Mexicop, Mountainp, Pacificp, FontName;
string        timeStr,LocalTimeS,sMonth,sDay,sHour,sMin,sSec;
int           hour,nYear,nMonth,nDay,nHour,nMin,nSec,nMilliSec;

//Clock - Normal hrs 8-17 (9 hrs), Sydney 8-17 (9 hrs) and Tokyo 9-18 (9 hrs)
int           SydneyLocalOpenHour,SydneyLocalCloseHour;
int           LocalOpenHour        =  8;
int           LocalCloseHour       = 17;
int           TokyoLocalOpenHour   =  9;
int           TokyoLocalCloseHour  = 18;

//+-------------------------------------------------------------------------------------------+
//| Indicator De-initialization                                                               |
//+-------------------------------------------------------------------------------------------+
int deinit()
  {
  obj_total= ObjectsTotal();
  for(k= obj_total; k>=0; k--)
    {
    name= ObjectName(k);
    if(StringSubstr(name,0,3)=="[CP" || StringSubstr(name,1,3)=="[CP") {ObjectDelete(name);}
    }
  //Comment("");
  return(0);
  }

//+-------------------------------------------------------------------------------------------+
//| Indicator Initialization                                                                  |
//+-------------------------------------------------------------------------------------------+
int init()
  {
  //With the first DLL call below, the program will exit (and stop) automatically after one alert.
  if(!IsDllsAllowed() )
    {
    Alert(Symbol()," ",Period(),", Access Panel: Allow DLL Imports"); return(false);
    }

  //Be sure broker server equivalent time is properly input
  if((Clock_Proxy_Server_Tz_Location!="Auckland") && (Clock_Proxy_Server_Tz_Location!="Sydney") &&
     (Clock_Proxy_Server_Tz_Location!="Tokyo") && (Clock_Proxy_Server_Tz_Location!="HongKong") &&
     (Clock_Proxy_Server_Tz_Location!="Jakarta") && (Clock_Proxy_Server_Tz_Location!="India") &&
     (Clock_Proxy_Server_Tz_Location!="Dubai") && (Clock_Proxy_Server_Tz_Location!="Moscow") &&
     (Clock_Proxy_Server_Tz_Location!="Israel") && (Clock_Proxy_Server_Tz_Location!="Helsinki") &&
     (Clock_Proxy_Server_Tz_Location!="Frankfurt") && (Clock_Proxy_Server_Tz_Location!="London") &&
     (Clock_Proxy_Server_Tz_Location!="GMT") && (Clock_Proxy_Server_Tz_Location!="Brazil") &&
     (Clock_Proxy_Server_Tz_Location!="NewYork") && (Clock_Proxy_Server_Tz_Location!="Central") &&
     (Clock_Proxy_Server_Tz_Location!="Mexico") && (Clock_Proxy_Server_Tz_Location!="Mountain") &&
     (Clock_Proxy_Server_Tz_Location!="Pacific"))
    {
    Alert(Symbol()," ",Period(),", Access: Preface valid input req'd"); return(false);
    } 

  //Determine the current chart scale (chart scale number should be 0-5)
  Chart_Scale = ChartScaleGet();
 
  //Reset to Signal State of Non-deinitialization
  Deinitialized = false;

  //Panel - determine display of Market Price
  if(Digits == 5 || Digits == 3) {Factor = 10;}
  else {Factor = 1;} //cater for 5 digits

  //Panel, Bid/Ask Lines, Levels and Ranges - Set Poin values
  Poin2 = Point;
  Poin = Point*10;
  if(__Incr_Decr_Levels_Density>0) {Poin=Poin*(1+__Incr_Decr_Levels_Density);}
  if(__Incr_Decr_Levels_Density<0) {Poin=Poin/MathPow(2,MathAbs(__Incr_Decr_Levels_Density));}

  //Levels - set ranges for chart TFs
        if(Period() == 1) {NumberOfRanges = 4;}
  else {if(Period() == 5) {NumberOfRanges = 7;}
  else {if(Period() == 15) {NumberOfRanges = 15;}
  else {if(Period() == 30) {NumberOfRanges = 15;}
  else {if(Period() == 60) {NumberOfRanges = 20;}
  else {if(Period() == 240) {NumberOfRanges = 30;}
  else {if(Period() == 1440) {NumberOfRanges = 60;}
  else {if(Period() == 10080) {NumberOfRanges = 70;}
  else {if(Period() == 43200) {NumberOfRanges = 60;} }}}}}}}}

  //Import Time Zone Data  required for Clock, PivotsTZ and vLines
  GetTimeZoneInfo(AucklandTZInfoArray, SydneyTZInfoArray, TokyoTZInfoArray,
    ChinaTZInfoArray, JakartaTZInfoArray, IndiaTZInfoArray, DubaiTZInfoArray,
    MoscowTZInfoArray, IsraelTZInfoArray, HelsinkiTZInfoArray, BerlinTZInfoArray,
    LondonTZInfoArray, BrazilTZInfoArray, NewYorkTZInfoArray, CentralTZInfoArray,
    MexicoTZInfoArray, MountainTZInfoArray, PacificTZInfoArray);

  return(0);
  }

//+-------------------------------------------------------------------------------------------+
//| Indicator Start                                                                           |
//+-------------------------------------------------------------------------------------------+
int start()
  {
  //If Indicator is "Off" deinitialize only once, not every tick-------------------------------
  if(!Indicator_On)
    {
    if (!Deinitialized) {deinit(); Deinitialized = true;}
    return(0);
    }
  else {deinit();}

  //Chart Scale Settings-----------------------------------------------------------------------
  //Set datetimes based on chart scale (for Ask/Bid lines, Pivots & Ranges
            if(Chart_Scale == 0) {T1=Time[0]+(Period()*60*8); T4=Period()*60*100;}
    else {if(Chart_Scale == 1) {T1=Time[0]+(Period()*60*4); T4=Period()*60*50;}
    else {if(Chart_Scale == 2) {T1=Time[0]+(Period()*60*3); T4=Period()*60*25;}
    else {if(Chart_Scale == 3) {T1=Time[0]+(Period()*60*2); T4=Period()*60*13;}
    else {if(Chart_Scale == 4) {T1=Time[0]+(Period()*60*1); T4=Period()*60*8;}
    else {if(Chart_Scale == 5) {T1=Time[0]+(Period()*60*1); T4=Period()*60*5;}  }}}}}

  //Clock, PivotsTZ and vLines-----------------------------------------------------------------
  //Go to subroutine to get TZ info needed for Clock, PivotsTZ and vLines
  if(__Show_Clock_in_Panel || __PivotsTz_On || vLines_On)
    {
    GetSystemTime(systemTimeArray);
    UTC = TimeArrayToTime(systemTimeArray);
    BrokerDT = TimeCurrent();
    SystemTimeToTzSpecificLocalTime(AucklandTZInfoArray, systemTimeArray, AucklandTimeArray);
    AucklandDT = TimeArrayToTime(AucklandTimeArray);
    SystemTimeToTzSpecificLocalTime(SydneyTZInfoArray, systemTimeArray, SydneyTimeArray);
    SydneyDT   = TimeArrayToTime(SydneyTimeArray);
    SystemTimeToTzSpecificLocalTime(TokyoTZInfoArray, systemTimeArray, TokyoTimeArray);
    TokyoDT    = TimeArrayToTime(TokyoTimeArray);
    SystemTimeToTzSpecificLocalTime(ChinaTZInfoArray, systemTimeArray, ChinaTimeArray);
    ChinaDT    = TimeArrayToTime(ChinaTimeArray);
    SystemTimeToTzSpecificLocalTime(JakartaTZInfoArray, systemTimeArray, JakartaTimeArray);
    JakartaDT  = TimeArrayToTime(JakartaTimeArray);
    SystemTimeToTzSpecificLocalTime(IndiaTZInfoArray, systemTimeArray, IndiaTimeArray);
    IndiaDT    = TimeArrayToTime(IndiaTimeArray);
    SystemTimeToTzSpecificLocalTime(DubaiTZInfoArray, systemTimeArray, DubaiTimeArray);
    DubaiDT    = TimeArrayToTime(DubaiTimeArray);
    SystemTimeToTzSpecificLocalTime(MoscowTZInfoArray, systemTimeArray, MoscowTimeArray);
    MoscowDT   = TimeArrayToTime(MoscowTimeArray);
    SystemTimeToTzSpecificLocalTime(IsraelTZInfoArray, systemTimeArray, IsraelTimeArray);
    IsraelDT   = TimeArrayToTime(IsraelTimeArray);
    SystemTimeToTzSpecificLocalTime(HelsinkiTZInfoArray, systemTimeArray, HelsinkiTimeArray);
    HelsinkiDT = TimeArrayToTime(HelsinkiTimeArray);
    SystemTimeToTzSpecificLocalTime(BerlinTZInfoArray, systemTimeArray, BerlinTimeArray);
    BerlinDT   = TimeArrayToTime(BerlinTimeArray);
    SystemTimeToTzSpecificLocalTime(LondonTZInfoArray, systemTimeArray, LondonTimeArray);
    LondonDT   = TimeArrayToTime(LondonTimeArray);
    SystemTimeToTzSpecificLocalTime(BrazilTZInfoArray, systemTimeArray, BrazilTimeArray);
    BrazilDT   = TimeArrayToTime(BrazilTimeArray);
    SystemTimeToTzSpecificLocalTime(NewYorkTZInfoArray, systemTimeArray, NewYorkTimeArray);
    NewYorkDT  = TimeArrayToTime(NewYorkTimeArray);
    SystemTimeToTzSpecificLocalTime(CentralTZInfoArray, systemTimeArray, CentralTimeArray);
    CentralDT  = TimeArrayToTime(CentralTimeArray);
    SystemTimeToTzSpecificLocalTime(MexicoTZInfoArray, systemTimeArray, MexicoTimeArray);
    MexicoDT   = TimeArrayToTime(MexicoTimeArray);
    SystemTimeToTzSpecificLocalTime(MountainTZInfoArray, systemTimeArray, MountainTimeArray);
    MountainDT = TimeArrayToTime(MountainTimeArray);
    SystemTimeToTzSpecificLocalTime(PacificTZInfoArray, systemTimeArray, PacificTimeArray);
    PacificDT  = TimeArrayToTime(PacificTimeArray);
    GetLocalTime(LocalTimeArray);
    Local_Time = TimeArrayToTime(LocalTimeArray);

    //Sydney market local time open changes from 7am to 8am to 9am (NYC making winter DST 
    //change, later followed by Sydney making DST change) and from 9am to 8am to 7am
    //(NYC making summer DST change, later followed by Sydney making DST change.  When both
    //locations have made their DST change the time difference is 14 hours.
    if(int((UTC-NewYorkDT)/3600)==4)
      {
      if(int(SydneyDT/3600 - NewYorkDT/3600) == 14) 
        {
        SydneyLocalOpenHour  =  7;
        SydneyLocalCloseHour = 16;
        }
      else
        {
        SydneyLocalOpenHour  =  8;
        SydneyLocalCloseHour = 17;
        }
      }
     else if(int((UTC-NewYorkDT)/3600)==5)
      {
      if( int(SydneyDT/3600 - NewYorkDT/3600) == 14) 
        {
        SydneyLocalOpenHour  =  9;
        SydneyLocalCloseHour = 18;
        }
      else
        {   
        SydneyLocalOpenHour  =  8;
        SydneyLocalCloseHour = 17;
        }
      } 

    //Assign "Broker_GMT_Offset" if PivotsTz or vLines are "on".
    if((vLines_On && Period()<= __Current_Session_Max_TF) ||
      (__PivotsTz_On && Period()<= __PVT_Max_TF ))
      {
           if(Clock_Proxy_Server_Tz_Location=="Auckland") {BrokerDT= AucklandDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Sydney")   {BrokerDT= SydneyDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Tokyo")    {BrokerDT= TokyoDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="China")    {BrokerDT= ChinaDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Jakarta")  {BrokerDT= JakartaDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="India")    {BrokerDT= IndiaDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Dubai")    {BrokerDT= DubaiDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Moscow")   {BrokerDT= MoscowDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Israel")   {BrokerDT= IsraelDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Helsinki") {BrokerDT= HelsinkiDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Frankfurt"){BrokerDT= BerlinDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="London")   {BrokerDT= LondonDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="GMT")      {BrokerDT= UTC;}
      else{if(Clock_Proxy_Server_Tz_Location=="Brazil")   {BrokerDT= BrazilDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="NewYork")  {BrokerDT= NewYorkDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Central")  {BrokerDT= CentralDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Mexico")   {BrokerDT= MexicoDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Mountain") {BrokerDT= MountainDT;}
      else{if(Clock_Proxy_Server_Tz_Location=="Pacific")  {BrokerDT= PacificDT;}                                                            
        }}}}}}}}}}}}}}}}}}
      Broker_GMT_Offset = int(BrokerDT-UTC)/3600;
      }                             
    } 

  //-------------------------------------------------------------------------------------------   
  //PivotsTZ, Day RangeTZ and vLines:
  //With required time zone data imported, define parameters for PivotsTZ and vLines.
  //Calculate the GMT offsets at Ao, Fo, Lo, Ny and Lc used by vLines.  Calculate the pvtDT
  //used in the Clock when PivotsTZ is on.  Calculate Pivots_GMT_Offset used by PivotsTZ
  //and Day RangeTZ, and which might depend on one of the GMT offsets used by vLines or on
  //the alternate External Input for PivotTZ.
  if(vLines_On  || __PivotsTz_On)
    {
    //Make 8am the "reference time" at GMT for London Open
    GMT_Ref_Time = 8;

    //Find GMT At Ao (Sydney offset from GMT is not constant):
    //Sydney market local time open changes from 7am to 8am to 9am (NYC making winter DST 
    //change to GMT offset of 5 hours, later followed by Sydney making DST change) and 
    //from 9am to 8am to 7am (NYC making summer DST change to GMT offset of 4 hours, later 
    //followed by Sydney making DST change.  When both locations have made their DST change 
    //the time difference is 14 hours.
    Sydney_GMT_Offset = int (SydneyDT/3600 - UTC/3600);
    if(int((UTC-NewYorkDT)/3600)==4)
      {
      if(int(SydneyDT/3600 - NewYorkDT/3600) == 14)
        {
        //Syndey opens 7am local
        GMT_At_Ao = GMT_Ref_Time-Sydney_GMT_Offset-1;
        }
      else
        {
        //Syndey opens 8am local
        GMT_At_Ao = GMT_Ref_Time-Sydney_GMT_Offset;             
        }
      }
    else if(int((UTC-NewYorkDT)/3600)==5)
      {
      if( int(SydneyDT/3600 - NewYorkDT/3600) == 14)
        {
        //Syndey opens 9am local
        GMT_At_Ao = GMT_Ref_Time-Sydney_GMT_Offset+1;
        }
      else
        {
        //Syndey opens 8am local
        GMT_At_Ao = GMT_Ref_Time-Sydney_GMT_Offset;
        }
      }            
    if(GMT_At_Ao+Broker_GMT_Offset<0) {GMT_At_Ao=GMT_At_Ao+24;}

    //Find GMT At Fo (when Berlin is at 8am local)
    Berlin_GMT_Offset = int (BerlinDT/3600 - UTC/3600);
    GMT_At_Fo = GMT_Ref_Time-Berlin_GMT_Offset;
    if(GMT_At_Fo+Broker_GMT_Offset<0) {GMT_At_Fo=GMT_At_Fo+24;}

    //Find GMT At Lo (when London is at 8am local)
    London_GMT_Offset = int (LondonDT/3600 - UTC/3600);
    GMT_At_Lo = GMT_Ref_Time-London_GMT_Offset;
    if(GMT_At_Lo+Broker_GMT_Offset<0) {GMT_At_Lo=GMT_At_Lo+24;}

    //Find GMT At Ny (when New York is at 8am local)
    NYC_GMT_Offset = int(NewYorkDT/3600 - UTC/3600);
    GMT_At_NYo = GMT_Ref_Time-NYC_GMT_Offset;
    if(GMT_At_NYo+Broker_GMT_Offset<0) {GMT_At_NYo=GMT_At_NYo+24;}

    //Find GMT At Lc (nine hours after London Open)
    GMT_At_Lc = GMT_At_Lo + 9;
    if(GMT_At_Lc+Broker_GMT_Offset<0) {GMT_At_Lc=GMT_At_Lc+24;}

    //Only do this part if PivotsTZ or day RangeTZ is on
    if(__PivotsTz_On)
      {
      //For selected pivotTZ time zone, recalculate pvtDT (datetime) for Clock label and
      //the new Pivots_GMT_Offset for use in the PivotsTZ and day RangeTZ coding
      if(____Use_Preferred_Offset)
        {
        pvtDT = UTC + Berlin_GMT_Offset*3600;
        Pivots_GMT_Offset = Berlin_GMT_Offset;
        }
      else
        {
        pvtDT = UTC + ____Alternative_GMT_Offset*3600;
        Pivots_GMT_Offset = ____Alternative_GMT_Offset;
        }
      }
    }
    //Levels-------------------------------------------------------------------------------------
  if(Levels_On && Period()<= __Levels_Whole_Max_TF)
    {
    if(Period()>240 && Levels_Display_Number== 2) {Levels_Display_Number= 3;}
    //define needed variables
    ssp1= int (Bid/Poin);  //bid w/o the decimal
    v1=ssp1%100; //last two significant digits
    BL=v1; //last two significant digits of starting/reference bid line

    //calculate line levels bottom to top
    for(j= int (-100-(100-BL)-(100*NumberOfRanges)); j<= (100-BL)+(100*NumberOfRanges); j++)
      {
      ssp=ssp1+j;
      v1=ssp%100;
      if(v1==u1)
        {
        linelevel = ssp*Poin;
        DrawLines("LVL", Levels_Display_Number, linelevel, Level_Whole_Color,
        Level_Whole_Style_01234, Level_Whole_Width_12345);
        }
      else {if((__Show_Half_Levels && Period()<= __Levels_Half_Max_TF) && (v1==u2))
        {
        linelevel = ssp*Poin;
        DrawLines("LVL", Levels_Display_Number, linelevel, Level_Half_Color,
        Level_Half_Style_01234, Level_Half_Width_12345);
        }
      else {if((__Show_Quarter_Levels && Period()<= __Levels_Quarter_Max_TF) && ((v1==u3) || (v1==u4)))
        {
        linelevel = ssp*Poin;
        DrawLines("LVL", Levels_Display_Number, linelevel, Level_Quarter_Color,
        Level_Quarter_Style_01234, Level_Quarter_Width_12345);
        } }}
      }
    }//End Levels
    
  //Separators---------------------------------------------------------------------------------
  if(Separators_On && Period() <= __Separators_Max_TF)
    {
    //Separators for Today and Tomorrow
    CurrentSeparators("Today", Separators_Color, Separators_Style_01234,
    Separators_Width_12345);

    CurrentSeparators("Tomorrow", Separators_Color, Separators_Style_01234,
    Separators_Width_12345);

    //Separators for prior sessions
    if(__Prior_Days_To_Show > 0)
      {
      //Calculate bars per session
           if (Period()==1) {bps = 1440;}
      else {if (Period()==5) {bps = 288;}
      else {if (Period()==15){bps = 96;}
      else {if (Period()==30){bps = 48;}
      else {if (Period()==60){bps = 24;}
      else {if (Period()==240){bps = 6;} }}}}}
      //Define bar starting prior sessions display
      shift = iBarShift(NULL,NULL,iTime(NULL,PERIOD_D1,0));
      //Execute loop for bars per session X number of prior sessions to show
      for(i= int (shift); i<=(shift+(bps*(__Prior_Days_To_Show))); i++)
        {
        if(TimeHour(Time[i]) == 0 && TimeMinute(Time[i]) == 0)
          {
          PriorSeparators(i, Separators_Color,
          Separators_Style_01234, Separators_Width_12345);
          }
        }
      }
    }//End Separators

  //vLines-------------------------------------------------------------------------------------
  if(vLines_On && Period()<= __Current_Session_Max_TF)
    {
    //Calculate position for vline labels
    level = WindowPriceMax();
    //Calculate bars per session
          if (Period()==1) {bps = 1439;}
    else {if (Period()==5) {bps = 287;}
    else {if (Period()==15){bps = 95;}
    else {if (Period()==30){bps = 47;}
    else {if (Period()==60){bps = 23;} }}}}
    //Define bar starting prior sessions display
    shift = iBarShift(NULL,NULL,iTime(NULL,PERIOD_D1,0));

    //Do vlines for current session------------------------------------------------------------
    if(DayOfWeek()==0)
      {
      //Code for any broker on Sunday is same type code used for prior sessions because we
      //have to recreate previous Friday session vLines since Sunday is just a short session
      //that is a continuation of Friday.  This applies to all vLines except "Ao".
      //Execute loop for bars per session
      for(i= int (shift); i<=(shift+bps); i++)
        {
        h=TimeHour(Time[i]);
        m=TimeMinute(Time[i]);

        //Asian Open vLine (prior session)
        if( __Prior_Ao_with_Current_Session_only) {
        MF = int (MathFloor(GMT_At_Ao));
        if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Ao != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
          {
          OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Ao == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          } }}}

        //Berlin Open vLine (current session)
        if(__Fo_in_All_Sessions) {
        MF = int (MathFloor(GMT_At_Fo));
        if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_Berlin_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Fo != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
          {
          OpenPrior(i, vLabels_Berlin_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Fo == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_Berlin_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          } }}}

        //London Open vLine (current session)
        MF = int (MathFloor(GMT_At_Lo));
        if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_London_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Lo != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
          {
          OpenPrior(i, vLabels_London_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Lo == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_London_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          } }}

        //NewYork Open vLine (current session)
        MF = int (MathFloor(GMT_At_NYo));
        if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_NewYork_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_NYo != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
          {
          OpenPrior(i, vLabels_NewYork_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_NYo == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_NewYork_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          } }}

        //London Close vLine (current session)
        MF = int (MathFloor(GMT_At_Lc));
        if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_London_Close, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Lc != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
          {
          OpenPrior(i, vLabels_London_Close, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Lc == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_London_Close, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          } }}
        }//End prior sessions shift loop

        //Asian Open vLine (current session)
        if(__Ao_in_All_Sessions)
          {
          OpenToday(vLabels_Asian_Open, GMT_At_Ao + Broker_GMT_Offset,
          vLines_Color, vLines_Style_01234, vLines_Width_12345, level);
          }
      }//End Short Sunday loop for broker at GMT

    else //for all brokers Monday thru Friday      
      {
      //Do Ao vline for prior session
      if(__Prior_Ao_with_Current_Session_only &&  __Prior_Sessions_To_Show==0)
        {
        for(i= int (shift+1); i<=(shift+bps+1); i++)
          {
          h=TimeHour(Time[i]);
          m=TimeMinute(Time[i]);

          //Asian Open vLine
          MF = int (MathFloor(GMT_At_Ao));
          if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
            {
            OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
            vLines_Width_12345, level);
            }
          else {if((GMT_At_Ao != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
            {
            OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
            vLines_Width_12345, level);
            }
          else {if((GMT_At_Ao == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
            {
            OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
            vLines_Width_12345, level);
            } }}
          }
        }//End single prior Ao vLine

      //Asian Open vLine (current session)
      if(__Ao_in_All_Sessions)
        {
        OpenToday(vLabels_Asian_Open, GMT_At_Ao + Broker_GMT_Offset,
        vLines_Color, vLines_Style_01234, vLines_Width_12345, level);
        }
      //Berlin Open vLine (current session)
      if(__Fo_in_All_Sessions)
        {
        OpenToday(vLabels_Berlin_Open, GMT_At_Fo + Broker_GMT_Offset,
        vLines_Color, vLines_Style_01234, vLines_Width_12345, level);
        }
      //London Open vLine (current session)
      OpenToday(vLabels_London_Open, GMT_At_Lo + Broker_GMT_Offset,
      vLines_Color, vLines_Style_01234, vLines_Width_12345, level);
      //NewYork Open vLine (current session)
      OpenToday(vLabels_NewYork_Open, GMT_At_NYo + Broker_GMT_Offset,
      vLines_Color,vLines_Style_01234, vLines_Width_12345, level);
      //London Close vLine (current session)
      OpenToday(vLabels_London_Close, GMT_At_Lc + Broker_GMT_Offset,
      vLines_Color, vLines_Style_01234, vLines_Width_12345, level);
      }

    //Do vlines for previous sessions----------------------------------------------------------
    if(__Prior_Sessions_To_Show >0 && Period() <= __Prior_Sessions_Max_TF)
      {
      int bps2 = bps +1;
      for(i= int (shift); i<=(shift+(bps2*(__Prior_Sessions_To_Show))); i++)
        {
        h=TimeHour(Time[i]);
        m=TimeMinute(Time[i]);

        //Asian Open vLine
        if(__Ao_in_All_Sessions) {
        MF = int (MathFloor(GMT_At_Ao));
        if((Period() > 30) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Ao != MF) && (h == MF + Broker_GMT_Offset) && (m == 30))
          {
          OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          }
        else {if((GMT_At_Ao == MF) && (h == MF + Broker_GMT_Offset) && (m == 0))
          {
          OpenPrior(i, vLabels_Asian_Open, vLines_Color, vLines_Style_01234,
          vLines_Width_12345, level);
          } }}}

        //Berlin Open vLine
        if(__Fo_in_All_Sessions) {
        MF = int (MathFloor(GMT_At_Fo));
        if((Period() > 30) &&        

Recommend