stock index futures – Helping you Master EasyLanguage https://easylanguagemastery.com Helping you Master EasyLanguage Wed, 27 Nov 2024 17:23:03 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://easylanguagemastery.com/wp-content/uploads/2019/02/cropped-logo_size_icon_invert.jpg stock index futures – Helping you Master EasyLanguage https://easylanguagemastery.com 32 32 Adapting to Volatility: Strategic Position Sizing for Algorithmic Traders https://easylanguagemastery.com/building-strategies/percent-risk-and-volatility-2/?utm_source=rss&utm_medium=rss&utm_campaign=percent-risk-and-volatility-2 https://easylanguagemastery.com/building-strategies/percent-risk-and-volatility-2/#comments Mon, 02 Dec 2024 11:00:18 +0000 http://systemtradersuccess.com/?p=2748

I’m going to show you how to turn a good system into an amazing system with just a few lines of code! Adding these few lines of code could make you an additional $10k, $25K or even $50K in profits instantly.

Today we’re going to take my Better Breakout Strategy, which is a day trading strategy and dramatically improve it’s ability to generate profit. The simple technique I’m going to show you can easily be applied to any of your trading systems allowing you to generate 10s of thousands of more dollars quickly.

Let’s start with a thought experiment.

Explain This Mystery?

Say we have two traders who are each given identical trading systems to execute on the NASDAQ futures market (@NQ).  Because both systems are identical copies of an automated trading system, both trading systems generate the same buy/sell signals, use identical stop loss and trailing stop parameters.

These two traders are also going to start trading on the same day, with the same starting account size.  In essence let’s pretend we have two traders that have identical trading circumstances. Let's give these two traders 12 months to trade.  At the end of the trading period, we would expect them to have the same account balance, right?

But at the end of the trading period, reality has made fools of us. One trader generated more net profit. How can this be?

Reviewing the trading results for both traders you can see both traders took the same signals. Both traders have the same win/loss ratio and even the same number of stop-out trades. But there is one difference.

One trader used a simple mathematical formula to determine how many shares to buy and thus, his account grew at a faster rate.

What is Position Sizing

Position sizing is a critical component of both systematic and discretionary trading, addressing the pivotal question: How many shares or contracts should I purchase?

Far too often, the answer is derived from nothing more than a well-informed guess. A common misstep among traders is to size their trades without considering risk, potentially undermining their results, their trading systems, and, in some cases, their careers as algorithmic traders!

By anchoring your trade size to a risk metric, you adopt a defensive stance against the unpredictability of the market. Risk management should be paramount for any trader aiming for long-term success. Therefore, employing a risk-based metric to mathematically size your trades is not just recommended; it's essential. Despite this, the common practice involves using a fixed number of shares or allocating a fixed dollar amount per trade. Let's pause to consider the implications.

Imagine your trading system signals a new buy opportunity. You could, theoretically, risk your entire cash balance on this single signal. A win might double your money swiftly, but a loss could deplete your account entirely. It's evident that staking your whole account on one trade is a gamble far too risky for any prudent investor. This extreme example illustrates a fundamental truth: risking your entire trading capital on a single trade is recklessly imprudent.

So, what's the prudent amount to wager? Maybe 90% of your account? Or perhaps you decide on purchasing 100 shares. Many system developers overlook how trade size influences the risk-reward dynamic of a trade.

As the risk increases, so does the potential reward. Yet, overextend your risk, and a few losing trades could decimate your account. Theoretically, there's an optimal balance between risk and reward specific to each trading system.

Your mission is to identify a nearly optimal level that aligns with your comfort as a trader. While delving into the intricacies of finding an optimal position sizing strategy for a specific trading system is beyond the scope of this discussion, I will illustrate the difference between employing a risk-based position sizing algorithm and simply buying a fixed number of shares—the latter being a common practice that neglects risk metrics, thereby failing to adjust trade sizes according to market conditions.

Does a risk-based approach truly offer an advantage? Let's delve into the evidence.

Our Day Trading Algorithm

We will be using a simple intraday breakout model called, Better Breakout which was discussed in thie article, A Modern Approach To Breakout Trading. Please review that article for the strategy rules. The code is available for all EasyLanguage Mastery subscribers.

Let's load the strategy on a NASDAQ Futures (@NQ) chart.

  • Historical data January 1, 2012 through October 31, 2024
  • Trades are executed on a 5-minute bar
  • All trades are closed at the end of the day
  • A dynamic stop loss based upon the volatility of the market. See the code for details.
  • All trades are long only.
  • We assumed a starting capital of $100,000
  • $15 for slippage and commissions deducted for each round trip.

Below is an example of the strategy trading on the daily chart of @NQ. We can see the trade entering early on the 9:05 AM bar on a big gap up from the previous day. The trade closed at 15:00 PM the same day.

Fixed Contract Position Sizing

The fixed-share method is a non-risk-based method. In this case we simply buy the same number of contracts (1) for each signal. I use this technique all the time when developing a strategy. But it's probably not the best way to trade something live.

Contracts = 1


Percent Risk Position Sizing

The percent-risk method is a strategy grounded in risk management. In this approach, we allocate a fixed percentage of our equity—2% in this example—to risk on each trading signal. The choice of 2% is guided by a widely accepted principle in trading that suggests risking anywhere from 0.5% to 2% of your account balance on any single trade. This strategy aims to mitigate the impact of a series of losses, preventing them from significantly damaging your trading account. We then use this predetermined risk percentage to calculate the specific dollar amount you're willing to risk on an individual trade.

Example:

Contracts  = (2% of Account Equity) / ( Stop Loss Per Contract)
Contracts  = (2% * $100,000)/ $500
Contracts = $2,000 / $500
Contracts = 4

In the example provided, we have the methodology to calculate the number of contracts to purchase while maintaining a consistent risk level of 2% of the account size per trade. As mentioned, the stop-loss value for the 'Better Breakout' strategy adjusts based on recent market volatility, as detailed in the original article.

This adaptive approach means that if market volatility increases, our stop-loss threshold will widen. Consequently, to adhere to our 2% risk per trade guideline, we might find ourselves buying fewer contracts. Conversely, in periods of reduced volatility, our stop-loss tightens, allowing us to purchase more contracts without breaching the 2% risk rule.

The essence of this strategy is that we never risk more than 2% of our account on a single trade. This flexibility enables us to adjust the number of contracts traded in response to the volatility of the market, effectively normalizing our risk exposure relative to market conditions.

But what implications does this have for our trading outcomes?

Performance Comparison

Fixed

2% Risk

Net Profit

$59,595

$112,350

Profit Factor

1.88

2.16

Total Traders

193

193

Avg.Trade Net Profit

$308.78

$582.12

Annual Rate of Return

3.64%

5.87%

Max Drawdown (Intraday)

$10,425

$13,270

NP vs DD

5.7

8.5

In our analysis, we observed an increase in profits while maintaining the same number of trades (almost, there is one extra trade), without escalating our maximum intraday drawdown. We also increased every other metric!. 

This is a clear win. More profit. Identical risk. 

It's important to note that in our Percent Risk model, we are not reinvesting profits. We started trading with an account balance of $100,000 which remains constant for the purpose of calculating position sizes.

Why adopt this approach?

The goal was to evaluate the impact of scaling trades based on market volatility and to compare its performance with that of the Fixed Model. Incorporating profits into our calculations would undoubtedly enhance our returns further. However, I preferred to avoid complicating the analysis with additional variables. This decision was made to provide a clearer comparison and to focus solely on the influence of the position sizing model.

Pitfalls To Avoid

Don't Using Position Sizing To Improve A Poor System

First, let’s tackle a common misconception: thinking position sizing can turn a mediocre system into a winner.

Here’s the truth – position sizing isn’t a magic fix. If your trading system doesn’t have a solid foundation, even the best position sizing approach won’t make it profitable in the long run.

Imagine trying to fix a car with no engine by just repainting it; it might look better, but it’s still not going anywhere. You should always start with a positive expectancy system, meaning it’s capable of generating returns based on the market behavior it was designed to exploit.

Think of position sizing as the tool that can amplify or protect your returns, not create them from scratch. So, before diving into advanced sizing techniques, ensure your system is already well-tuned and thoroughly backtested. Only then can you expect position sizing to help elevate your results.

Don’t Risk Too Much Per Trade

Now, here’s a mistake that every beginner should be wary of risking too much per trade. It’s easy to think that a higher risk per trade means faster growth, but the opposite is true – the more you risk, the faster you can blow up your account.

In professional trading, a common rule is to keep risk per trade around 1-2% of your account. Why? Because this allows you to survive the inevitable losing streaks. Even the best trading systems will experience losses, sometimes back-to-back.

If you’re risking 5%, 10%, or more on a single trade, it won’t take long for a few bad trades to wipe out a significant portion of your capital. Here’s the bottom line: keeping your risk per trade at around 2% or lower gives you the breathing room to recover from losses and make adjustments if needed. It’s all about protecting your account so you can stay in the game for the long haul.

Remember, in trading, slow and steady does win the race.

Conclusion

Alright, let’s recap the main points.

We started with the concept of position sizing and why it’s essential for traders who want consistent, long-term results. We saw how adjusting trade size based on a percent-risk approach – rather than a fixed contract method – can help align your trades with market conditions, providing flexibility and stability in a volatile environment.

