What does it mean 'function must have a body'?

To add comments, please log in or register
mygreensun
157
mygreensun  

My coding is using IsNewBar function as below; 

After compiling, there is an error message that 'IsNewBar' - function must have a body

What should I modify for my coding??

input double Lotsize=1.0;
input int Slippage=10;
input int Stoploss=30;
input int Takeprofit=30;

input int MAPeriod=20;
input int MAShift=0;
input ENUM_TIMEFRAMES MATimeFrame=PERIOD_M30;
input ENUM_MA_METHOD MAMethod=MODE_SMA;
input ENUM_APPLIED_PRICE MAPrice=PRICE_CLOSE;
bool IsNewBar (string symbol, ENUM_TIMEFRAMES timeframe);

void OnTick()
   {
   double MA=iMA(NULL, MATimeFrame, MAPeriod, MAShift, MAMethod, MAPrice, 0);
    
   if (IsNewBar (Symbol(), PERIOD_M30))
   {
   if (Close[1] > MA)
   {
   OrderSend(Symbol(),OP_BUY, Lotsize, Ask, Slippage, 0, 0, "1", 2, 0, clrGreen);
   }
   }
   }

Kenneth Parling
9508
Kenneth Parling  
mygreensun:

My coding is using IsNewBar function as below; 

After compiling, there is an error message that 'IsNewBar' - function must have a body

What should I modify for my coding??

input double Lotsize=1.0;
input int Slippage=10;
input int Stoploss=30;
input int Takeprofit=30;

input int MAPeriod=20;
input int MAShift=0;
input ENUM_TIMEFRAMES MATimeFrame=PERIOD_M30;
input ENUM_MA_METHOD MAMethod=MODE_SMA;
input ENUM_APPLIED_PRICE MAPrice=PRICE_CLOSE;
bool IsNewBar (string symbol, ENUM_TIMEFRAMES timeframe);

void OnTick()
   {
   double MA=iMA(NULL, MATimeFrame, MAPeriod, MAShift, MAMethod, MAPrice, 0);
    
   if (IsNewBar (Symbol(), PERIOD_M30))
   {
   if (Close[1] > MA)
   {
   OrderSend(Symbol(),OP_BUY, Lotsize, Ask, Slippage, 0, 0, "1", 2, 0, clrGreen);
   }
   }
   }

To answer your topic question - define a function as a body of code that is returning a value or executing a task

To add comments, please log in or register