Skip to content

Commit

Permalink
EA: Fixes bug in GetStrategySignalEntry() with close filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Oct 17, 2021
1 parent 502cc1f commit 680ba2a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion EA.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class EA {
_signals |= !_strat.SignalCloseFilter(ORDER_TYPE_BUY, _scfm) ? SIGNAL_CLOSE_BUY_FILTER : 0;
_signals |= _strat.SignalClose(ORDER_TYPE_SELL, _scm, _scl, _ss) ? SIGNAL_CLOSE_SELL_MAIN : 0;
_signals |= !_strat.SignalCloseFilter(ORDER_TYPE_SELL, _scfm) ? SIGNAL_CLOSE_SELL_FILTER : 0;
_signals |= !_strat.SignalCloseFilterTime(_scfm) ? SIGNAL_OPEN_TIME_FILTER : 0;
_signals |= !_strat.SignalCloseFilterTime(_scft) ? SIGNAL_CLOSE_TIME_FILTER : 0;
TradeSignalEntry _sentry(_signals, _strat.Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF), _strat.Get<long>(STRAT_PARAM_ID));
_sentry.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_STRENGTH), _strat.SignalOpen(_sofm, _sol, _ss));
_sentry.Set(STRUCT_ENUM(TradeSignalEntry, TRADE_SIGNAL_PROP_TIME), ::TimeGMT());
Expand Down
5 changes: 3 additions & 2 deletions Strategy.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct StgParams {
sl_max(0),
type(0),
refresh_time(0) {}
StgParams(int _som, int _sofm, float _sol, int _sob, int _scm, int _scf, float _scl, int _psm, float _psl, int _tfm,
StgParams(int _som, int _sofm, float _sol, int _sob, int _scm, int _scfm, float _scl, int _psm, float _psl, int _tfm,
float _ms, short _s = 0)
: id(rand()),
order_close_loss(0.0f),
Expand All @@ -121,7 +121,8 @@ struct StgParams {
signal_open_level(_sol),
signal_open_boost(_sob),
signal_close_method(_scm),
signal_close_filter_method(_scf),
signal_close_filter_method(_scfm),
signal_close_filter_time(0),
signal_close_level(_scl),
price_profit_method(_psm),
price_profit_level(_psl),
Expand Down
8 changes: 8 additions & 0 deletions Trade/tests/TradeSignalTest.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ bool TestTradeSignalOpenBuyWithoutFilters() {
// 2nd method.
TradeSignalEntry _entry2;
_entry2.Set(SIGNAL_OPEN_BUY_MAIN, true);
_entry2.Set(SIGNAL_CLOSE_BUY_MAIN, true); // This should not affect anything.
_entry2.Set(SIGNAL_CLOSE_BUY_FILTER, true); // This should not affect anything.
_entry2.Set(SIGNAL_CLOSE_SELL_FILTER, true); // This should not affect anything.
_entry2.Set(SIGNAL_CLOSE_SELL_MAIN, true); // This should not affect anything.
TradeSignal _signal2(_entry2);
_result &= !_signal2.ShouldClose(ORDER_TYPE_BUY);
_result &= !_signal2.ShouldClose(ORDER_TYPE_SELL);
Expand Down Expand Up @@ -247,6 +251,10 @@ bool TestTradeSignalOpenSellWithFilters() {
_entry2.Set(SIGNAL_OPEN_SELL_MAIN, true);
_entry2.Set(SIGNAL_OPEN_SELL_FILTER, true);
_entry2.Set(SIGNAL_OPEN_TIME_FILTER, true);
_entry2.Set(SIGNAL_CLOSE_BUY_FILTER, true); // This should not affect anything.
_entry2.Set(SIGNAL_CLOSE_BUY_MAIN, true); // This should not affect anything.
_entry2.Set(SIGNAL_CLOSE_SELL_FILTER, true); // This should not affect anything.
_entry2.Set(SIGNAL_CLOSE_SELL_MAIN, true); // This should not affect anything.
TradeSignal _signal2(_entry2);
_result &= !_signal2.ShouldClose(ORDER_TYPE_BUY);
_result &= !_signal2.ShouldClose(ORDER_TYPE_SELL);
Expand Down

0 comments on commit 680ba2a

Please sign in to comment.