如何在没有DLL的情况下从MQL4 / 5程序(EA)全局禁用自动交易?

时间:2016-06-04 17:21:07

标签: algorithmic-trading mql4 metatrader4 mql5 metatrader5

如何在不使用DLL的情况下从MQL4 / 5代码中在MetaTrader 4/5中全局禁用自动交易?

1 个答案:

答案 0 :(得分:0)

是的,MQL4/5 专家顾问可以在当地禁止自己以这种方式进行交易:

if (  IsTradeAllowed() )
{     Comment( __FILE__, " [EA] Trading is allowed, will disable self." );
      ...
}
else
{    Comment( __FILE__, " [EA] Trading is not allowed, will disable self." );
     ...
}
// ---------------------------------------//   GRACEFULLY RELEASE ALL RESOURCES BEFORE FIN'd

// ********
// FINALLY:    EXPERT-ADVISOR SIG_TERM -> self ( MT4 )
   ExpertRemove();                        /*     MT4 The Expert Advisor
                                                     is not stopped immediately
                                                     as you call ExpertRemove();
                                                     just a flag to stop the EA operation is set.
                                                     That is:
                                                     - any next event won't be processed,
                                                     - OnDeinit() will be called
                                                     and
                                                     - the Expert Advisor will be unloaded and removed from the chart.
                                                 */