We also dug into the two common pitfalls to avoid: first, don’t rely on position sizing to make up for a weak system. Build a solid foundation with a proven strategy, and then let position sizing enhance it. Second, keep your risk per trade at a reasonable level, around 2%, to avoid those devastating losses that can sideline even the most promising traders.

Key takeaway? Strategic position sizing is a powerful tool when used with a robust trading system and disciplined risk management. It’s about managing your exposure, protecting your capital, and allowing your account to grow consistently.

Good luck with your trading.

]]>
https://easylanguagemastery.com/building-strategies/percent-risk-and-volatility-2/feed/ 5
Riding the Market Waves: How to Surf Seasonal Trends to Trading Success https://easylanguagemastery.com/market-studies/market-seasonality-study-may-2019/?utm_source=rss&utm_medium=rss&utm_campaign=market-seasonality-study-may-2019 https://easylanguagemastery.com/market-studies/market-seasonality-study-may-2019/#comments Mon, 26 Aug 2024 10:00:00 +0000 http://easylanguagemastery.com/?p=19871

Remember that old Wall Street chestnut, "Sell in May and go away"? Well, grab your favorite beverage and settle in, because we're about to dive into this age-old wisdom and see if it really holds water.

Now, I don't know about you, but I've always been a bit skeptical of these catchy market phrases. They sound great at cocktail parties, but do they actually work? That's exactly what I set out to discover.

In this article, we're going to break down our Market Seasonality Study step by step.

Below is a graph of the market with a "buy" at the start of the strong period and a "sell" at the end of the strong period.

Testing the "Buy in November, Sell in May" Strategy

To evaluate the popular trading concept of buying the S&P in November and selling in May, I set up a test with the following parameters:

  • Market: S&P cash market
  • Time period: 1960 to present
  • Position sizing: Risk-adjusted, with $5,000 risked per trade based on market volatility
  • Transaction costs: Not included (no slippage or commissions accounted for)

The core logic of this strategy can be implemented in EasyLanguage as follows:

CurrentMonth = Month(Date);
If (CurrentMonth = BuyMonth) And (MP = 0) Then
Buy("Buy Month") iShares contracts next bar at market;
If (CurrentMonth = SellMonth) Then
Sell("Sell Month") iShares contracts next bar at market;

This code does the following:

  1. Determines the current month
  2. If it's the buy month (November) and we're not in the market, it enters a long position
  3. If it's the sell month (May), it exits the position

By using this simple logic, we can test whether this well-known market adage holds up over a long period of historical data.

Test Parameters and Assumptions

I decided to test the strategy on the S&P cash index, with data going back to 1960. The following assumptions were made for this test:

  • Starting account size: $100,000
  • Test period: January 1960 through May 2024
  • Position sizing: Full account size used when opening a new position
  • Equity management: P&L not accumulated to the starting equity
  • Transaction costs: No deductions for commissions and slippage
  • Risk management: No stops were used

With these parameters set, we can now input the key months for our seasonality strategy:

  • Buy month: November
  • Sell month: May

Using these inputs, we generated the following equity graph:

Buy November, Sell May

Buy November, Sell May

"Sell in May and Go Away" Strategy Results

The equity curve we generated visually represents the performance of our "Sell in May and Go Away" strategy over the 64-year test period. It allows us to see the long-term trend as well as any significant drawdowns or periods of exceptional growth. And I must say, it sure looks like these months have a long bias - those are some impressive results!

Let's break down the numbers:

  • Total Profit: $4,640,085
  • Max Intra-day Drawdown: $1,403,538
  • Net Profit vs Drawdown Ratio: 3.3

In simpler terms, for every dollar of drawdown, the strategy is making just over three dollars in profit. That's a respectable ratio by most trading standards.

Inverting the Strategy

But here's where it gets really interesting. What would happen if we flipped our strategy on its head? Instead of buying in November and selling in May, what if we did the opposite - buying in May and selling in November?

To find out, I inverted the BuyMonth and SellMonth inputs in our test. Here's the resulting equity curve:

Buy May, Sell November

Buy May, Sell November

Analyzing the Inverted Strategy Results

The inverted equity curve provides a fascinating contrast to our original strategy, allowing us to visually compare the performance of buying during the traditionally "weak" months versus the "strong" months.

Let's break down the performance of this inverted strategy:

  1. 1960-1970: The equity curve consistently declined.
  2. 1970-1978: It bottomed out and began to climb.
  3. 1978-1997: Steady growth, reaching an equity peak in 1997.
  4. 1997-2008: Entered a drawdown period, bottoming in 2008.
  5. 2008-2021: Recovered, reaching new equity highs in 2020 and 2021.

Key metrics for the inverted strategy:

  • Total Profit: $94,148
  • Max Intra-day Drawdown: $92,357
  • Net Profit vs Drawdown Ratio: 1.0

This 1:1 ratio indicates that you must endure a dollar of drawdown for every dollar of profit - a much less attractive risk-reward proposition compared to our original strategy.

Let's focus on the strong season period from November-May moving forward. Can we add a filter to improve the results?

Implementing a Simple Moving Average Filter

To refine our strategy and avoid potentially unfavorable entry and exit points, we're introducing a 30-period simple moving average (SMA) as a short-term trend filter. This addition aims to prevent us from:

  1. Buying immediately into a falling market
  2. Selling immediately into a rising market

Here's how it works:

  • For Selling: If May (our SellMonth) arrives and the market is rising (price above the 30-period SMA), we delay selling until the price closes below the SMA.
  • For Buying: If November (our BuyMonth) arrives, we only buy when the price closes above the SMA.

To implement this in EasyLanguage, we create two flags: BuyFlag and SellFlag. These indicate when the proper conditions for buying or selling are met based on our short-term trend filter.

if (MinorTrendLen > 0) Then 
BuyFlag = Close > Average(Close, MinorTrendLen)
Else
BuyFlag = true;

If (MinorTrendLen > 0) Then
SellFlag = Close < Average(Close, MinorTrendLen)
Else
SellFlag = true;

The MinorTrendLen variable is an input that determines the SMA's look-back period. An additional check allows us to enable or disable the SMA filter:

  • If MinorTrendLen > 0: The SMA filter is active
  • If MinorTrendLen = 0: Both flags are always true, effectively disabling the filter

This flexibility lets us easily compare performance with and without the filter.

Strong Seasonality Trade (November-May) With Filters

Baseline

SMA Filter

Net Profit

$4,640,095

$5,961,005

Profit Factor

4.42

4.81

Total Trades

64

64

Avg.Trade Net Profit

$72,501

$93,140

Annual Rate of Return

9.54%

9.93%

Max Drawdown(Intraday)

$1,403,538

$1,856,564

NP vs Drawdown

3.3

3.2

We increased the net profit, profit factor, average profit per trade, and annual rate of return. There is a slight decline in the NP vs Drawdown ratio, but it's tiny. We can decently pull more profit by applying a simple moving average.

MACD Filter

A standard MACD filter is a well known indicator that may help with timing. I'm going to add a MACD calculation, using the default settings, and only open a new trade when the MACD line is above zero. Likewise, I'm only going to sell when the MACD line is below zero.  Within EasyLanguage we can create a MACD filter  by creating two Boolean flags called MACDBull and MACDBear which will indicate when the proper major market trend is in our favor.

If ( MACD_Filter ) Then
Begin
MyMACD = MACD( Close, FastLength, SlowLength );
MACDAvg = XAverage( MyMACD, MACDLength );
MACDDiff = MyMACD - MACDAvg;
If ( MyMACD crosses over 0 ) Then
Begin
MACDBull = True;
MACDBear = False;
End
Else If ( MyMACD crosses under 0 ) Then
Begin
MACDBull = False;
MACDBear = True;
End;
End
Else Begin
MACDBull = True;
MACDBear = True;
End;

Below are the results with the MACD filter:

Strong Seasonality Trade (November-May) With Filters

Baseline

SMA Filter

MACD Filter

Net Profit

$4,640,095

$5,961,005

$4,685,543

Profit Factor

4.42

4.81

5.35

Total Trades

64

64

63

Avg.Trade Net Profit

$72,501

$93,140

$74,373

Annual Rate of Return

9.54%

9.93%

9.55%

Max Drawdown (Intraday)

$1,403,538

$1,856,564

$1,205,264

NP vs Drawdown

3.3

3.2

3.8

Utilizing the MACD filter and comparing it to our baseline system, we can see we don't make as much more as the simple moving average filter, however, we increased our risk adjusted return with a NP vs DD of 3.8. So, if drawdown is your concern and not just pure profit it looks the MACD filter is slightly better.

RSI Filter

For our final filter I will try the RSI indicator with its default loopback period of 14. Again, like the MACD calculation, I want price moving in our direction so I want the RSI calculation to be above zero when opening a position and below zero when closing a position.

If ( RSI_Filter ) Then
Begin
   RSIBull = RSI(Close, 14 ) > 50;
   RSIBear = RSI(Close, 14 ) < 50;
End
Else Begin
   RSIBull = true;
   RSIBear = true;
End;

Strong Seasonality Trade (November-May) With Filters

Baseline

SMA Filter

MACD Filter

RSI Filter

Net Profit

$4,640,095

$5,961,005

$4,685,543

$4,080,657

Profit Factor

4.42

4.81

5.35

4.24

Total Trades

64

64

63

64

Avg.Trade Net Profit

$72,501

$93,140

