How to handle "event handling function"

 

Hi there !

I found this and then tried to compile it but the code is giving me 3 errors: 

'}' - unexpected end of program

'{' - unbalanced parentheses

event handling function not found  

 

Here is the code:

 

//+------------------------------------------------------------------+
//|                    PSAR Trader                                   |
//|                                                                  |
//+------------------------------------------------------------------+


#property copyright "Copyright © 2012"
#property link      "Mql5"

//---- input parameters
input string    Visit="www.mql5.com for more products";
input string    SignalsAndManagedAccounts="www.mql5.com";
input double    Lots=0.1;
input int       Slip=5;
input string    StopSettings="Set stops below";
input double    TakeProfit=50;
input double    StopLoss=50;
input string    PSARsettings="Parabolic sar settings follow";
input double    Step    =0.001;   //Parabolic setting
input double    Maximum =0.2;    //Parabolic setting
input bool      CloseOnOpposite=true;
input string    TimeSettings="Set the hour range the EA should trade";
input int       StartHour=0;
input int       EndHour=23;


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
//----
int digits=MarketInfo("EURUSD",12);
int StopMultd=10;
int Slippage=Slip*StopMultd;

int MagicNumber1=220101,MagicNumber2=220102,i,closesell=0,closebuy=0;


//-------------------------------------------------------------------




double  TP=NormalizeDouble(TakeProfit*StopMultd,_Digits);
double  SL=NormalizeDouble(StopLoss*StopMultd,_Digits);



double slb=NormalizeDouble(Ask-SL*_Point,_Digits);
double sls=NormalizeDouble(Bid+SL*_Point,_Digits);


double tpb=NormalizeDouble(Ask+TP*_Point,_Digits);
double tps=NormalizeDouble(Bid-TP*_Point,_Digits);

//-------------------------------------------------------------------+
//Check open orders
//-------------------------------------------------------------------+
if(OrdersTotal()>0){
  for(i=1; i<=OrdersTotal(); i++)          // Cycle searching in orders
     {
      if (OrderSelect(i-1,0)==true) // If the next is available
        {
          if(OrderMagicNumber()==MagicNumber1) {int halt1=1;}
          if(OrderMagicNumber()==MagicNumber2) {int halt2=1;}

        }
     }
}
//-------------------------------------------------------------------+
// time check
//-------------------------------------------------------------------
if((Hour()>=StartHour)&&(Hour()<=EndHour))
{
int TradeTimeOk=1;
}
else
{ TradeTimeOk=0; }
//-----------------------------------------------------------------
// Bar checks
//-----------------------------------------------------------------

 
 //-------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------
// Opening criteria
//-----------------------------------------------------------------------------------------------------

Comment("For more goodies, managed accounts, forex signals and premium EAs visit www.mql5.com");

// Open buy
 if((iSAR(NULL, 0,Step,Maximum, 0)<iClose(NULL,0,0))&&(iSAR(NULL, 0,Step,Maximum, 1)>iClose(NULL,0,1))&&(TradeTimeOk==1)){
 int openbuy=OrderSend(_Symbol,0,Lots,Ask,Slippage,0,0,"PSAR trader buy order",MagicNumber1,0,Blue);
 if(CloseOnOpposite==true)closesell=1;
 }


// Open sell
 if((iSAR(NULL, 0,Step,Maximum, 0)>iClose(NULL,0,0))&&(iSAR(NULL, 0,Step,Maximum, 1)<iClose(NULL,0,1))&&(TradeTimeOk==1)){
 int opensell=OrderSend(_Symbol,1,Lots,Bid,Slippage,0,0,"PSAR trader sell order",MagicNumber2,0,Green);
 if(CloseOnOpposite==true)closebuy=1;
 }


//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// Closing criteria
//-------------------------------------------------------------------------------------------------

if(closesell==1||closebuy==1||openbuy<1||opensell<1){// start

if(OrdersTotal()>0){
  for(i=1; i<=OrdersTotal(); i++){          // Cycle searching in orders
  
      if (OrderSelect(i-1,0)==true){ // If the next is available
        
          if(OrderMagicNumber()==MagicNumber1&&closebuy==1) { OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,CLR_NONE); }
          if(OrderMagicNumber()==MagicNumber2&&closesell==1) { OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,CLR_NONE); }
          
          // set stops
          if((OrderMagicNumber()==MagicNumber1)&&(OrderTakeProfit()==0)&&(OrderSymbol()==_Symbol)){ OrderModify(OrderTicket(),0,OrderStopLoss(),tpb,0,CLR_NONE); }
          if((OrderMagicNumber()==MagicNumber2)&&(OrderTakeProfit()==0)&&(OrderSymbol()==_Symbol)){ OrderModify(OrderTicket(),0,OrderStopLoss(),tps,0,CLR_NONE); }
          if((OrderMagicNumber()==MagicNumber1)&&(OrderStopLoss()==0)&&(OrderSymbol()==_Symbol)){ OrderModify(OrderTicket(),0,slb,OrderTakeProfit(),0,CLR_NONE); }
          if((OrderMagicNumber()==MagicNumber2)&&(OrderStopLoss()==0)&&(OrderSymbol()==_Symbol)){ OrderModify(OrderTicket(),0,sls,OrderTakeProfit(),0,CLR_NONE); }

        }
     }
}


}// stop

