Need Help Clearing Errors

 

Hi,

I'm still having trouble clearing errors. Which consists of 'CloseAllMarketOrders'-struct or Class type expected, 'Trade'-struct or class type expected, and 'DeleteAllPendingOrders' struct or class type expected.  I will post my code below and following I will post my include file code.  Any help would be appreciated. 


#include <Timer.mqh>
CTimer Timer;



string MM; // Money Management
input bool UseMoneyManagement=true;
input double RiskPercent=2;
input double FixedLotSize=0.1;


string TradeSettings;    // Trade Settings
input int MagicNumber = 101;
input int HighLowBars = 8;
input int TakeProfit = 0;
input int Slippage = 10;
input int Spread = 5;

string BE;  // Break Even Stop
input bool UseBreakEvenStop=false;
input int MinimumProfit=0;
input int LockProfit=0;

string TI;  // Timer
input int StartHour=0;
input int StartMinute=0;
input int EndHour=0;
input int EndMinute=0;
input bool UseLocalTime=false;
input bool UseTimer=false;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {

// Check timer
   bool tradeEnabled=Timer.DailyTimer(StartHour,StartMinute,EndHour,EndMinute,UseLocalTime);

// Close all orders
   bool Trade=false;
   int gBuyTicket=0;
   int gSellTicket=0;

   if(tradeEnabled==false)

     {

      Trade.CloseAllMarketOrders();
      Trade.DeleteAllPendingOrders();

      gBuyTicket=0;
      gSellTicket=0;
     }
// Open Orders

   else
     {
      //Calculate highest high & lowest low
      int hShift=iHighest(_Symbol,_Period,MODE_HIGH,HighLowBars);
      int lShift=iLowest(_Symbol,_Period,MODE_LOW,HighLowBars);

      double hHigh=High[hShift];
      double lLow=Low[lShift];
      double difference=(hHigh-lLow)/_Point;

      //Money Management
      double LotSize=FixedLotSize;
      if(UseMoneyManagement==true)
        {

         LotSize=MoneyManagement(_Symbol,FixedLotSize,RiskPercent,(int)difference);
        }

      //Open buy stop order
      if(Count.Buy()==0 && Count.BuyStop()==0 && gBuyTicket==0)
        {
         double orderPrice=hHigh;
         orderPrice=AdjustAboveStopLevel(_Symbol,orderPrice);

         double buyStop=lLow;
         double buyProfit=BuyTakeProfit(_Symbol,TakeProfit,orderPrice);

         gBuyTicket=Trade.OpenBuyStopOrder(_Symbol,LotSize,orderPrice,buyStop,buyProfit);
        }
      //Open Sell stop order
      if(Count.Sell()==0 && Count.SellStop()==0 && gSellTicket==0)
        {
         double orderPrice=lLow;
         orderPrice=AdjustBelowStopLevel(_Symbol, orderPrice);

         double sellStop=hHigh;
         double sellProfit=SellTakeProfit(_Symbol,TakeProfit,orderPrice);

         gSellTicket=
            Trade.OpenSellStopOrder(_Symbol,lotSize,orderPrice,sellStop,sellProfit);

        }

      // Break even stop
      if(UseBreakEvenStop==true)
        {

         BreakEvenStopAll(MinimumProfit,LockProfit);
        }
     }
  }


Below is the Include file code

#define TIME_ADD_MINUTE 60
#define TIME_ADD_HOUR 3600
#define TIME_ADD_DAY 86400
#define TIME_ADD_WEEK 604800




class CNewBar
{

   private:
      datetime _time[],_lastTime;
      
   public:
      void CNewBar();
      
      bool CheckNewBar(string pSymbol,ENUM_TIMEFRAMES pTimeframe);
};
   void CNewBar::CNewBar(void)
   {
      ArraySetAsSeries(_time,true);
   }
   
   bool CNewBar::CheckNewBar(string pSymbol,ENUM_TIMEFRAMES pTimeframe)
   {
   
      bool firstRun=false,newBar=false;
      CopyTime(pSymbol,pTimeframe,0,2,_time);
      
      if(_lastTime==0) firstRun=true;
      
      if(_time[0]>_lastTime)
      {  
         if(firstRun==false) newBar=true;
         _lastTime=_time[0];
      }
      
      return(newBar);
      
 }

datetime CreateDateTime(int pHour=0, int pMinute=0)
{

   MqlDateTime timeStruct;
   TimeToStruct(TimeCurrent(),timeStruct);
   
   timeStruct.hour=pHour;
   timeStruct.min=pMinute;
   
   datetime useTime=StructToTime(timeStruct);
   
   return(useTime);
}


class CTimer
{
   private:
      datetime _startTime,_endTime;
      
   public:
      bool CheckTimer(datetime pStartTime, datetime pEndTime,bool pLocalTime=false);
      bool DailyTimer(int pStartHour,int pStartMinute,int pEndHour,int pEndMinute,bool pLocalTime=false);
 };
 
 bool CTimer::DailyTimer(int pStartHour,int pStartMinute,int pEndHour,int pEndMinute,bool pLocalTime=false)
 
 {
      datetime currentTime;
      if(pLocalTime==true) currentTime=TimeLocal();
      else currentTime=TimeCurrent();
      
      _startTime=CreateDateTime(pStartHour,pStartMinute);
      _endTime=CreateDateTime(pEndHour,pEndMinute);
      
      if(_endTime<=_startTime)
      {
      
         _startTime-=TIME_ADD_DAY;
      
      if(currentTime>_endTime)
      {
         _startTime+=TIME_ADD_DAY;
         _endTime+=TIME_ADD_DAY;
      }
      
      }
      
      bool tradeEnabled=CheckTimer(_startTime,_endTime,pLocalTime);
      return(tradeEnabled);
      }
 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code properly in a new post.
 
Keith Watford:
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code properly in a new post.

I think I did it correctly.  Please take a look and let me know if it's OK now. 

 
Peno313:

I think I did it correctly.  Please take a look and let me know if it's OK now. 

Yes, it is done correctly.

 

Don't post code that won't even compile.

   bool Trade=false;
⋮
      Trade.CloseAllMarketOrders();

Trade is a bool, it can not be a class/struct object and can't have methods.

 
William Roeder:

Don't post code that won't even compile.

Trade is a bool, it can not be a class/struct object and can't have methods.

Any suggestion on how to fix it? 

 
Peno313:

Any suggestion on how to fix it? 

Yes. Get a complete copy of that code.
 
lippmaje:
Yes. Get a complete copy of that co

That code is from a book.  Using it for practice.  Any pertinent advice ? 

 

There should be a class named CTrade and CCount mentioned somewhere near this code, use it.

 
lippmaje:

There should be a class named CTrade and CCount mentioned somewhere near this code, use it.

Thank you.