Event handling function

To add comments, please log in or register
VictorLyon
9
VictorLyon  

Hi, I have an error when I compile the follwing code;

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   double  Lots  =1;
   int     BandsPeriod       = 20;
   double  BandsDeviation    = 2;
   int     OpenDifference    =30;
   int     StopLossLevel     =400;
   int     TakeProfitLevel   =400;
   int   bollingerticket   =  0;
   
void Bollinger()
  {

   static bool UpperBandsBreak=False;
   static bool LowerBandsBreak=False;
   double BandsTop=iBands(Symbol(),0,BandsPeriod,BandsDeviation,0,PRICE_CLOSE,MODE_UPPER,0);
   double BandsLow=iBands(Symbol(),0,BandsPeriod,BandsDeviation,0,PRICE_CLOSE,MODE_LOWER,0);
   double ma      =iMA(Symbol(),Period(), BandsPeriod,0,0,0,1);

   if(Close[1]>BandsTop)
      UpperBandsBreak=True;
   if(Close[1]<BandsLow)
      LowerBandsBreak=True;

   if(UpperBandsBreak)
     {
      if(Bid<BandsTop-OpenDifference*Point  &&   Bid>ma)
        {
         bollingerticket=-1;
         UpperBandsBreak=False;
        }
      if(Bid<ma)
        {
         UpperBandsBreak=false;
        }
     }
   if(LowerBandsBreak)
     {
      if(Ask>BandsLow+OpenDifference*Point   &&   Ask<ma)
        {
         bollingerticket=1;
         LowerBandsBreak=False;
        }
      if(Ask>ma)
        {
         LowerBandsBreak=false;
        }

     }
  }

 

error: event handling function not found

I would like to include this expert advisor into an other one, which is why I don't use the OnTick() function there. But what else am I supposed to use? Why can't this just be the definition of a function, that I would only call in an other expert advisor?

Thanks

William Roeder
20217
William Roeder  
VictorLyon: Why can't this just be the definition of a function, that I would only call in an other expert advisor?

It is just the definition of a function. As such it is not an EA.

Put the code in an EA and call your function in an event handling function. Or make that file an include file and include it in your EA.

VictorLyon
9
VictorLyon  
William Roeder:

It is just the definition of a function. As such it is not an EA.

Put the code in an EA and call your function in an event handling function. Or make that file an include file and include it in your EA.

Thank you, I did not know about the Include file format.
To add comments, please log in or register