3shadeopen Indicator For MT4

3shadeopen Indicator For MT4

The 3shadeopen Indicator For MT4 shows critical information regarding the different trading sessions. If you want to pick the specific trading asset, make sure you learn about the importance of different trading sessions. Once you learn to trade this market with the perfect trading method, you need to think about the risk exposure. Taking the high risk to trade the overlapping session is a very big mistake. Follow the conservative trading approach to earn more money from this market.

FREE 3shadeopen Indicator

Download the FREE 3shadeopen Indicator for MT4.

To receive my email 100% sure: 
Put my email on your whitelist!

 

Partially Automated Trading Besides Your Day Job

Alerts In Real-Time When Divergences Occur

My Recommended MT4/MT5 Broker

 

Installing the 3shadeopen Indicator For MT4

After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file 3shadeopen.mq4 into the folder MQL4\Indicators of your MT4 installation. After that please restart MT4 and then you will be able to see the indicator in the list of indicators.

Parameters of the 3shadeopen Indicator For MT4

The 3shadeopen Indicator For MT4 has 1 parameters to configure.

extern color     ShadeColor=Gold;

Buffers of the 3shadeopen Indicator For MT4

The 3shadeopen Indicator For MT4 provides 0 buffers.

Main Parts Of The Code

//|              is widened in the start() in lieu of repainting all.|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, sx ted"
#property link      ""
#property indicator_chart_window
//---- input parameters
extern color     ShadeColor=Gold;
/*
// if in Moscow
#define NY_OPEN_HH   17 // NY session open hour
#define NY_OPEN_MM   30 // NY session open minutes
#define NY_CLOSE_HH  00 // NY session close hour
#define NY_CLOSE_MM  05 // NY session close minutes
*/
/* if in London
#define NY_OPEN_HH   14 // NY session open hour
#define NY_OPEN_MM   30 // NY session open minutes
#define NY_CLOSE_HH  21 // NY session close hour
#define NY_CLOSE_MM  05 // NY session close minutes
*/
// if in New York
#define NY_OPEN_HH   06 // NY session open hour
#define NY_OPEN_MM   30 // NY session open minutes
#define NY_CLOSE_HH  13 // NY session close hour
#define NY_CLOSE_MM  05 // NY session close minutes
#define MAX_DAYS_TO_SHADE  5 // maximum number of days back from last chart date to be shaded
//---- global variables to program
string obj[]; //array of object names
int    iPrevious=0,iStart=-1,iEnd;
double dLow,dHigh;
bool prepared=false;
bool rectangle_created=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   if(Period() gt PERIOD_H4) return(0); // no shading required
   rectangle_created=false;
   prepared=CheckAndPrepare();
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CheckAndPrepare()
  {
   int iMaxBarsOnChart=iBars(NULL,0),i,iBarDay,iBarTime;
   if(iMaxBarsOnChart lt =0)
     {
      Print("Not enough bars");
      return(false);
     }
// find approximate start of first day to shade
   int iBarsToDo=MathMin((MAX_DAYS_TO_SHADE*PERIOD_D1)/Period(),iMaxBarsOnChart);
// find start of first day to shade
   if(ArraySize(Time) lt =0)
     {
      Print("Timeseries are not ready for use");
      return(false);
     }

   for(i=iBarsToDo; i lt iMaxBarsOnChart; i++)
     {
      iBarDay=TimeYear(Time[i])*PERIOD_MN1*12+TimeMonth(Time[i])*PERIOD_MN1+TimeDay(Time[i])*PERIOD_D1;
      iBarTime=iBarDay+TimeHour(Time[i])*60+TimeMinute(Time[i]);
      if(iBarTime gt =iBarDay+NY_OPEN_HH*60+NY_OPEN_MM && iBarTime lt =iBarDay+NY_CLOSE_HH*60+NY_CLOSE_MM) iStart=i;
      else if(iStart gt -1) break;
     }
   if(iStart gt -1) iBarsToDo=iStart;
   iBarsToDo=MathMin(iBarsToDo,ArraySize(Time)-1);
   iStart=-1;
// shade previous sessions and current session if started
   for(i=iBarsToDo; i gt =0; i--)
     {
      iBarDay=TimeYear(Time[i])*PERIOD_MN1*12+TimeMonth(Time[i])*PERIOD_MN1+TimeDay(Time[i])*PERIOD_D1;
      iBarTime=iBarDay+TimeHour(Time[i])*60+TimeMinute(Time[i]);
      if(iBarTime gt =iBarDay+NY_OPEN_HH*60+NY_OPEN_MM && iBarTime lt =iBarDay+NY_CLOSE_HH*60+NY_CLOSE_MM)
        {
         if(iBarDay==iPrevious) // current NY session
           {
            dLow =MathMin(dLow,  Low[i]);
            dHigh=MathMax(dHigh, High[i]);
           }
         else                     // new NY session
           {
            dLow=Low[i];
            dHigh=High[i];
            iStart=i;
            iPrevious=iBarDay;
           }
         iEnd=i;
        }
      else if(iStart gt -1)
        {
         PaintRectangle();
         iStart=-1;
        }
     }
   if(iStart gt -1)
     {
      PaintRectangle();
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   int iaCount=ArraySize(obj);
   for(int i=0; i lt iaCount; i++)
     {
      if(ObjectFind(obj[i]) gt -1) ObjectDelete(obj[i]);
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   if(!prepared)
     {
      prepared=CheckAndPrepare();
      if(!prepared)
         return(0);
      else
        {
         if(!rectangle_created)
           {
            prepared=false;
            Print("Try to paint at next tick");
            return(0);
           }
        }
     }
   int i=0,iBarDay,iBarTime;
   iBarDay=TimeYear(Time[i])*PERIOD_MN1*12+TimeMonth(Time[i])*PERIOD_MN1+TimeDay(Time[i])*PERIOD_D1;
   iBarTime=iBarDay+TimeHour(Time[i])*60+TimeMinute(Time[i]);
   bool condition=(iBarTime gt =iBarDay+NY_OPEN_HH*60+NY_OPEN_MM) && (iBarTime lt =iBarDay+NY_CLOSE_HH*60+NY_CLOSE_MM);
   if(iBarTime gt =iBarDay+NY_OPEN_HH*60+NY_OPEN_MM && iBarTime lt =iBarDay+NY_CLOSE_HH*60+NY_CLOSE_MM)
     {
      if(iBarDay==iPrevious) // current NY session
        {
         dLow =MathMin(dLow,  Low[i]);
         dHigh=MathMax(dHigh, High[i]);
        }
      else                     // new NY session
        {
         dLow=Low[i];
         dHigh=High[i];
         iStart=i;
         iPrevious=iBarDay;
        }
      iEnd=i;
      Print("painting..");
      PaintRectangle();
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| Paint rectangle                                                  |
//+------------------------------------------------------------------+
void PaintRectangle()
  {
   string sObj="ShadeNY_"+DoubleToStr(iPrevious,0); // name for the object
   if(ObjectFind(sObj) gt -1)
     {
      // current session object found, so just widen it
      ObjectSet(sObj,OBJPROP_PRICE1,dLow-Point);
      ObjectSet(sObj,OBJPROP_TIME2,Time[iEnd]);
      ObjectSet(sObj,OBJPROP_PRICE2,dHigh+Point);
     }
   else
     {
      // otherwise create new object for the session
      int iaCount=ArraySize(obj);
      ArrayResize(obj,iaCount+1);
      obj[iaCount]=sObj;
      ObjectCreate(sObj,OBJ_RECTANGLE,0,Time[iStart],dLow-Point,Time[iEnd],dHigh+Point);
      ObjectSet(sObj,OBJPROP_COLOR,ShadeColor);
      rectangle_created=true;
     }
  }
//+------------------------------------------------------------------+

 

About Me

I'm Mike Semlitsch the owner of PerfectTrendSystem.com. My trading career started in 2007. Since 2013 I have helped thousands of traders to take their trading to the next level. Many of them are now constantly profitable traders. 

The following performance was achieved by me while trading live in front of hundreds of my clients:

Connect With Me:  

This FREE Indicator Can Transform
Your Trading!

FREE Indicator + Telegram Group


Request the Ultimate Double Top/Bottom Indicator which is used by 10,000+ traders.

Results From 5 Months!
This service starts soon! Be the first who get's notified when it begins!