Open mavidelisi opened 1 year ago
In general, Heiken Ashi indicator produces OHLC candles which are more smooth to regular one. So the strategy have to work on candle pattern conditions.
In general, I don't think there is a particular problem with the logic, it's how the strategy was written and optimized, and how the list of pattern is structured.
Let me explain the logic behind it (code as per v1.013):
case ORDER_TYPE_BUY:
_result &= _method == 0 ? PatternCandle2::CheckPattern(PATTERN_2CANDLE_BULLS, _ohlc) : PatternCandle1::CheckPattern(PATTERN_1CANDLE_BULL, _ohlc[0]);
_result &= _method > 0 ? PatternCandle3::CheckPattern((ENUM_PATTERN_3CANDLE)(1 << (_method - 1)), _ohlc) : _result;
_result &= _method < 0 ? PatternCandle4::CheckPattern((ENUM_PATTERN_4CANDLE)(1 << -(_method + 1)), _ohlc) : _result;
break;
case ORDER_TYPE_SELL:
_result &= _method == 0 ? PatternCandle2::CheckPattern(PATTERN_2CANDLE_BEARS, _ohlc) : PatternCandle1::CheckPattern(PATTERN_1CANDLE_BEAR, _ohlc[0]);
_result &= _method > 0 ? PatternCandle3::CheckPattern((ENUM_PATTERN_3CANDLE)(1 << (_method - 1)), _ohlc) : _result;
_result &= _method < 0 ? PatternCandle4::CheckPattern((ENUM_PATTERN_4CANDLE)(1 << -(_method + 1)), _ohlc) : _result;
break;
Code explanation:
_method
is positive or negative (in case of 0, only 1st condition is activated)._method
is above 0, 2nd condition is activated which checks for 3 candle pattern where _method is the n-pattern from the list._method
is below 0, 3rd condition is activated which checks for 4 candle pattern where _method is the n-pattern from the list._method
value for open is -9
- means to open the trade when 10th (9+1) 4-candle pattern is present (where BarOHLC _ohlc[4]
actually extracts last 4 HA candles converted from HA indicator values)._method
value for close is 4
means to close the trade when 3th (4-1) 3-candle pattern is present.Pattern.enum.h
and logic written in Pattern.struct.h
.So the issue here is more in selected method that these patterns aren't neutral, but open signal is focused more on bull pattern. So the problem is that on open signal, we expect only one pattern shared across both buy and sell which is kind of limitation.
What the code should have is to have look for different/separate patterns for buy and sell. This has been already solved in Pattern strategy where _method value have information about 2 patterns (one for buy, another for sell). I'm going to revise this strategy and improve its logic based on it, so buy and sell could have different patterns being set.
Another way is to refactor Pattern code and organize enums by split them into 3 categories: bullish, bearish and neutral. But I'm not sure at this point if that's possible (to categorize) with all the patterns.
At this point, you'll have to re-optimize Signal open/close method params so the trades works better.
just like you said, I changed the logic and open signal parameters. Bull continuation and bear continuation values (UDDU and DUUP) are different. i just made a few changes to the logic part of the heiken ashi strategy. thank you. i solved the problem.
Hi Kenorb;
Heiken Ashi strategy is constantly opening a Buy position .
I have constantly changed the parameters, but it still opens the buy position. In no way is sell opening the position. Can you check the source code? Is there a bug, I wonder?
Thanks.