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

 

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);
   }
   }
   }

 
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

 
Replace
bool IsNewBar (string symbol, ENUM_TIMEFRAMES timeframe);

with

bool IsNewBar (string symbol, ENUM_TIMEFRAMES timeframe)
  {
   ...your code here
  }


https://www.mql5.com/en/forum/211945

How to detect NEW Bar?
How to detect NEW Bar?
  • 2017.07.24
  • www.mql5.com
How to detect NEW Bar? I want to reset my indicator variables if there's a new bar...
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.

    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 programming forum