______________________________________________________________________________________________________


1. ABSTRACT


One of the biggest problems that a trader faces is his ability to be disciplined and stick to his plan. With a strategy that controls the market through the defined parameters, we guarantee that if a trading opportunity arises this is executed without errors according to the programmed. An automated strategy, in turn, can also analyze more data successively than a human would achieve, making it easier to monitor multiple patterns at the same time.





2. INTRODUCTION

Following the previous article in April, I chose 2 patterns to present the code in JForex and study to what extent these patterns are profitable or not in forex. The chosen patterns were as follows:

Bullish Piercing Line:
This pattern is defined by a candle with a considerable body in which the next candle opens below the minimum of the previous candle, but closes above the middle, without exceeding the top. In this case, it is expected that the market is initiating a bullish move, thus altering the trend and initiating a new one.

Recognition Criteria:

  1. The market is characterized by a prevailing downtrend.
  2. A bear candlestick appears on the first observation.
  3. A bull candlestick opens on the second observation and closes more than halfway into the body of the first bear candle observed.
  4. The second candle fails to close above the body of the first candle, but the close of the bullish candle must be beyond a 60% u-turn of the bearish candle.
  5. When you see this: BUY in the direction of the trend at the opening of the next candle or when it meets the criteria of the Bullish Piercing Line. The stop loss level is defined as the last low.

Bearish Dark Cloud Cover:
This pattern is defined by a candle with a considerable body in which the next candle opens above the maximum of the previous candle, but closes below the middle, without exceeding the bottom. In this case, it is expected that the market is initiating a bearish move, thus altering the trend and initiating a new one.

Recognition Criteria:

  1. The market is characterized by a prevailing uptrend.
  2. A bull candlestick appears on the first observation.
  3. A bear candlestick opens on the second observation and closes more than halfway into the body of the first bull candle observed.
  4. The second candle fails to close below the body of the first candle, but the close of the bearish candle must be beyond a 60% u-turn of the bullish candle.
  5. When you see this: SELL in the direction of the trend at the opening of the next candle or when it meets the criteria of the Bearish Dark Cloud Cover formation. The stop loss level is defined as the last high.

Obviously if we translate this vision of the patterns into the strategy code, the results will not be the best, so I opted to add some filters in the strategy to just open the orders when the result was more accurate.


3. CODE PRESENTATION

The code has been kept as simple as possible so that more members of this community understand what's in each line of the strategy program.
Like any other strategy, this strategy has several parameters defined at the beginning that we can change depending on whether your behavior suits the various studies made during its development, in order to achieve the best results in the various backtests made. In the next image you can see the main parameters that can influence the final results of the strategy.




The strategy only works on the closing of the candle. In the next block of code, the value of the SMA and other necessary values are read so that the logic of the strategy works according to the defined parameters.




For the strategy open a BUY order through the Bullish Piercing Line conditions, the following 2 code blocks are displayed. As I mentioned earlier other filters are used, such as the case where the price has to be above the SMA to open a buy or, conversely, below the SMA to open a sell. Another filter is the verification of 3 consecutive bear candles so that the reversing bar is validated. Finally, the candle overlap value is calculated to determine if the condition of the pattern is valid. Conversely, Bearish Dark Cloud Cover conditions are calculated for the strategy to open a SELL order.




4. STRATEGY RESULTS

The strategy and its parameters were optimized for a specific period of time, where the patterns described were profitable. I will present the results obtained during the period from 1st February 2017 to 23rd June 2017. In the following images you can verify that in a 100k account, at the end of the period tested the result was a return of more than 61% , without ever putting the account at risk.











5. CONCLUSION

This article was written with the intention of continuing my article of the month of April, where I described several patterns that could be profitable if applied to the forex market.
As you realize this article is purely didactic, not being guaranteed any kind of profitability if you use such a strategy.
I will make available in the FORUM the complete code, so that whoever wants to test and try to optimize even more the strategy, can do it.

6. REFERENCES

[1] http://www.candlesticker.com/?lang=en
[2]
https://www.markettraders.com/downloads/candlestick-cheat-sheet-RGB-FINAL.pdf
[3]https://www.dukascopy.com/fxcomm/fx-article-contest/?Theory-For-Reversal-Candle-Patterns&action=read&id=3781
Translate to English Show original