$74,373

$63,760

Annual Rate of Return

9.54%

9.93%

9.55%

9.34%

Max Drawdown (Intraday)

$1,403,538

$1,856,564

$1,205,264

$1,291,784

NP vs Drawdown

3.3

3.2

3.8

3.1

Filter Comparison Results

The RSI filter performed worse than both the MACD and SMA filters.

In the end, it appears that applying either an SMA filter or an MACD filter can improve the baseline results. Both filters are relatively simple to implement and were tested for this article using their default values. Of course, this simple study could be expanded much further.

Applying Filters to the Weak Seasonality Period

After performing the different filter tests and selecting the simple moving average filter as the most effective, I began to wonder how our three filters would perform if applied to the weak seasonality period. Below are the performance results.

Weak Seasonality Trade (May-November) With Filters

No Filter

SMA Filter

MACD Filter

RSI Filter

Net Profit

$94,148

$244,406

$221,672

$121,740

Profit Factor

1.42

1.67

1.79

1.52

Total Trades

64

64

63

64

Avg.Trade Net Profit

$1,471

$3,818

$3,518

$1,902

Annual Rate of Return

3.64%

5.03%

4.88%

4.00%

Max Drawdown (Intraday)

$92,357

$128,921

$106,121

$100,544

NP vs Drawdown

1.0

1.7

2.0

1.2

We can see that adding MACD Filter produces the best results in terms risk adjusted return (NP vs Drawdown). The SMA Filter products the best results in terms of net profit. Both provide a radical change when compared to the No Filter situation. 

Conclusion

It certainly appears there is a significant seasonal edge in the S&P market. The trading rules we used above for the S&P cash market could be applied to the SPY and DIA ETF markets. I've tested these ETFs, and they produce very similar results. The S&P futures market also yields comparable outcomes. Interestingly, this approach even seems to work well for some individual stocks.

Keep in mind that this market study did not utilize any market stops. This is not a complete trading system!

Practical Use: Market Regime Filter For Stock Index Markets

With some additional work, an automated trading system could be built from this study. Another application would be to use this study as a filter for other trading systems. I envision using these results as a regime filter for your existing trading systems that trade the stock index markets.

Strong Season Bull/Bear Filter

  • Bull Market = if price is above 30-day SMA
  • Bear Market = if price is at or below 30-day SMA

Weak Season Bull/Bear Filter

  • Bull Market = if MACD is above zero
  • Bear Market = if MACD is at or below zero

This seasonality filter could be applied to both automated trading systems and discretionary trading. While it may not be particularly helpful for intraday trading, it's worth testing in that context as well.

Being aware of these major market cycles can be invaluable in understanding current market conditions and potential future directions. This knowledge can enhance your overall market perspective and potentially improve your trading decisions.

I hope you found this study helpful and that it provides you with new insights for your trading strategies.

]]>
https://easylanguagemastery.com/market-studies/market-seasonality-study-may-2019/feed/ 2
The Overnight Edge https://easylanguagemastery.com/building-strategies/overnight-edge/?utm_source=rss&utm_medium=rss&utm_campaign=overnight-edge https://easylanguagemastery.com/building-strategies/overnight-edge/#comments Mon, 20 Jul 2020 10:00:00 +0000 http://eminiedges.com/blog/?p=67

In this article I’m going to highlight a trading edge that appears in many different instruments and markets including both the futures and equity markets. It’s an edge that has persisted for well over two decades. This edge is a long bias that occurs in the “overnight” session as defined by the U.S. markets. Traders who hold long positions overnight can often be rewarded as substantial upward movement that can occur during this quiet time. Does this edge still hold up? Or is it fading?

Many day traders discuss the advantages of closing out their positions at the end of the day. Such traders are often proud they don’t hold open positions overnight for fear of the market moving strongly against them in the overnight session. This is a valid way to trade, to be sure. There are clear benefits to day traders who close their positions at the end of the day.

For example, if you’re a stock trader you are not exposed to a large gap which opens beyond your stop value thus, you may very well sleep more soundly. I have to admit there is some comfort knowing my account is flat at the end of the day. However, when it comes to market psychology what feels right is not often the best thing to do for your equity. What may appear to be a “safe thing to do” in reality, is more harmful than not.

While this post is by no means a rant against people who close out their positions at the end of the day, it does get me wondering that this fear of holding through the overnight session may be worth investigating. I ask, does the overnight session hold more of a bullish or bearish edge?

Let me ask this question: When do you think the most points are accumulated in the S&P E-mini market, during the day session or during the overnight session? To answer this question I developed two simple strategies.

  1. Day Test: Open trades at market open and close at market close.
  2. Night Test: Open trades and market close, and close trade at market open.

They both use a daily chart and a 200-period simple moving average (SMA) as a market environment filter so trades are only taken when price closes above the SMA. Both systems were executed from January 3, 2006 to July 14, 2020 with no slippage or commission cost deducted.

The Day Session

The first strategy simply buys at the day’s open and closes the position at the end of the day. Thus, we are capturing the points gained or lost during the day session. The equity curve is a sum of the points gained or lost during the day session. Below is the equity curve of this trading system.

Points captured during the day session

The Night Session

The night session strategy is just as simple but it opens a new position at the close of the daily bar. It then closes that position at the open of the next bar. Thus, we are capturing the points gained or lost during the night session. The equity curve is a sum of the points gained or lost during the night session since 2006. Below is the equity curve of this trading system.

Points captured in the overnight session

As you can see there is a clear difference between the night session and the day session. What does this mean to you? There seems to be an edge in exploiting long positions by riding the overnight session. My hypothesis is because so many active traders do not trade the overnight session, the market will often move in such a way as to lock them out from gains. Most people are familiar with the market shakeouts that rattle the faith of bullish participants, thus forcing them to lose their position.

You’ve seen it where the market moves down to take out your stop loss only to reverse in your favor. A painful experience. However, the market does have another subtle trick that messes with your psychology. That trick is making you miss the bull move altogether. Put another way, not only does the market attempt to shakeout weak hands (stopping you out), it also does a fantastic job of making people miss the rally! I think there is some of that going on here.

Recent Performance Of The Overnight Edge

A few years ago the overnight edge appeared to be fading. But when we take a closer look at the past the last few years the edge has been OK but as you can see, it’s been weak over the past four years, the edge seems to be holding up.

Points from overnight session over the past 4 years

For comparison below is the equity curve of points captured during the day sesson.

Points from day session over the past 4 years

The overnight session still may hold a bullish edge. To take advantage of this some system traders devise a trading system to enter long trades in the overnight session or continue to hold trades through the night session that they would otherwise close.

]]>
https://easylanguagemastery.com/building-strategies/overnight-edge/feed/ 13
A Simple S&P System https://easylanguagemastery.com/strategies/simple-sp-system/?utm_source=rss&utm_medium=rss&utm_campaign=simple-sp-system https://easylanguagemastery.com/strategies/simple-sp-system/#comments Mon, 18 Feb 2019 11:00:30 +0000 http://systemtradersuccess.com/?p=6439

In a past article, Trading Ideas And Systems: Keep It Simple, Smart Guy, highlighted the virtues of building simple trading systems. Simple trading systems have a lot of advantages namely, being robust. In this article I want to provide the EasyLanguage code for the concept provided in the orginal article. It’s a fine example of following the keep-it-simple mantra and just might inspire you to create a profitable system.

Simple S&P Futures System

The first system is based upon the concept provided in last week’s article. The rules are provided below.

System Rules

  • If today’s close is less than the close 6 days ago, buy (enter long).
  • If today’s close is greater than the close 6 days ago, sell (exit long).

Below is a screenshot of the system in action on the daily chart of the E-mini S&P futures contract.

Environmental Settings

I coded the above rules in EasyLanguage and tested it on the E-mini S&P futures market going back to 1998. Before getting into the details of the results let me say this: all the tests within this article are going to use the following assumptions:

  • Starting account size of $25,000
  • Dates tested are from January 1, 2000 through December 31, 2018
  • One contract was traded for each signal
  • The P&L is not accumulated to the starting equity
  • $30 was deducted per round trip for slippage and commissions
  • There are no stops

Baseline Results

Below is the equity curve for trading the E-mini futures contract based upon the rules as defined above. The equity curve looks very similar to the one from the original article. Below the equity curve is the weekly drawdown as a percentage of equity. We can see it reaches down in to the 40% range.

Baseline

Net Profit

$58,895

Profit Factor

1.33

Total Trades

421

%Winners

70.8%

Avg.Trade Net Profit

$139.89

Annual Rate of Return

6.65%

Max Drawdown(intraday)

$37,457

Would anyone really trade this? Of course not, but that’s not the point. The point is simple rules can be rather powerful and be the start of a great system. Can we take this trading concept and take it to a few more steps closer to a real system? Let’s see…

Bull/Bear Regime Filter

You can probably guess this would be my first line of attack. That is, broadly divide the market into two distinct modes: bullish or bearish. Often a simple indicator such as a simple moving average applied to a daily bar chart can be very effective in dividing a market into a bullish or bearish regime. The idea in this case is to only take long trades when we are in a bull market. I will be using a simple moving average to act as my regime filter.

In this case I'm gonig to use a 200-day simple moving average for the bull/bear regime filter. After applying the regime filter we get the following results:

Baseline

Regime Filter

Net Profit

$58,895

$49,957

