`IsTradeAllowed()`: undeclared identifier.

 

I am trying to use `IsTradeAllowed()` function to know whether I can use auto trader or not. I also want to check whether I can trade the current symbol at this current time. What I want is to create a pre order sending for 2 things whether I can use auto trading and whether I can trade Symbol at  this current time current time. I don't think so I made a mistake in typing the function because while tying the function does not pop up as recommendation nor the function changes the color (indicating in built function). Am I missing something like #include files...

I am open to use any other functions, which caters the above requirements. Forgive me if I have asked a silly question, I am stuck on this for hours and can't seem to find any solution. Thank you.

 
varun_19:

I am trying to use `IsTradeAllowed()` function to know whether I can use auto trader or not. I also want to check whether I can trade the current symbol at this current time. What I want is to create a pre order sending for 2 things whether I can use auto trading and whether I can trade Symbol at  this current time current time. I don't think so I made a mistake in typing the function because while tying the function does not pop up as recommendation nor the function changes the color (indicating in built function). Am I missing something like #include files...

I am open to use any other functions, which caters the above requirements. Forgive me if I have asked a silly question, I am stuck on this for hours and can't seem to find any solution. Thank you.

Hi Varun_19, dear friend

plz check this function

I hope this function to be useful, and let me know what did you do


bool isTradingAllowed()
  {
   if(!IsTradeAllowed())
     {
      return(False);
     }
   else
      if(!IsTradeAllowed(Symbol(),TimeCurrent()))
        {
         return(False);
        }
   return(True);
  }
 
varun_19: I am trying to use `IsTradeAllowed()` function to know whether I can use auto trader or not. I also want to check whether I can trade the current symbol at this current time. What I want is to create a pre order sending for 2 things whether I can use auto trading and whether I can trade Symbol at  this current time current time. I don't think so I made a mistake in typing the function because while tying the function does not pop up as recommendation nor the function changes the color (indicating in built function). Am I missing something like #include files... I am open to use any other functions, which caters the above requirements. Forgive me if I have asked a silly question, I am stuck on this for hours and can't seem to find any solution. Thank you.

There is no such function as "IsTradeAllowed" in MQL5.

There is however a class method with that name for the CTerminalInfo class from the MQL5 Standard Library, which simply uses the TerminalInfoInteger() function with the TERMINAL_TRADE_ALLOWED property.

Documentation on MQL5: Standard Library / Trade Classes / CTerminalInfo
Documentation on MQL5: Standard Library / Trade Classes / CTerminalInfo
  • www.mql5.com
CTerminalInfo - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

There is no such function as "IsTradeAllowed" in MQL5.

There is however a class method with that name for the CTerminalInfo class from the MQL5 Standard Library, which simply uses the TerminalInfoInteger() function with the TERMINAL_TRADE_ALLOWED property.

bool is_allowed(){
    int result = TerminalInfoInteger(TERMINAL_TRADE_ALLOWED);
    if(result == 1)
      {
       return true;
      }
    else
      {
       return false;
      }
}

This is the function for checking whether auto trading is allowed or not, and it totally worked. But Can you suggest me a function for whether the current symbol is allowed for trading at the current time. 
 
varun_19 #: But Can you suggest me a function for whether the current symbol is allowed for trading at the current time. 

Please read up on ...

SymbolInfoSessionQuote

Allows receiving time of beginning and end of the specified quoting sessions for a specified symbol and day of week.

SymbolInfoSessionTrade

Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week.

And also see the following as well:

bool  bAccountTradeAllowed       = AccountInfoInteger(  ACCOUNT_TRADE_ALLOWED  ),
      bAutomatedTradeAllowed     = AccountInfoInteger(  ACCOUNT_TRADE_EXPERT   ),
      bTerminalTradeAllowed      = TerminalInfoInteger( TERMINAL_TRADE_ALLOWED ),
      bProgramTradeAllowed       = MQLInfoInteger(      MQL_TRADE_ALLOWED      );
Reason: