Wrong parameter count?

 

Hello, 

I've been trying to add a true/false input for use of time filter, however i get the below error. Probably missing something obvious. Any help is greatly appreciated.

'fCheckTradingTime' - Wrong parameter count

inputs 

input bool useTradeTimeFilter = true;

input string InpStartTime = "01:00";

input string InpStopTime = "23:00";


time filter code

bool fCheckTradingTime(bool useTradingTimeFilter)

{

   bool tradeallowd = true;

      if (useTradeTimeFilter)

   {

      if(StringToTime(CurrentTime)>=StringToTime(InpStartTime) && StringToTime(CurrentTime)<=StringToTime(InpStopTime))

      {

         tradeallowd = true;

      }

      else

      {

         tradeallowd = false;

      }

   }

      return tradeallowd;

}

getting error in on tick, with following lines

 if(Localtime>waitTime && fCheckTradingTime())

and

if(fCheckTradingTime()==false)


again could possibly be missing something simple. but for the life of me cant see it. any help is greatly appreciated 

Documentation on MQL5: Trade Functions / OrderCalcProfit
Documentation on MQL5: Trade Functions / OrderCalcProfit
  • www.mql5.com
OrderCalcProfit - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Please edit your post (don't create a new post) and replace your code properly (with "</>" or Alt-S), or attach the original file directly with the "+ Attach file" button below the text box.

NB! Very important! DO NOT create a new post. EDIT your original post.

 

You have defined your function as requiring a boolean parameter:

bool fCheckTradingTime( bool useTradingTimeFilter ) { ... }

Yet when you call the function, you don't supply an argument for the parameter that you declared for the function:

fCheckTradingTime(     )
 

okay, so should this be 

fCheckTradingTime(useTradingTimeFilter)

or am i missing something?

 

You are reusing variable names for different scopes. Just because they have the same name does not make them the same variable.

They have different scopes. One is an input and the other a parameter.

input bool useTradeTimeFilter = true;
bool fCheckTradingTime( bool useTradingTimeFilter ) { ... }
 
okay, thought they would be the same, what would you recommed
 

Use different names so that you don't get confused.

input bool i_useTradeTimeFilter = true;

...

bool fCheckTradingTime( bool useTradingTimeFilter ) { ... };

...

if( !fCheckTradingTime( i_useTradeTimeFilter ) )  ... 
 
that makes sense, thanks for your help
 
jack3394 #: that makes sense, thanks for your help
You are welcome!