Profit Factor

1.33

1.52

Total Trades

421

286

%Winners

70.8%

74.1%

Avg.Trade Net Profit

$139.89

$174.68

Annual Rate of Return

6.65%

6.03%

Max Drawdown(intraday)

$37,457

$15,537

So, does this look like an improvement? While we make less money, the system is more effective overall, in my opinion. The profit factor increases as does the average net profit per trade. We also reduce the max drawdown by a lot. I would guess we are eliminating a number of losing trades by only taking trades during a bull market.

Volatility Filter

Another way to divide the market is through volatility. Markets go through periods of rising volatility and falling volatility. In general, market volatility rises and peeks as the market falls and makes new lows. Some systems do well during these high volatility times while others do better during more quiet times. How are we going to measure volatility? We’re going to use the VIX index.  The VIX is a popular measure of the implied volatility of S&P 500 index options and is often called the fear index. In general, the VIX represents a measure of the market’s expectation of volatility over the next 30 days. The VIX has an inverse relationship to the price action on the S&P. Thus, we often see the VIX making new highs as the market is making new lows.

I’m going use the VIX in a very simple manner. I’m going to take the average of the daily VIX value over a number of days to create a simple moving average. Trade will only be opened when the current VIX is below the moving average. This should help the system by only taking trades when the VIX is likely to be falling.

But what value to use for the look-back? Using TradeStation’s optimization feature I’m going to test look-back values between 5 – 60 in increments of 5. The results are depicted in the bar graph below where the net profit is on the y-axis and the look-back period is on the x-axis.

The value 30 looked like a reasonable value to pick. The results of using 30 for the simple moving average for the VIX is below.

Baseline

Regime Filter

Volatility Filter

Net Profit

$58,895

$49,957

$34,427

Profit Factor

1.33

1.52

1.42

Total Trades

421

286

252

%Winners

70.8%

74.1%

59.4%

Avg.Trade Net Profit

$139.89

$174.68

$136.62

Annual Rate of Return

6.65%

6.03%

4.62%

Max Drawdown (intraday)

$37,457

$15,537

$18,560

Like the regime filter we see an improvement in profit factor, and drawdown from the baseline. But when comparied to the Regime Filter, this volatility filter underperforms in my opinion. 

Just for curiosity I performed one more test with VIX. That involved inverting the filter. That is, only take trades when VIX is above its moving average. Below are the results. 

Baseline

Regime Filter

Volatility Filter

Volatility Filter (inverted)

Net Profit

$58,895

$49,957

$34,427

$42,245

Profit Factor

1.33

1.52

1.42

1.29

Total Trades

421

286

252

291

%Winners

70.8%

74.1%

59.4%

72.2%

Avg.Trade Net Profit

$139.89

$174.68

$136.62

$145.17

Annual Rate of Return

6.65%

6.03%

4.62%

5.28

Max Drawdown (intraday)

$37,457

$15,537

$18,560

$26,460

I think the inverted run shows the least improvement against the baseline. It's also clearly not as good when compared to the standard Volatility Filter. What I really don't like is the increased drawdown and reduction in profit factor. More money is made with the inverted volatility filter vs the standard voltaility filter but, at a cost!

Overall, I like the equity curve and performance of the Regime Filter over the VIX Filter. Both represent an improvement over the baseline concept and demonstrate how simple concepts can produce positive results. Added one of the filters to the baseline concept was a “next step” to a potential profitable system. Clearly, more work needs to be done

]]>
https://easylanguagemastery.com/strategies/simple-sp-system/feed/ 10
Two Dimensional Market Environment Filter https://easylanguagemastery.com/building-strategies/two-dimensional-market-environment-filter/?utm_source=rss&utm_medium=rss&utm_campaign=two-dimensional-market-environment-filter https://easylanguagemastery.com/building-strategies/two-dimensional-market-environment-filter/#comments Tue, 25 Dec 2018 11:00:51 +0000 http://systemtradersuccess.com/?p=2567

In this article I’m going to demonstrate a technique to help adapt your trading systems to the changing market conditions. In a previous article entitled, “Trend Testing Indicators“, I tested several indicators that could be used to divide the market into two modes: bullish and bearish. These two modes were then used to dictate how the trading system should execute its trades. For example, during a bull mode only open long trades. During a bear mode only open short trades. In essence, we made our system adapt to the given market conditions. However, we can take this concept further by looking at a different market characteristic: trend strength.

A market may be in a bull regime, but how strong is the trend? Is the market rising fast or is it range bound? We would like to know if the market is trending strong or not because we would like to trade them differently. It’s clear a range bound market that should be traded differently than a trending market. In general you may want to hold an open position longer if the trend is strong. By measuring the strength of the trend we can further divide the market to make our trading system more adaptive. By introducing trend strength we now create four distinct market environments that can be used to determine how an automated system trades.

Four Market Environments

Bull Market

Bear Market

Weak Trend

1

2

Strong Trend

3

4

In this article I’m going to create  a simple strategy that will focus on the market environments one and three. That is, we will look at a weak-trending bull market and a strong-trending bull market.

Trading Environment

Our strategy will be coded in EasyLanguage and tested on the SPY ETF going back to 1993. All the tests within this article are going to use the following assumptions:

  •  Starting account size of  $50,000.
  •  Dates tested are from 2006 through December 31, 2019
  •  1 Contract per trade
  •  The P&L is not accumulated to the starting equity.
  •  There are no deductions for commissions and slippage.
  • No Stops

The Baseline System

For the buy and sell signal I’m going to use the very familiar 2-period RSI Strategy from the book, ”Short Term Trading Strategies That Work”, by Larry Connors and Cesar Alvarez. The system only goes long. There is no shorting. This strategy goes long in the S&P 500 E-mini when the market experiences a pullback in a long-term uptrend. Based on our previous article, “Trend Testing Indicators“, we determined the smoothed ROC indicator which may be an effective market regime filter. So we will use a 200-period ROC calculation to determine if we are within a bull market. The 2-period RSI is used to locate pullbacks (entry points) within our bull market. An RSI value below a 10 will tell our system to open a new long position. We exit the trade when the 2-period RSI rises above 65 . The rules are:

  • 200-Period ROC calculation must be above zero.
  • Buy on close when RSI(2) is below 10.
  • Exit when RSI(2) is above 65.

This system is applied to a daily bar chart going back to 2006.

Looking at the trading rules, you can see that the Baseline System has a market mode filter (the 200-day smoothed ROC) to identify the overall bullishness or bearishness of the market. But we make no distinction between a strong trending bull market and weak trending bull market. If we are in a strong bullish market it makes sense to hold on to our trade in an attempt to capture a bigger move. On the other hand, if we are not in a strong trending market we may want to exit our long position rather quickly. Yet, our Baseline System always sells when a 2-period RSI rises above 65. The exit makes no adjustment for the trendiness of the market.

Introducing Trend Strength

Let’s use Trend Strength Indicator to gauge the trend strength of the market. Trend Strength Indicator (TSI) can be found over at Engineering Returns (no longer around). You can also download the code at the bottom of this article. Let’s also define a strong trend as >= 1.65 and a weak trend as < 1.65. These are not optimized numbers. They are simply a generalization from experience.

Now, let’s modify our exit parameter to hold longer during a strong trend. We’ll exit when a 2-period RSI rises above 95. This should allow us to hold our position longer and capture more profit during a strong trend.

The TSI indicator is provided as a download within the TradeStation ELD and within the Text File found within the download section at the conclusion of the article.

Our new bull market exit rules look like …

  • If TSI >= 1.65 Exit when RSI(2) of the close of current day is above 95

Below is a snapshot of several trades where the market trend changes from non-trending to trending. You can see that during a trending market we are holding the trade longer simply by requiring the RSI(2) value to rise above 95. The trades on the left half of the image are non-trending trades (LE_nt) while the two trades on the right half of the image are trending trades (LE_t).

Let's also change our entry rules based upon the trend strength. If we are experiencing a strong trend we want to make our entry rules a bit looser. That is, we expect pullbacks to be shallower when a market in trending strongly. So, we'll make our 2-period RSI threshold 25 instead of 10. This will allow us to enter shallower pullbacks during a strong trending market.

Now let’s take a look at the performance of this strategy.

1S VS 2D Filter

1D Filter

2D Filter

Net Profit

$10,575

$32,513

Profit Factor

1.19

1.60

Total Trades

111

88

%Winners

74%

72%

Avg.Trade Net Profit

$95

$369

Consective Losers

3

3

Annual Rate of Return

1.45%

3.79%

Net Profit / Drawdown

0.59

1.66

By introducing a simple trend strength indicator and making our strategy adapt to the trend strength, we generate more net profit and more profit per trade. We do decrease the number of trades as well. This is a good improvement and it demonstrates that we are on the right track by holding our position longer during a strong trend.

What if we simple hold all our traders (strong trend or not ) with our strong trend exit method?

1D Filter

2D Filter

Always 

Net Profit

$10,575

$32,513

Enter your text here...

Profit Factor

1.19

1.60

Cell

Total Trades

111

88

Cell

%Winners

74%

72%

Cell

Avg.Trade Net Profit

$95

$369

Cell

Consective Losers

3

3

Cell

Annual Rate of Return

1.45%

3.79%

Cell

Net Profit / Drawdown

0.59

1.66

Cell

Conclusion