//----
int Error=GetLastError();
  if(Error==130){Alert("Wrong stops. Retrying."); //RefreshRates();}
  if(Error==133){Alert("Trading prohibited.");}
  if(Error==2){Alert("Common error.");}
  if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(500); //RefreshRates();}

//----

//-------------------------------------------------------------------
   return(0);
  }
//+------------------------------------------------------------------+
//********************************************  Emulation *******************************************
double Ask;
double Bid;
double Bars;
double Open[];
double Close[];
double High[];
double Low[];
datetime Time[];
long Volume[];

void Set_Values_to_variables()
{
   MqlTick last_tick;
   SymbolInfoTick(_Symbol,last_tick);
   Ask=last_tick.ask;
   Bid=last_tick.bid;
  
   ArraySetAsSeries(Close,true);
   CopyClose(_Symbol,_Period,0,Bars(_Symbol,_Period),Close);
   ArraySetAsSeries(Open,true);
   CopyOpen(_Symbol,_Period,0,Bars(_Symbol,_Period),Open);
   ArraySetAsSeries(Low,true);
   CopyLow(_Symbol,_Period,0,Bars(_Symbol,_Period),Low);
   ArraySetAsSeries(High,true);
   CopyHigh(_Symbol,_Period,0,Bars(_Symbol,_Period),High);
   ArraySetAsSeries(Time,true);
   CopyTime(_Symbol,_Period,0,Bars(_Symbol,_Period),Time);
   ArraySetAsSeries(Volume,true);
   CopyTickVolume(_Symbol,_Period,0,Bars(_Symbol,_Period),Volume);
} 
void OnTick()
{
        Set_Values_to_variables();
}
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], 
                const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[])     
{
        Set_Values_to_variables();
}
int Hour()
{
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.hour);
}
ENUM_TIMEFRAMES TFMigrate(int tf)
{
   switch(tf)
   {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);
      
      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      

      default: return(PERIOD_CURRENT);
   }
}

 

 Can some expert help me where is the problem ?

 

Cheer 

 
This code is a mix mql4 and mql5. Personally I don't have time to waste with such things sorry.
 
angevoyageur:
This code is a mix mql4 and mql5. Personally I don't have time to waste with such things sorry.

I don't see your name anywhere to do the job. I have seen your other posts too and felt the heat out of your posts.

No need for it. 

 
Shunmas:

I don't see your name anywhere to do the job. I have seen your other posts too and felt the heat out of your posts.

No need for it. 

?
 
angevoyageur:
?

You are saying "I don't have time to waste with such things". This is derogatory and I find it unnecessary for anyone here to write if he doesn't want to help. What is this forum for ? I posted a code to ask for some help. You said its a mixed code. If you don't want to help in anyway, no need to write that.

That's what I said. :)

 
Shunmas:

You are saying "I don't have time to waste with such things". This is derogatory and I find it unnecessary for anyone here to write if he doesn't want to help. What is this forum for ? I posted a code to ask for some help. You said its a mixed code. If you don't want to help in anyway, no need to write that.

That's what I said. :)

I helped you, for the last time, saying you this code is a mess and mix 2 languages. The forum isn't to get things for free. About programming, it's to help people who wants to learn to code, and post THEIR attempts.

If you want a coder, please use the Jobs section and don't waste time of people trying to help others. You never helps nobody here.

 
angevoyageur:

I helped you, for the last time, saying you this code is a mess and mix 2 languages. The forum isn't to get things for free. About programming, it's to help people who wants to learn to code, and post THEIR attempts.

If you want a coder, please use the Jobs section and don't waste time of people trying to help others. You never helps nobody here.

I don't want to argue with you but you are being rude now.

 

I am out of this. 

 
Shunmas:

I don't want to argue with you but you are being rude now.

 

I am out of this. 

Rude ?  where ?
 

Where is OrderMagicNumber() declared ?

Where is  OrderTakeProfit() declared ?

Where is  OrderModify() declared ?

Where is  OrderStopLoss() declared ?

Where is OrderLots() declared ?

Where is NormalizeDouble() declared ?

etc.

etc. 

 

do you really expect this code to compile ? 

Reason: