Help Me to add Timezone in to my Test EA

 

Hello Master Coding,

please help me to add Timezone in to my Test EA ....

i really appreciate who want to help me... thank you....

//+------------------------------------------------------------------+
//|                                                         Test.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//-------------------------------------------------------------------
//--- Enum Options
   enum IndicatorTimeframe {
                                 OnCart = PERIOD_CURRENT,
                                 M1    = PERIOD_M1,
                                 M5    = PERIOD_M5,
                                 M15   = PERIOD_M15,
                                 M30   = PERIOD_M30,
                                 H1    = PERIOD_H1,
                                 H4    = PERIOD_H4,
                                 D1    = PERIOD_D1,
                                 W1    = PERIOD_W1,
                           };
//--- Input Menu :
   input double   Lot_Size                   = 0.01;        // Lot Size
   input int      Take_Profit                = 20;          // Take Profit
   input int      Stop_Loss                  = 15;          // Stop Loss
   input int      Slippage                   = 7;           // Slippage
   input int      MA_Period                  = 30;          // MA Period
   input double   Distance                   = 2.5;         // Step Up/Down MA
   input bool     Active_Working_Hours       = true;        // [Working Hours] | Broker Time :
   input int      Begin_Hour                 = 3;           // Begin Hour
   input int      Begin_Minute               = 15;          // Begin Minute
   input int      End_Hour                   = 22;          // End Hour
   input int      End_Minute                 = 15;          // End Minute
   input bool     StopFriday                 = true;        // Stop Friday
   input int      FridayHourStop             = 18;          // Friday Hour To Stop
   input IndicatorTimeframe Indi_Timeframe   = OnCart;      // Timeframe Used
   int MagicNumBuy             = 1234;
   int MagicNumSell            = 5678;
   int NewsLevel               = 3;
//--------------------------------------------------------------------
//--- Global Variable :
   const string EA_NAME = "Never Loss";
   double MyPoint;
   int MySlippage;
   double MA_Trend;
   //double BB_Upper, BB_Lower;
   
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