There you have it. A strategy that adapts to several different market conditions. I did not cover the bear market regime, but you’re certainly free to explore that. Likewise, you can expand this concept to create a strategy that more drastically changes its trading behavior based on which of the four market environments we defined. Maybe during a strongly trending bull market you will want to use a completely different exit method than used during a non-trending market. In closing, this should provide some idea on how you can use two different types of indicators to divide the market into four different market environments.

]]>
https://easylanguagemastery.com/building-strategies/two-dimensional-market-environment-filter/feed/ 16
Market Seasonality Study https://easylanguagemastery.com/market-studies/market-seasonality-study/?utm_source=rss&utm_medium=rss&utm_campaign=market-seasonality-study https://easylanguagemastery.com/market-studies/market-seasonality-study/#comments Mon, 05 Nov 2018 11:00:50 +0000 http://systemtradersuccess.com/?p=3616


With October over I thought it would be a good idea to review our Market Seasonality Study.

Back in May of this year, we closed a seasonality trade in anticipation for a traditionally weak period of the stock index markets. That is the months of May, June, July, August, September, and October. So what did the market do during those months?

Below is a graph of the market with a "buy" at the start of the weak period and a "sell" at the end of the weak period.

As you can see, the traditionally weak period took off! Only in the last few weeks did it start giving back some of those gains. The weak period returned a $3,375 (3.4%) gain.

We are now entering a traditionally strong season for the stock index market. This is a well known seasonality period. In this article I would like to take a closer look at the seasonality bias which so many investors and traders talk about. 

Seasonality Bias

First, I would like to test the popular trading idea of buying the S&P in November and selling in May. I will test this on the cash market going back to 1983. The number of shares to buy will be adjusted based upon a fixed amount of risk. In this case, $5,000 is risked per trade based upon the volatility of the market. As this is a simple market study no slippage or commissions were taken into account. The EasyLanguage code looks like this:

CurrentMonth = Month( Date );
 
If ( CurrentMonth = BuyMonth ) And ( MP = 0 ) Then Buy("Buy Month") iShares contracts next bar at market;
 
If ( CurrentMonth = SellMonth ) Then Sell("Sell Month") iShares contracts next bar at market;

Testing Environment

I decided to test the strategy on the S&P cash index going back to 1960. The following assumptions were made:

* Starting account size of  $100,000.
* Dates tested are from 1960 through May 2017.
* The number of shares traded will be based on volatility estimation and risking no more than $5,000 per trade.
* Volatility is estimated with a two times 20-week ATR calculation. This is done to normalize the amount of risk per trade.
* The P&L is not accumulated to the starting equity.
* There are no deductions for commissions and slippage.
* No stops were used.

From here we can plug into the input values the buy month (November) and sell month (May). Doing this we generate the following equity graph:  

It sure looks like these months have a long bias as those are some nice results. What would the equity curve look like if we reverse the BuyMonth and SellMonth? That is, let's buy in May and sell in November. Below is the equity curve for this inverted system.

The early years of 1960 to about 1970 the equity curve went lower and lower. Then it started climbing reaching an equity peak of 1987. During this period, the strategy was producing positive results. That equity peak occurred during 1987 should be familiar. That was the year we had the massive one day market crash on October 19th known as Black Monday. That's when Dow Jones Industrial Average dropped 22% in one day!

 Since that event the behavior of market participants has been altered. This is not unlike the radical market changes which occurred after the 2000 market peek where much of the trending characteristics of the major markets were replaced by mean reversion tendencies. So far the basic seasonality study looks interesting. However, keep in mind that we do not have any stops in place. 

Nor do we have any entry filter that would prevent us from opening a trade during a bear market. If the market is falling strongly when our BuyMonth rolls around we may not wish to purchase right away.

Likewise, we have no exit filter to prevent us from exiting when the market may be on a strong rise during the month of May. It's conceivable that the market may be experiencing a strong bull run when our usual SellMonth of May rolls around.

Simple Moving Average Filter

In order to avoid buying and selling at the wrong times I'm going to introduce a 30-period simple moving average (SMA) to act as a short-term trend filter. This filter will be used to prevent us from immediately buying into a falling market or selling into a rising market. For example, if our SellMonth of May rolls around and the market happens to be rising (trading above the 30-period SMA), we do not sell just yet. We wait until unit price closes below the short-term SMA. The same idea is applied to the buying side, but reversed. We will not go long until price closed above the short-term SMA. Within EasyLanguage we can create a buy/sell confirmation flag called BuyFlag and SellFlag which will indicate when the proper go-long or sell conditions appear based upon our short-term trend filter.

if ( MinorTrendLen > 0 ) Then BuyFlag = Close > Average( Close,  MinorTrendLen )
Else BuyFlag = true;
If ( MinorTrendLen > 0 ) Then SellFlag = Close < Average( Close, MinorTrendLen )
Else SellFlag = true;

The MinorTrendLen variable is actually an input value which holds the look-back period to be used in the SMA calculation. You will notice there is an additional check to see if the look-back period is zero. This is done so we can enable or disable this SMA filter. If you enter zero for the look-back period, the code will always set our BuyFlag and SellFlag to true. This effectively disables our short-term market filter. This is a handy way to enable and disable filters from the system inputs. Below is the performance of both our Baseline system and the system with our SMA filter:

Seasonality Trade

Baseline

SMA Filter

Net Profit

$383,604

$419,965

Profit Factor

5.73

6.22

Total Trades

57

57

%Winners

75%

74%

Avg.Trade Net Profit

$6,730

$7,368

Annual Rate of Return

2.71%

2.83%

Sharpe Ratio

0.15

0.16

Max Drawdown(Intraday)

$36,151

$29,979

RINA Index

145

158

We increased the net profit, profit factor, average profit per trade, annual rate of return, and the expectancy score. The max intraday drawdown fell as well. Overall it looks like the SMA filter adds value.

MACD Filter

A standard MACD filter is a well known indicator that may help with timing. I'm going to add a MACD calculation, using the default settings, and only open a new trade when the MACD line is above zero. Likewise, I'm only going to sell when the MACD line is below zero.  Within EasyLanguage we can create a MACD filter  by creating two Boolean flags called MACDBull and MACDBear which will indicate when the proper major market trend is in our favor.

If ( MACD_Filter ) Then
Begin
MyMACD = MACD( Close, FastLength, SlowLength );
MACDAvg = XAverage( MyMACD, MACDLength );
MACDDiff = MyMACD - MACDAvg;
If ( MyMACD crosses over 0 ) Then
Begin
MACDBull = True;
MACDBear = False;
End
Else If ( MyMACD crosses under 0 ) Then
Begin
MACDBull = False;
MACDBear = True;
End;
End
Else Begin
MACDBull = True;
MACDBear = True;
End;

Below are the results with the MACD filter:

Seasonlity Trade

Baseline

SMA Filter

MACD Filter

Net Profit

$383,604

$419,965

$367,642

Profit Factor

5.73

6.22

4.74

Total Trades

57

57

56

%Winners

75%

74%

71%

Avg.Trade Net Profit

$6,730

$7,368

$6,565

Annual Rate of Return

2.71%

2.83%

2.65%

Sharpe Ratio

0.15

0.16

0.12

Max Drawdown(Intraday)

$36,151

$29,979

$36,151

RINA Index

145

158

111

Utilizing the MACD filter and comparing it to our baseline system, we reduced every so slightly many of the performance metrics. Overall, it does not appear to be better than our SMA filter.

RSI Filter

For our final filter I will try the RSI indicator with its default loopback period of 14. Again, like the MACD calculation, I want price moving in our direction so I want the RSI calculation to be above zero when opening a position and below zero when closing a position.

If ( RSI_Filter ) Then
Begin
   RSIBull = RSI(Close, 14 ) > 50;
   RSIBear = RSI(Close, 14 ) < 50;
End
Else Begin
   RSIBull = true;
   RSIBear = true;
End;

Seasonality Trade

Baseline

SMA Filter

MACD Filter

RSI Filter

Net Profit

$383,604

$419,965

$367,642

$381,850

Profit Factor

5.73

6.22

4.74

5.39

Total Trades

57

57

56

57

%Winners

75%

74%

71%

75%

Avg.Trade Net Profit

$6,730

$7,368

$6,565

$6,699

Annual Rate of Return

2.71%

2.83%

2.65%

2.70%

Sharpe Ratio

0.15

0.16

0.12

0.14

Max Drawdown(Intraday)

$36,151

$29,979

$36,151

$35,052

RINA Index

145

158

111

137

The RSI filter performed better than the MACD filter. Comparing it to the Baseline, we see it's very similar. With the RSI filter the net profit, profit factor and RINA Index are all slightly lower.

In the end it does appear applying a SMA filter or an RSI filter can improve the baseline results. Both filters are rather simple to implement and were tested for this article with their default values. Of course, you could take this simple study much further.

Apply SMA Filter on Weak Seasonality Period?

After performing the different filter tests and choosing the simple moving average filter, I started wondering what it would look like if we applied to the weak seasonality period. Below are the before-and-after equity curves.

Without the simple moving average filter

With the simple moving average filter

It appears the simple moving average filter helps a lot. While we can still see the weak seasonality period equity curve is not nearly as attractive as the strong seasonality period, it did improve to somewhat decent. 

Conclusion

