Including IsTradeAllowed() makes EA able to verify if the Expert Advisor is allowed to trade and trading context is not busy.
I am trying to find if there is any similar way to make EA able to verify if 'Disable experts when the profile has been changed' (MetaTrader 4 Tools >Options >Expert Advisors) is enabled or not.
I want to include that checking (and eventual warning to user) because although IsTradeAllowed() gave TRUE value as a result, when my EA tried to modify stop loss of open order, I got error 4109.
I don't think there is a mql4 function that can read those particular settings, but you can detect if an expert is allowed to run.
Check IsExpertEnabled() function.