//----------------------
int OnInit()
  {
//---
   MyPoint = MyPoint();
   MySlippage = MySlippage();
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
    //--- 
   StopWorkFriday();
   ShowInformation();
   InitIndicators();
   //---
       if(CheckTotalOrderBuy() == 0 && InitWorkingHours() == true)
         {
          if(InitSignalBuy() == true)
          { PlaceBuy(); }
         }
       //---
       if(CheckTotalOrderSell() == 0 && InitWorkingHours() == true)
         {
          if(InitSignalSell() == true)
          { PlaceSell(); }
         }
  } // End of Void
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Chek function                                                    |
//+------------------------------------------------------------------+
//--- Initialize Digit    
   double MyPoint()
      {
      double CalcPoint = 0;
      if(_Digits == 2 || _Digits == 3) CalcPoint = 0.01;
         else if(_Digits == 4 || _Digits == 5) CalcPoint = 0.0001;
         
      return(CalcPoint);
      }
      
   //--- Initialize Slippage
   int MySlippage()
      {
      int CalcSlippage = 0;
      if(_Digits == 2 || _Digits == 4) CalcSlippage = Slippage;
         else if(_Digits == 3 || _Digits == 5) CalcSlippage = Slippage * 10;
         
      return(CalcSlippage);
      }
   //-----------------------------------------------------------------
   //--- Initialize Friday Stop
   bool StopWorkFriday()
      {
         if(StopFriday == true)
            {
               if(ThisFriday() == false)
               {  return(0);  }
            }
         return(true);
      }
   bool ThisFriday()
      {
         datetime time=TimeCurrent();
         if( (DayOfWeek() == 5) && (TimeHour(time) >= FridayHourStop) )
               {  return(true);  }
         else  {  return(false); }
      }
   //--- End of : Friday Stop */
   //-------------------------------------
   //--- Initialize Working Hours
   bool InitWorkingHours()
      {
         if(Active_Working_Hours == true)
            {  
            if(WorkingHours() == false)
               {  return(0);  }
            }
         return(true);
      }
   bool WorkingHours()
      {
         datetime time=TimeCurrent();
         if( ((TimeHour(time) > Begin_Hour || (TimeHour(time) == Begin_Hour && TimeMinute(time) >= Begin_Minute))
               && (TimeHour(time) < End_Hour || (TimeHour(time) == End_Hour && TimeMinute(time) <= End_Minute))) )
               {  return(true);  }
         else  {  return(false); }
      }
   //--- End of : Initialize Working Hours
   //-------------------------------------
   //-----------------------------------------------------------------
   //--- Initialize Indicator
   void InitIndicators()
      {
        MA_Trend        = iMA(Symbol(),Indi_Timeframe,MA_Period,0,MODE_EMA,PRICE_CLOSE,0);
      }
   //-----------------------------------------------------------------
   //--- Initialize Signal
   bool InitSignalBuy()
      {
         if((Ask < (MA_Trend - Distance*MyPoint)) )
         return(true);
         return(false);
      }
   //---
   bool InitSignalSell()
      {
         if((Bid > (MA_Trend + Distance*MyPoint)) )
         return(true);
         return(false);
      }
   //-----------------------------------------------------------------
   //--- Checking Total Orders
   int CheckTotalOrderBuy()
      {
      int total_order_buy = 0;
      for(int orderbuy = 0; orderbuy < OrdersTotal(); orderbuy++)
         {
         if(OrderSelect(orderbuy,SELECT_BY_POS,MODE_TRADES) == false)
         break;
         if(OrderMagicNumber() == MagicNumBuy && OrderSymbol() == _Symbol && OrderType() == OP_BUY)
            {
            total_order_buy++;
            }
         }
         return(total_order_buy);
      }
   //---
   int CheckTotalOrderSell()
      {
      int total_order_sell = 0;
      for(int ordersell = 0; ordersell < OrdersTotal(); ordersell++)
         {
         if(OrderSelect(ordersell,SELECT_BY_POS,MODE_TRADES) == false)
         break;
         if(OrderMagicNumber() == MagicNumSell && OrderSymbol() == _Symbol && OrderType() == OP_SELL)
            {
            total_order_sell++;
            }
         }
         return(total_order_sell);
      }
   //-----------------------------------------------------------------
   //--- Initialize Place Order
   void PlaceBuy()
      {
         //--- Placed Order BUY :
         int ticketbuy = OrderSend(_Symbol,OP_BUY,Lot_Size,Ask,MySlippage,0,0,"BUY",MagicNumBuy);
            if(ticketbuy < 0 )
            {  Print("OrderSend Buy Error #",GetLastError());   }
            else
            {  Print("OrderSend Buy Successfully");   }
         //--- Modify Order BUY :
         //--- Check TakeProfit and Stoploss :
         bool DoModify = OrderModify(ticketbuy,OrderOpenPrice(),Bid-Stop_Loss*MyPoint,Ask+Take_Profit*MyPoint,0,Blue);
            if(!DoModify)
            {  Print("OrderModify Buy. Error Code=",GetLastError());  }
            else
            {  Print("Order Buy Modified Successfully."); }
      }
   //---
   void PlaceSell()
      {
         //--- Place Order SELL :
          int ticketsell = OrderSend(_Symbol,OP_SELL,Lot_Size,Bid,MySlippage,0,0,"SELL",MagicNumSell);
             if(ticketsell < 0 )
             {  Print("OrderSend Sell Error #",GetLastError());   }
             else
             {  Print("OrderSend Sell Successfully");   }
          //--- Modify Order SELL :
          bool DoModify = OrderModify(ticketsell, OrderOpenPrice(),Bid+Stop_Loss*MyPoint,Ask-Take_Profit*MyPoint,0,Blue);
          if(!DoModify)
             {  Print("OrderModify Sell. Error Code=",GetLastError());  }
             else
             {  Print("Order Sell Modified Successfully."); }
      }
   //-----------------------------------------------------------------
 
   //--- Initialize Information
   void ShowInformation() 
      { 
      string ShowComment = "";
      // Add comment
      ShowComment += "----------------------------------------------- \n" + 
                    "     " + EA_NAME + "                             \n" +
                    "----------------------------------------------- \n" +
                    "----------------------------------------------- \n" +
                    " Account Name        : " + AccountName() + "\n" +
                    " Account Number      : " + IntegerToString(AccountNumber()) + "\n" + 
                    " Account Leverage    : 1:" + IntegerToString(AccountLeverage()) + "\n" +
                    " Account Broker       : " + AccountCompany() + "\n" +
                    "----------------------------------------------- \n" +
                    " Account Balance     : " + AccountCurrency() + " " + DoubleToStr(AccountBalance(), 2) + "\n" +
                    " Account Equity      : " + AccountCurrency() + " " + DoubleToStr(AccountEquity(), 2) + "\n" +
                    "----------------------------------------------- \n";

      ShowComment += "----------------------------------------------- \n";
      // Show comments             
      Comment(ShowComment);
      }
   //--- End of : Initialize Information
   //-----------------------------------

here the file ...

Files:
Test.mq4  11 kb
 
nerverlost: please help me to add Timezone in to my Test EA ....
  1. Makes no sense.
    input int      TimeZone                   = 0;
    Done.
  2. Your code
       enum IndicatorTimeframe {
                                     OnCart = PERIOD_CURRENT,
                                     M1    = PERIOD_M1,
                                     M5    = PERIOD_M5,
                                     M15   = PERIOD_M15,
                                     M30   = PERIOD_M30,
                                     H1    = PERIOD_H1,
                                     H4    = PERIOD_H4,
                                     D1    = PERIOD_D1,
                                     W1    = PERIOD_W1,
                               };
       input IndicatorTimeframe Indi_Timeframe   = OnCart;      // Timeframe Used
    Simplified
     ENUM_TIMEFRAMES   Indi_Timeframe=PERIOD_CURRENT;           // Timeframe Used
    
 

As it is known that the forex market starts always at Sunday NY-time 17:00 (inlc. USA DST!!) you can start from there if your broker (your data) corresponds to that.

So if the first data after weekend has a time stamp of e.g. 20:00 your data are NY-time + 3 hours - this must be a unknown island in the Atlantic Ocean ;)