It certainly appears there is a significant seasonal edge to the S&P market. The very trading rules we used above for the S&P cash market could be applied to the SPY and DIA ETF markets. I've tested those ETFs and they produce very similar results. The S&P futures market also produces similar results. It even appears to work well on some stocks.

Keep in mind this market study did not utilize any market stops. How can this study be used? With a little work an automated trading system could be built from this study. Another use would be to apply this study as a filter for trading other systems.

This seasonality filter could be applied to both automated trading systems or even discretionary trading. It may not be much help for intraday trading, but it may be worth testing. Anyway, just being aware of these major market cycles can be helpful in understanding what's going on with today's markets and where they may be going in the near future.

Hope you found this study helpful. 

]]>
https://easylanguagemastery.com/market-studies/market-seasonality-study/feed/ 7
Market Phase – Going Beyond The Death Cross https://easylanguagemastery.com/building-strategies/market-phase-going-beyond-the-death-cross/?utm_source=rss&utm_medium=rss&utm_campaign=market-phase-going-beyond-the-death-cross https://easylanguagemastery.com/building-strategies/market-phase-going-beyond-the-death-cross/#comments Mon, 04 Jun 2018 10:00:49 +0000 http://systemtradersuccess.com/?p=2689

There are many ways to use indicators to help determine when the market is within a bull or bear mode. A common method that works well on trending markets over the long-term has been the so-called death cross and golden cross (Death/Golden Cross) indicator. This topic was discussed in a former article called,

The Death Cross – What You Need To Know. I encourage you to read the article which is based on backtesting the indicator on the S&P 500.  Below are the rules used by the Death/Golden Cross to divide a market into a bullish or bearish mode.

Bull Market = 50-Period SMA > 200-Period SMA 
 Bear Market = 50-Period SMA < 200-Period SMA 

In short, the Golden Cross has been a great signal for long-term market strength while the Death Cross often signals market weakness. Simply using the Death Cross as a signal to close all long positions within your retirement and brokerage accounts has historically saved your account from painful drawdowns. But can we improve upon this idea?

Within this article I’m going to build upon the Death/Golden Cross concept. I recently became inspired to write this article after reading “Defining The Bull And The Bear” by Chuck Dukas. Chuck developed a simple and interesting method to take the Death/Golden Cross to the next level. I’m going to reconstruct his concept using EasyLanguage programming code and backtest it to see how effective it is.

Within Chuck’s article, he uses a 200-period simple moving average (SMA) and 50-period SMA as the two primary indicators. These are the same indicators used by the Death/Golden Cross. However, where the Death/Golden Cross uses the crossing of these averages to generate their respective bull and bear signals, Chuck goes further by breaking up both the bear and bull markets into six different Phases.

  1.   Recovery Phase
  2. Accumulation Phase
  3.   Bull Phase
  4.   Warning Phase
  5.   Distribution Phase
  6.   Bear Phase

These phases take into account the relative positions of both the daily closing price and the two moving averages. This finer granularity can be used as a guide to deploy your money in the markets.

Recovery Phase = 50-Period SMA < 200-Period SMA and Close < 200-Period SMA and Close > 50-Period SMA

Accumulation Phase = 50-Period SMA < 200-Period SMA and Close > 200-Period SMA and Close > 50-Period SMA

Bull Phase 50-Period SMA > 200-Period SMA and Close > 200-Period SMA and Close > 50-Period SMA

Warning Phase = 50-Period SMA > 200-Period SMA and Close > 200-Period SMA and Close < 50-Period SMA

Distribution Phase 50-Period SMA > 200-Period and SMA and Close < 200-Period SMA and Close < 50-Period SMA

Bear Phase = 50-Period SMA < 200-Period SMA and Close < 200-Period SMA and Close < 50-Period SMA

For a pictorial representation of some of these phase you can see the “Bull Phase” and “Warning Phase” listed below.

 On the opposite end of the spectrum, below is an image of price action in “Bear Phase”,  “Recovery Phase” and “Accumulation Phase.” 

The original article goes into much more explanation behind each phase but let’s stick with the basics which are very quantifiable.  These simple rules can now be programmed into an automated trading system and tested. This system will be called the Market Phase System. For our examples I’m going to be buying the S&P 500 cash index ($SPX.X) and deduct $30 per round trip for slippage and commissions. The system will be going long only and will scale into a position based upon the following rules:

Buy X shares when we advance from Recovery Phase into Accumulation Phase.
Buy X shares when we advance from Accumulation Phase to Bull Phase.

The number of shares will be adjusted based upon an ATR calculation and will risk no more than $2,000 per trade with an account size of $100,000. We will exit our entire position when we enter a Bear Phase. The exit rule is basically the same as the Death/Golden Cross. Also, the entry rules are similar. The only difference is with the Market Phase System we are scaling into our position while the Death/Golden Cross purchases all shares ($4000 risk per trade) when the signal occurs. In short, the Market Phase System allows us to scale into our position during the Accumulation Phase instead of waiting until we transition into a Bull Phase. So, how do these two systems compare?

Golden Cross vs Market Phase

Golden Cross

Market Phase

Net Profit

$276,820

$294,261

Profit Factor

14.85

7.19

Total Trades

25

63

%Winners

80%

57%

Avg.Trade Net Profit

$11,072

$4,670

Annual Rate of Return

2.70%

2.79%

Sharpe Ratio

0.1

0.08

Max Drawdown(Intraday)

$52,621

$57,883

Expectancy

2.77

1.21

Expectancy Score

1.41

0.92

Since the inception of $SPX.X it has been difficult to beat following the Death/Golden Cross signals. The Market Phase System holds its own. It produces more than twice as many trades, but remember that’s also due to the fact it scales into the full position and TradeStation reports each entry as an individual trade. That’s why we have over twice as many trades. But the system does hold up well.

One tweak I would like to make to the Market Phase System is to substitute the closing price with a price proxy. As we know, the daily closing price of SPY can be rather choppy resulting in whipsaws. Let’s try to reduce some of these false signals and see if we can improve the system’s performance.

For our price proxy let’s take the exponential average of the last five days. But don’t use the closing price of SPY. Let’s take an average of the daily high, daily low and the closing price. With this method we are taking into account the size (range) of the daily bar. Here is the formula.

 PriceProxy = Exponential Average ( (High+Low+Close)/3, 5 )

We will use the value of PriceProxy instead of the daily closing price in all our calculations. This is done to smooth out the short-term price noise. Below are the results.

Golden Cross Vs Market Phase

Golden Cross

Market Phase

With Price Porxy

Net Profit

$276,820

$294,261

$290,415

Profit Factor

14.85

7.19

7.83

Total Trades

25

63

52

%Winners

80%

57%

69%

Avg. Trade Net Profit

$11,072

$4,670

$5,585

Annual Rate of Return

2.70%

2.79%

2.77%

Sharpe Ratio

0.1

0.08

0.07

Max Drawdown (Intraday)

$52,621

$57,883

$63,396

Expectancy

2.77

1.21

1.94

Expectancy Score

1.41

0.92

0.84

The price proxy does what is should do – reduce the number of trades, increase the percent winners and increased the average profit per trade. This was accomplished by reducing whipsaw trades. This results in slightly less overall net profit but generates a better profit factor. So our reducing the number of losing trades comes at a cost.

Keep in mind the number of shares traded between the two systems is not identical. Trades are entered at different times based upon volatility and price so, the number of shares traded will not be identical. Does the scale-in technique of the Market Phase system perform better than our Death/Golden Cross system? It’s a close call. Both systems are very similar, which is expected since both systems produce similar trading signals.

However, we enter the trade earlier with the Market Phase system which is why it produces slightly more profit. It also has more losing trades. Again, this is due to the fact we are scaling into the position. Clearly the Market Phase with the price proxy does not add much value. It all comes down to what you are looking for. For me, the Market Phase does not add enough value. I like to keep things simple and it does not get much simpler than the Golden Cross. Both the Market Phase system and the Golden Cross system are long term trend following systems. They do OK on SPY because it’s such a broad based index. However, they don’t fair so well on major stock index ETFs such as NASDAQ, DIA or IWM. They also perform poorly when trading individual stocks.

So, what else can we use these systems on? Commodity ETFs appear to be the best bet since they tend to have smoother trending characteristics which trend following systems can take advantage of. Note, many times a lot of cash is left on the table as we wait for the Bear Phase to close our long positions. Trading this type of system, which is typical for a long-term trend following system, one must have a lot of psychological strength to sit and watch profits evaporate while waiting for your exit signal. This is mentally difficult to do! This also makes me wonder if scaling out of the trades may work better to capture more profit.

In closing, both of these systems are not trade able systems as they stand. For example, they do not utilize protective stops! However, it appears they could provide a basis for a complete system with some modification. Another idea would be to use the Market Phase as a regime filter.

]]>
https://easylanguagemastery.com/building-strategies/market-phase-going-beyond-the-death-cross/feed/ 20
A Complementary Approach To Trading Technical Indicators https://easylanguagemastery.com/building-strategies/a-complementary-approach-to-trading-technical-indicators/?utm_source=rss&utm_medium=rss&utm_campaign=a-complementary-approach-to-trading-technical-indicators https://easylanguagemastery.com/building-strategies/a-complementary-approach-to-trading-technical-indicators/#comments Mon, 21 Aug 2017 10:00:08 +0000 http://systemtradersuccess.com/?p=3960

