Trading Idea #016 – Forex Swing 1

This Forex Swing idea is from an article in the April 2021 issue of Technical Analysis of Stocks & Commodities (TASC).  TASC is always a good resource for trading ideas, so I thought the trading system suggested in the article “A Simple Forex Trend-Following Strategy”, by Azeez Mustapha, would be fun to try. 

The general idea here is just a forex swing trade riding the coattails of a trend.  We use 3 simple moving averages, 8, 13, and 21 periods, to determine the trend and wait for a pull-back.  After pullback, if we see the correct bar pattern (engulfing bar or pin bar), then we go in the direction of the trend.  You may recognize these periods (8, 13, 21) as part of the Fibonacci sequence.  I do not have time this time to explain why using Fibonacci numbers is significant, but I promise to explain this in a later system idea I have planned.

This system has enough complexity to make it interesting.  Also, forex is really not my area of expertise, so this will be interesting and a learning experience.  Enough chit-chat; let’s go!

Phase 1: Plan & Design

1. Trading Idea

First, we need to evaluate the 8, 13, and 21 period simple moving averages (SMA), as shown here: 

Continuing with this example, once these conditions are met, then we are looking for one of two candlestick bar types:

Bullish pin bar

Bullish engulfing

Once we have these conditions established, we set a limit order 3 pips above the confirmation candle.  Once in the trade, we set a stop order 3 pips below the confirmation candle.  With these data points, we calculate our Risk.  We take profit at 2 times Risk.  The article also suggests moving our stop to break even once we achieve a profit >= 1 times Risk.  We could also use a trailing stop, but for this idea, we will stick with profit of 2x, which should equate roughly to a profit factor of 2.0. 

For short positions, we look for the exact opposite conditions, naturally. Since this was suggested for forex, that is what we will do here. 

2. System Definition

Position Sizing:

I will use the following position sizing:

  • Forex: 100,000 units (e.g., $100,000 USD)

Input Parameters:

No inputs are needed for this system.

Variables:

VariableData TypeDefaultCalculation
SMA8Double08-period SMA, using Close
SMA13Double013-period SMA, using Close
SMA21Double021-period SMA, using Close
BullEngBooleanfalseIf bar is Bullish Engulfing, then True, else False
BullPinBooleanfalseIf bar is Bullish Pin, then True, else False
BearEngBooleanfalseIf bar is Bearish Engulfing, then True, else False
BearPinBooleanfalseIf bar is Bearish Pin, then True, else False
LongLowDouble0Low of the confirmation bar on a buy signal
ShortHighDouble0High of the confirmation bar on a sell short signal
LongRiskDouble0(Entry Price – LongLow + .0003) ; this is per unit
ShortRiskDouble0(ShortHigh – Entry Price + .0003( ; this is per unit

Entry:

  • Long:
    • If Market Position = flat and
    • (BullEng = true or BullPin = true) and
    • SMA8 > SMA13 and
    • SMA13 > SMA21 and
    • Low < SMA8
    • Buy 100,000 shares next bar at (High + .0003) limit
  • Short:
    • If Market Position = flat and
    • (BullEng = true or BullPin = true) and
    • SMA8 > SMA13 and
    • SMA13 > SMA21 and
    • Low < SMA8
    • Sell short 100,000 shares next bar at (Low – .0003) limit
  • Profit targets: 2 times LongRisk or ShortRisk, depending upon direction of trade
  • Stop Loss: 1 times LongRisk or ShortRisk, depending upon direction of trade

Challenges: None. 

3. Performance Objectives

The system will meet the following objectives:

ObjectiveGoal
System Type (trend, mean-reversion, day, swing, etc.)Swing
Walk-forward Efficiencyn/a
Risk of Ruin0%
Profit Factor>= 2.0
Win Percent>= 50%
Max Drawdown %< 35%
Profit/Drawdown Ratio>= 2.0
Ready Date2021/05/21

This idea is S.M.A.R.T.: Specific, Measurable, Achievable, Realistic, Time-bound

4. Market Selection

Markets:

EnergiesCurrenciesFixed IncomeAgricultureMetalsSoftsIndexesEquities
X

Instruments:

Market SectorInstrumentSymbolComments
CurrenciesForex onlyEUR/USD AUD/NZD USD/CHF 

Chart Type, Timeframe, Session, Time Zone:

AttributeValueComments
Chart TypeRegular CandlestickCharting is only useful for validating entry and exit signals
Timeframe / Interval(s)Daily, 4 hour, 1 hourI am using the recommended timeframes, though 4 hour is the recommended timeframe
SessionRegular 
Time ZoneExchange 

Phase 2: Build

5. Manual Test

It was kind of hard to identify the bar types (pin or engulfing), but I found a few and it looks like this might work. 

6. Build

Process Diagram

Comments:

This was a little difficult to diagram.  I have some other code that I reused to help build this.  For this, I created functions to identify the four different candlestick formations (engulfing, pin) that are part of our entry criteria.

7. Unit Test

The unit test was terrible.  Ultimately everything worked, but validating it was misery.  The more rules and conditions that are added, the worse testing (and results) tend to be.  It worked, but it was a pain. 

Complete?

Note: Unit Test verifies that the system is executing the trading rules correctly.  It is, essentially, quality control.

Phase 3: Test

8. Optimization

Party time… no optimization needed! 

9. Walk-Forward Analysis

In case you are wondering, this is what doing walk-forward analysis on 3 instruments and 3 timeframes looks like:

Party time is over, everything failed at Profit Factor:

10. Monte Carlo Simulation

Nothing passed, so not Monte Carlo Simulation this time.

11. Incubation

We did not make it this far. 

Phase 4: Deploy

We did not make it this far.

Trading System Result: FAIL

Notes and Commentary

This system was a whole bunch of sturm und drang (storm and drive), with not a lot to show for it.  The system was hard to ideate (step 1), difficult to define (step 2), frustrating to build and unit test (steps 6-7), and ultimately disappointing when it failed.  Why did it fail?  Here some observations:

  1. Discretionary trading is very difficult to translate into code, mainly because of, well…trader’s discretion.  This idea likely works for the author, but it would likely fail as an automated system.    
  2. Some ideas that may work in the near term are not valid over longer testing periods.  Although I only used just over 6 years of data, there were good and bad periods.  I do not expect looking back any further would improve the trading results.
  3. There are too many rules, making me feel like I was tying myself in a knot.  I have found that the fewer the rules, the more robust the system.  This partially explains my skepticism over AI and deep learning/machine learning in trading, at least for now.
  4. It is entirely possible that I misinterpreted the system or made an error.  Back to point 3, having too many rules makes too many places where the code can break.

It was fun defining the rules for the pin bars and engulfing bars.  Working through the code was like doing a puzzle or brainteaser, so that was fun.  Initially I ran into some issues with the accuracy of the testing and the orders, but I was able to work out the kinks in the end.

Although I do not plan to revisit this idea for a while, here are Improvements for next time:
  • Use an adaptive moving average, such as the KAMA, to stick with the trade and help us with our exits, thus turning this into more of a trend following system.
  • Use an ATR based stop loss and take profit, balancing us at about 1:2 risk/reward ratio.  I like the ATR idea better, because I noticed that if we just use the confirmation bar for our risk/reward calculation, I found that it could be a very big bar, which could make it difficult to take any profit out on subsequent smaller bars.

That is all for this system. Thanks for reading and I hope you enjoyed.  Feel free to leave a comment below and let me know what you think.

Next time’s idea: Am I a better trader than a kindergartener?  Check back next Friday and see the system that is so simple a kindergartner can trade it (but can he/she develop it?).

Sources/References

Did you like what you read? Do you want to see more?  Subscribe now and receive our email twice per month, with a new Trading System Idea and other fun stuff.

Don’t worry, we will never, ever, ever sell, overuse, or donate your email address. Promise.

Did you like what you read? Do you want to see more?  Subscribe now and receive our email twice per month, with a new Trading System Idea and other fun stuff.

Don’t worry, we will never, ever, ever sell, overuse, or donate your email address. Promise.

Leave a Reply

Your email address will not be published. Required fields are marked *