Free Weekly Strategy #1
Our free weekly strategy series is dedicated to bringing you new long term trading ideas. As always, we (highly) encourage you to take the concepts and code we present in this post and expand upon them to make a system that fits your trading style—if you have an idea that you would like to see implemented, or want to discuss how to implement a great idea, we’d love to hear from you!
This weeks trading strategy is a strategy dedicated to the ES and SPY. When we test strategies on the ES, we require them to have a consistent level of performance on the SPY—even though the ES and SPY move in unison, we test hundreds of strategies that don’t perform the same on the ES and SPY. The NinjaTrader specific settings we use during backtesting are:
- Commission: NinjaTrader Brokerage Lifetime
- Order fill resolution: Standard (Fastest)
- Fill limit orders on touch: false
- Slippage: 1 tick
- Session template: Use instrument settings (unless otherwise specified)
Now that we have the boring stuff out of the way, let’s get down to the rules and why we think they work—our rules will be simple, but powerful.
- Current Close below the EMA(3)—we want price in a “retracement” before we get long.
- Current Open is greater than the current OHLC ((Open + High + Low + Close) / 4)—even though we want a “retracement” scenario in #1, we want the current bar to open strong by opening greater than the prior bars OHLC.
- Current Volume is less than or equal to Volume 1 bar ago—we also want to see “demand” leaving (or the same) in the market.
- Finally, since we see weakness in #1 and #3, but strength in #2, we want to confirm our entry with a strong move in either direction based on the close. If the market has gained strength, the Close should be greater than the max of the prior bars Close or Open. If the current bar saw weakness, we should see the current Close less than minimum of the the prior bars Open or Close. The only scenario we don’t want to see is a weak bar (even if it’s in the wrong direction).
- Exit when either: 1) there have been 5 bars that close in profit, or 2) the position has been open for 10 bars.
The following is what the code would look like in NinjaTrader:
double xOHLC = (Open + High + Low + Close) / 4.0;
// Entry Conditions
if(Close < EMA(3)
&& Open > xOHLC
&& Volume <= Volume
&& (Close < Math.Min(Open, Close) || Close > Math.Max(Open, Close)))
ES – Daily Chart – 1 Contract – 1/18/2005 – 7/18/2017
SPY – Daily Chart – 100 Shares – 1/24/1996 – 7/18/2017
First, we believe optimization can be a beneficial tool, but it must be used with caution and any changes made to the underlying strategy must be rationale and well thought through. We will run three scenarios, using max net profit, in NinjaTrader: 1) optimize the rules from #5 above, 2) optimize using a stop loss and profit target, and 3) optimize #1 and #2 combined:
- Rule #5 (from above): the settings with the best performance (for both settings) had a value between 5 and 10 (our optimization range was 1 – 30).
- Stop loss and profit target: the settings with the best performance for profit target had a value between 460 – 480 and for stop loss had a value between 250 – 280 (our optimization range was 100 – 500).
- For the final optimization, we will optimize #1 based on the range 5 – 10 and optimize #2 based on the profit target range 450 – 500 and the stop loss range between 250 – 300.
Based on the final optimization, the optimized settings are:
- Profit target: 474 ticks
- Stop loss: do not use
- Exit when either: 1) there have been 5 bars that close in profit, or 2) the position has been open for 10 bars
We want our optimized settings to work well on both the ES and SPY, so we will test the above settings on SPY, but first we want to make sure we note that the profit target value being a very specific number is a clear indication of curve fitting. Also, this target amount was likely found to be a peak on one or two trades, giving the best performance, but it is unlikely that this will be a continued trend in the future performance statistics:
When we optimized the inputs for the ES, net profit increased marginally, but when we tested those settings on the SPY, net profit decreased. Optimization does not always work and in our case, it did not help our strategy, so we are sticking with our default settings. If you would like to test the strategy on your NinjaTrader, you can download the open source strategy here.
HYPOTHETICAL PERFORMANCE DISCLAIMER: HYPOTHETICAL PERFORMANCE RESULTS HAVE MANY INHERENT LIMITATIONS, SOME OF WHICH ARE DESCRIBED BELOW. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN; IN FACT, THERE ARE FREQUENTLY SHARP DIFFERENCES BETWEEN HYPOTHETICAL PERFORMANCE RESULTS AND THE ACTUAL RESULTS SUBSEQUENTLY ACHIEVED BY ANY PARTICULAR TRADING PROGRAM. ONE OF THE LIMITATIONS OF HYPOTHETICAL PERFORMANCE RESULTS IS THAT THEY ARE GENERALLY PREPARED WITH THE BENEFIT OF HINDSIGHT. IN ADDITION, HYPOTHETICAL TRADING DOES NOT INVOLVE FINANCIAL RISK, AND NO HYPOTHETICAL TRADING RECORD CAN COMPLETELY ACCOUNT FOR THE IMPACT OF FINANCIAL RISK OF ACTUAL TRADING. FOR EXAMPLE, THE ABILITY TO WITHSTAND LOSSES OR TO ADHERE TO A PARTICULAR TRADING PROGRAM IN SPITE OF TRADING LOSSES ARE MATERIAL POINTS WHICH CAN ALSO ADVERSELY AFFECT ACTUAL TRADING RESULTS. THERE ARE NUMEROUS OTHER FACTORS RELATED TO THE MARKETS IN GENERAL OR TO THE IMPLEMENTATION OF ANY SPECIFIC TRADING PROGRAM WHICH CANNOT BE FULLY ACCOUNTED FOR IN THE PREPARATION OF HYPOTHETICAL PERFORMANCE RESULTS AND ALL WHICH CAN ADVERSELY AFFECT TRADING RESULTS.