In the October issue of Futures magazine, author Jean Folger discusses an important aspect in selecting two or more indicators when developing a trading system. While I don't recommend simply combining indicators to create a trading system, and I don't think that's what Folger is suggesting either, when there comes a time to introduce two or more technical indicators to a trading system, this is when Folger's advice is relevant. The author highlights a common mistake when selecting two or more indicators that could really hinder the performance of your system. By following Folger's advice you can multiply the effectiveness of your system by selecting two or more indicators when done properly.

Types of Indicators

When it comes to technical indicators we are talking about mathematical formulas that are applied to price or volume. These technical indicators include MACD, Moving Averages, Stochastics, ADX, ATR, CCI, and many others. Folger first organized these indicators into different categories based upon what they are measuring.

  • Trend - ADX, Moving Averages, MACD, Parabolic SAE
  • Momentum - CCI, RSI, Stochastics
  • Volatility - ATR, Bollinger Bands, Standard Deviation
  • Volume - Chaikin Oscillator, OBV, Rate of Change

Selecting Two Indicators

When it comes to selecting two indicators the mistake can be from selecting two from the same category. By selecting from the same category you are measuring the same market characteristics (Trend, Momentum, Volatility, or Volume). In this case you're not getting new information about the market. For example, if you select ADX and Moving Average you are simply looking at the trending characteristics of the market. I'm a believer in keeping things simple and if you are introducing two indicators that are telling you the same thing, this is not helpful and it needlessly complicates your trading system. Each indicator should be dedicated to a specific purpose, not telling you the same thing two different ways. The point is to look at different market characteristics to expand your view. This can be done by selecting two indicators from different groups, say from Trend and Momentum. Now you are gathering complementary information about the market and are better prepared to make a decision.

Example

An example strategy will make this concept even more clear. I'll take Folger's lead and create a similar strategy used in the original article. Let's create a simple strategy for the S&P E-mini futures market. We'll use a daily chart just to keep things simple. No slippage or commissions will be deducted. Entry signals will generate with the stochastic indicator move out from its overbought/oversold regions. The system will simply reverse its current position thus, we are always in the market.

  • Go Long when the SlowD line crosses above 20
  • Go Short when the SlowD line crosses below 80

Below are the results of this strategy.

One Indicator

One Indicator

Net Profit

$4,325

Profit Factor

1.03

Total Trades

137

%Winners

58%

Avg.Trade Net Profit

$31.57

Annual Rate of Return

2.08%

Sharpe Ratio

0.06

Max Drawdown(Intraday)

$50,325

Now let's try a complementary indicator. One technique I would like to utilize a lot is the use of a simple moving average to divide the market into two different regimes: bull market and bear market. Often a 200-period moving average applied to a daily chart will work just fine. However, Folger suggested an SMA crossover method to determine the market regime. A 50-period moving average and a 60-period moving average. If the 50-period SMA is above the 60-period SMA the market is considered in a bullish regime. Otherwise the market is considered in a bearish regime. Let's apply this filter here.

  • Go Long when the SlowD line crosses above 20 and within Bull Market
  • Go Short when the SlowD line crosses below 80 and within Bear market

With these rules added to our buy condition we have introduced a trend-based filter. This should reduce unproductive trades by only taking trades in the direction of the dominate market regime. As a result this should reduce the total number of trades and increase the profitability of our strategy.

Below are the results of this strategy.

Complementary Indicators

One Indicator

Two Indicators

Net Profit

$4,325

$48,275

Profit Factor

1.03

1.5

Total Trades

137

57

%Winners

58%

47%

Avg.Trade Net Profit

$31.57

$846.93

Annual Rate of Return

2.08%

10.18%

Sharpe Ratio

0.06

0.10

Max Drawdown(Intraday)

$50,325

$34,825

As you can see using two complementing indicators can really improve the results. Keep this in mind when developing a trading system. The example trading strategy is, of course, not a tradable system. It's only an example of how applying a complementary indicator to filter trades can improve the trading system's performance. I personally use this technique a lot. It really can do wonders for a trading system. You will find below the code used in this article along with a TradeStation workspace.

]]>
https://easylanguagemastery.com/building-strategies/a-complementary-approach-to-trading-technical-indicators/feed/ 6
The Double Seven Strategy https://easylanguagemastery.com/strategies/double-seven-strategy/?utm_source=rss&utm_medium=rss&utm_campaign=double-seven-strategy https://easylanguagemastery.com/strategies/double-seven-strategy/#comments Mon, 10 Oct 2016 10:00:07 +0000 http://systemtradersuccess.com/?p=4165

It’s time to look at another simple trading system which can be found in the book, ”Short Term Trading Strategies That Work” by Larry Connors and Cesar Alvarez. In this article we are going to look at the Double 7 strategy. This is a simple strategy that can be applied to the major market indices such as DIA, DOW and QQQ. It can also be applied to the futures markets.

The rules of this system are very simple.

  • The instrument must be above its 200 day moving average.
  • If the instrument closes at a 7-day low – buy.
  • If a long position is open and the instrument closes at a 7-day high – sell.

The trading system follows two basic concepts we have talked a lot about on this website. Namely when trading the major market indices, like the S&P, an effective strategy is to buy pullbacks in a major up trend. This system does just that. The major up-trend is defined by price being above the 200-day moving average. A pull-back is defined as a close below the lowest-low over the past seven days. Once a trade is entered, we simply look for a new seven day high to exit. Super simple. Below is an example of some trades on the S&P Cash Index. Click the image for a larger view.

Looking at the trading rules, you will also notice it’s a long-only system. Later in this article I will also reverse the rules and test it on the short-side. But for now, let’s look at the performance for the long-only system. At this point I’m going to test it on the S&P cash index ($SPX.X for TradeStation).

Unless otherwise stated, all the tests performed in this article will be based on the following assumptions:

  • Starting account size of  $100,000.
  • The number of shares traded will be based on volatility estimation and risking no more than $2,000 per trade.
  • Volatility is estimated with a five times 20-day ATR calculation. This is done to normalize the amount of risk per trade.
  • The P&L is not accumulated to the starting equity.
  • There are no deductions for commissions and slippage.
  • There are no stops.

Here is the position sizing formula used:

Shares = $2,000 per trade / 5 * ATR(20) * Big_Point_Value ) 

This looks very promising. Keep in mind, the system has no stops.

Is The 7-Day Optimized?

Let’s look at changing the 7-day look-back period for two reasons. First, I would like to see if the default seven value is optimized. Secondly, I would like to know if other nearby values are used, would the system remain viable. In short, I would like to test the robustness of  the look-back period. For example, if we change the 7-day low value to six, I don’t want to see the system’s equity curve drastically change. Likewise, if we increase the 7-day low value to eight, I don’t want to see a drastic change in results. The neighboring values around seven should still produce positive results. In fact, it would be great to see the system  remain profitable over a wide range of values.

I will use TradeStation’s optimization feature to optimize the look-back period over the values 2-20 in increments of one. Keep in mind this single input value controls two look-back periods. The first is the entry look-back and the second is the exit look-back. As the trading system is defined, both these variables use the same value.  The results of the test are in the graph below. You can click the image to see a larger view.  The x-axis contains the look-back period while the y-axis contains the trading systems total P&L.

This looks great. Any value you choose produces positive results. Each change in the look-back period also does not drastically change from neighboring values. The default value of seven is near the peek, which is six, but it’s not the most optimal number. It’s also important to keep in mind we will be using the default value of seven for other instruments as well and it’s highly unlikely the bar graph for those instruments would look exactly like what we have here. In any event, I think this brings a lot of confidence to the look-back period.

Is The Regime Look-Back Optimized?

Just as we did for the look-back period for our entry trigger, let’s perform the same type of test on the regime look-back period. Again, I will use TradeStation’s optimization feature to optimize the look-back period over the values 20-200 in increments of ten. The results are in the graph below. You can click the image to see a larger view.  The x-axis contains the look-back period while the y-axis contains the trading systems total return.

This looks great as well. All values produce positive returns. In general, the longer the look-back period the more profit the system generates. While I did not study the numbers just beyond 200, I feel confident that a 200-period look-back is not optimized.

Taken both these tests we can feel confident that this system does not appear to be optimized and it’s robust given a wide variety of input values.

Going Short

The original system is a long-only system. Let’s try to use the current rules to short the market. We can do this by simply reversing the rules. In other words, we will modify the regime filter to only open trades when price is below the 200-day moving average. Trades will then open when price makes a new 7-day high and close when they make a new 7-day low.

  • The instrument must be below its 200 day moving average.
  • If the instrument closes at a 7-day high – sell short.
  • If a position is open and the instrument closes at a 7-day low – buy to cover.

I created a separate trading system to study only the short-side. The results of the system can be seen in the equity graph below.

This is not so great. Most of the time the equity curve is below the zero line. It’s choppy and ugly.  Clearly the market participants’ psychology during a bear market is different than simply a mirror image of those found in a bull market. One would think shorting new highs in a bear is a good idea, and maybe it is, but this system is not successful at capturing profit. Taking a wild guess simply from past experience, I have found that exiting quickly during bear markets tends to work better than in bull markets. Thus, maybe a modification of the exit rules to only hold a trade until the first profitable day or only hold for a maximum of three days may produce significantly better results. However, such modifications are best left for another day.

To further test our shorting idea, let’s now look at testing a range of look-back periods just like we did during our bull market. If our shorting concept is truly flawed, I would expect to see not much improvement in modification of our look-back period. In fact, since my wild guess is we need to exit quickly to remain profitable, I would expect to see greater losses as we continue to increase our look-back period. Likewise, I would expect to see greater profit as we shorten our look-back period. I will optimize the look-back period over the values 2-20 in increments of one. The results are in the graph below. You can click the image to see a larger view.

Just as I expected. In general the shorter the look-back period, the more profitable. However, since this is our first look at the Double Seven Strategy, I don’t want to over complicate it by introducing a shorting component. We’ll keep it simple for now and apply our long-only strategy to several major market ETFs.

Double Seven Strategy

Confident the long-only trading rules are robust and appear to hold potential, let’s now test this system on several major ETFs. Let’s test, SPY, QQQ, DIA, and IWM. For this test we are going to use all the same trading assumptions and position sizing as we did above except for the following modifications.

  • $100,000 starting account
  • Risk 2% of account equity per trade
  • P&L is not reinvested

Double Seven System

SPX

DIA

QQQ

IWM

Total Net Profit

$46,958

$22,188

$30,726

$35,731

Profit Factor

2.22

1.53

2.00

2.34

Total No Of Trades

159

135

135

126

% Profitable

70%

69%

73%

75%

Avg.Trade Net Profit

$295.33

$164.35

$227.60

$283.58

Return on Capital

46.96%

22.19%

30.73%

35.73%

Annual Rate of Return

2.00%

1.20%

1.60%

1.98%

Conclusion

The Double Seven Strategy does produce positive results across the four major market ETFs we tested. Is this system tradable with real money as is? Probably not. Remember, there are no stops. However, this does appear to be a great start to a viable system. I would imagine if some of the larger losing trades could be eliminated by some type of stop method, this system could be viable with real money.

 Get The Book

]]>
https://easylanguagemastery.com/strategies/double-seven-strategy/feed/ 4
Better To Buy Strength or Weakness? https://easylanguagemastery.com/building-strategies/better-to-buy-strength-or-weakness/?utm_source=rss&utm_medium=rss&utm_campaign=better-to-buy-strength-or-weakness https://easylanguagemastery.com/building-strategies/better-to-buy-strength-or-weakness/#comments Mon, 03 Oct 2016 10:00:50 +0000 http://eminiedges.com/blog/?p=42

Emotionally it’s a lot easier to buy on strength than to buy on weakness. Buying into a falling market feels unnatural. Your instincts warn that price may continue to fall resulting in lost capital. On the other hand buying when the market makes new highs feels more natural. Price is moving in your direction and the sky is the limit! However, with so many other aspects of trading what feels natural or easy is often the opposite of what you should be doing.

Trading psychology can make or break not only your mental state-of-mind but your trading account. In this post I’m going to compare these two different trading strategies on the S&P E-mini futures market and see which one produces better results. That is, we will look at a weak-trending bull market and a strong-trending bull market.

Trading Environment

Our strategy will be coded in EasyLanguage and tested on the E-mini going back to 1997. All the tests within this article are going to use the following assumptions:

  • Starting account size of  $25,000.
  • Dates tested are from 1997 through August 31, 2016.
  • A single contract will be traded
  • The P&L is not accumulated to the starting equity.
  • There are no deductions for commissions and slippage.
  • There are no stops or targets
  • Trades are executed on a daily bar chart

To compare buying into strength vs buying into weakness, two simple trading strategies will be created. Both strategies will go long only. All open positions are held for five days only.

Buy Into Strength – Buy New Highs

First let’s create a simple strategy that will study buying into strength. To do this we will look for three consecutive higher closes. At that point we will buy the open of the next bar.  Based on this pattern we are testing the market’s ability to follow through with continued higher closes. In short, we are buying into short-term strength in hopes it will continue into the near future. Below are the results of executing this test.

The strategy is far from profitable as the equity curve spends most of its time in negative territory. What this suggests is that short term bursts of strength are soon followed by falling prices. Remember, after we buy we only hold our position for five days and sell. It seems when we sell, price is often lower than when we bought.

Buy Into Weakness – Buy Pullbacks

Now let’s look at buying into pullbacks. We will use the same premise as buying into strength, but look to buy into a falling market.  That is, we will look for three consecutive lower closes. A lower close is a closing price which is lower than yesterday’s closing price. At that point we will buy the open of the next bar. This strategy will represent our buying into weakness.

What a difference! This strategy equity graph looks completely different and suggests that short-term weakness is often followed by price moving higher. If the two equity graphs are not enough to prove this point, let’s compare strategy performance .

ES Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

-$9,650

$61,300

Profit Factor

0.94

1.44

Total Trades

292

239

%Winners

56%

57%

Avg. Trade Net Profit

-$33.05

$256.49

Annual Rate of Return

-1.74%

6.60%

Sharpe Ratio

0.04

0.14

Max Drawdown (Intraday)

-$46,000

-$15,838

It’s important to remember these strategies are not trading systems per say. For example, both of these strategies have no stops so you would not blindly trade them. Think of these strategies as market indicators designed to highlight market behavior which might lead to a profitable trading edge. In this case there appears to be a significant bullish bias when buying into weakness as opposed to buying into strength.

How Stable Is Lookback Period?

The two strategies we tested above both used a 3-day lookback period and hold the position five days before closing it. Maybe this is a fluke? What does this test look like over different lookback periods? Are different lookback periods still profitable? While I want the holding period to remain short (five days) to mimic a short-term trading system, let’s look at different lookback periods and see if our strategy will remain profitable of several different values.

The first graph below shows buying into short-term strength with a lookback period of one through 10 days.

Notice the first two days after three consecutive days up produce some profit. But even then, the profit over such a long test period is not significant. Most of the bars show negative profit or profit around zero. In short, this does not appear to hold a market edge.

The next graph below shows buying into short-term weakness with a lookback period of one through 10 days. Notice with a loookback period between one and five we have profitable results. This shows some stability with the market behavior. However, beyond five days (one trading week), price often shows weakness.

So, it appears our short-term lookback period when buying into weakness has a nice profitable region and gives more credence to the market behavior of buying into weakness. The optimal lookback period appears to be four days. After four consecutive lower closes price can often have a strong rebound.

The idea of buying into short-term weakness seems to still hold merit for the S&P. The market edge appears for the 1-5 consecutive down days in both the futures and equity markets. This type of a market edge can lead to building a profitable trading system. Adding a market regime filter, dynamic stop, position sizing model and maybe a dynamic exit could turn this into a winning system.

What About Other Markets?

Lets take a look at some other popular markets. Lets first start with two other major stock indexes, the DOW and NASDAQ.

YM Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

$2,255

$8,590

Profit Factor

1.02

1.10

Total Trades

234

161

%Winners

56%

50%

Avg. Trade Net Profit

$9.64

$53.35

Annual Rate of Return

0.61%

2.08%

Sharpe Ratio

0.04

0.04

Max Drawdown (Intraday)

-$25,900

-$16,500

NQ Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

-$3,805

$109,250

Profit Factor

0.98

2.00

Total Trades

273

220

%Winners

55%

58%

Avg. Trade Net Profit

-$13.94

$496.59

Annual Rate of Return

-0.83%

9.89%

Sharpe Ratio

0.08

0.21

Max Drawdown (Intraday)

-$44,405

-$19,850

Now lets turn our attention to currency futures

EC Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

$33,393

-$18,069

Profit Factor

1.17

0.90

Total Trades

220

192

%Winners

54%

55%

Avg. Trade Net Profit

$151.79

-$94.11

Annual Rate of Return

5.62%

-3.60%

Sharpe Ratio

0.09

0.08

Max Drawdown (Intraday)

-$22,613

-$62,413

Finally, lets take a look at some other popular futures. First silver and gold.

SI Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

-$90,335

$22,395

Profit Factor

0.77

1.09

Total Trades

225

174

%Winners

52%

51%

Avg. Trade Net Profit

-$401.49

$128.71

Annual Rate of Return

-10.12%

4.23%

Sharpe Ratio

0.05

0.08

Max Drawdown (Intraday)

-$130,000

-$53,690

GC Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

-$8,540

$35,960

Profit Factor

0.96

1.24

Total Trades

220

176

%Winners

55%

53%

Avg. Trade Net Profit

-$38.82

$204.32

Annual Rate of Return

1.95%

5.90%

Sharpe Ratio

0.13

0.09

Max Drawdown (Intraday)

-$50,120

-$49,250

Finally, oil and U.S. 30-Year Treasuries.

US Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

-$625

$29,250

Profit Factor

1.00

1.23

Total Trades

234

187

%Winners

50%

52%

Avg. Trade Net Profit

-$2.67

$154.42

Annual Rate of Return

0.16%

5.13%

Sharpe Ratio

0.01

0.09

Max Drawdown (Intraday)

-$34,593

-$14,375

CL Buy Strength or Weakness

Buy Strength

Buy Weakness

Net Profit

-$71,810

-$75,250

Profit Factor

0.76

0.75

Total Trades

202

197

%Winners

50%

49%

Avg. Trade Net Profit

-$355.50

-$381.98

Annual Rate of Return

-8.98%

-9.21%

Sharpe Ratio

-0.11

-0.08

Max Drawdown (Intraday)

-$91,200

-$132,340

]]>
https://easylanguagemastery.com/building-strategies/better-to-buy-strength-or-weakness/feed/ 5