A Trader Journal

Change yourself, change your trading.

Ninjatrader: Discretionary trading using Strategy analyzer

If your platform is not Ninjatrader then probably you can skip this post. All the quant stuff on this blog are done using Ninjatrader & R. For last few days I was trying to get Ninjatrader software handle following scenario. I feel the scenario is fairly common and the solution will be useful others. So posting it on the blog.

Scenario:
I have couple strategies that works off daily and weekly charts. Now I would like to use the strategies for live trading. But I am NOT comfortable with software placing orders automatically. Also I would like to use some level of discretion. So my desired workflow is:
  • Each day wait for US markets to close for the day. Then start Ninjatrader and connect to an EOD data feed (Example: Yahoo/Kinetic etc).
  • Select my strategy and run on a pre-defined watch list in Strategy Analyzer.
  • The strategy executes on the watchlist and generates list of orders (buy/sell/short/cover) with details. I either take a printout (or save in spreadsheet) to trade manually the following day/week.
  • Repeat the above step for other production strategies & watch lists.

Equity curve and performance analytics of price action strategy

Last post covers a simple price action strategy to profit from crowd emotions and some stats on it by market regimes. You can find the post here. It is easy to either skip that or move on to something else after quick read because it is too simple.

This simple strategy had beaten buy-n-hold by a wide margin overall in last 17 years. CAGR of 10% is good especially given the short time the strategy spends in the market. IMO time is one of the safest risk control a strategy can have. You can see for yourself the results, consistency and other ratios etc in the following two images along with my annotations.

Strategy - Equity Curve, Weekly Returns, Drawdowns

Strategy - Performance Analytics

Currently the max drawdown of this method is 20%.  That is too high for my comfort. One of my reasons for sharing this method on the blog is to hear your thoughts and suggestions on ways one can reduce the draw down of this strategy. Any suggestions?

Wish you all good health and good trading!

Research: Profiting from crowd emotions with simple price action

Many people approach the market with assumption that only ideas that are complex or arcane can provide an edge in the markets. Unfortunately most trading books and vendors promote this assumption to sell their own services. Would you buy/subscribe otherwise? Another culprit is the notion that the more complex and intellectual a method or concept is, the better it is. Typical justification, otherwise everyone would have figured it. Another reason - intellectual addiction.
 

Sometimes simple things can provide an edge. Partly because they tap into simple basic emotions we all have as humans. For example, remember the last time market (SP500) had a strong sell off and closed near its lows. If you are visual, think of a large big red bar. What was your thought pattern and reaction? What sense did you get from financial media and popular blogs?

My guess is in both cases, it is a negative emotion followed by intellectual/logical reasons to justify market sell off and continuation of it. We know majority people are bad at timing. So how about taking other side of the crowd? This is where the price action research of this post comes in.The purpose of the study is to see what are the market returns when we follow the crowd vs when we takes opposite side to the crowd. 

Using SP500 (SPY) market as an example, one simple way to define crowd behavior for the day is based on the market close with respect to its high, low and close of the day. There are multiple ways to identify but for this test how about we define crowd behavior as follows -
  • The location of the market close with respect to its high of the day provides the emotional temperature of the crowd for the day. The farther the close from high of the day, the stronger the emotional temperature of the crowd.
  • The location of the market close with respect to its open provides the emotional sign of the the crowd for the day i.e., down day = negative emotion, up day = positive emotion.
  • To quantify above, let's divide the day's range (i.e., high - low) into 4 quartiles to identify in which quartile the market closed for the day. Following image provides a pictorial description of what I mean.

Definitions:
  • Bull Market - Market is above 200 day moving average. 
  • Bear Market - Market is below 200 day moving average.  
  • Graphs Annotation - In below graph, on X-axis, label 25 means 0%-25%. Similarly label 50 (25%-50%) , label 75 (50%-75%) and label 100 (75%-100%).
Close_Test:
  • Compute the quartile for today's SPY market close i.e., (0-25)  or (25-50) or (50-75) or (75-100)
  • Buy market @ open the next day.
  • Sell market @ open the following day.
  • Calculate the performance stats.
Note: Another interesting test would be to buy @ close today near end of the day (instead of buying @ open the following day). This can help one to get in on overnight action. I assume most of this blog readers are likely end of day traders. So for the test, I am using buying @ open the next day.

Bull_Market_Test:
  • SPY market close is above its 200 day moving average.
  • Compute the quartile for today's SPY market close i.e., (0-25)  or (25-50) or (50-75) or (75-100)
  • Buy market @ open the next day.
  • Sell market @ open the following day
  • Calculate the performance stats. 
Bear_Market_Test:
  • SPY market close is below its 200 day moving average.
  • Compute the quartile for today's SPY market close i.e., (0-25)  or (25-50) or (50-75) or (75-100)
  • Buy market @ open the next day.
  • Sell market @ open the following day
  • Calculate the performance stats. 
Misc:
  • Test Duration: 1996 t0 Current
  • Friction less results i.e., no commissions, no slippage.
  • Long only trades.
Fading vs Following Crowd Emotions

Results Analysis:
My observation is in general it takes lot more time to write blog and generate plots compared to time it takes to create a test or analyze market. I already spent lot of time on this post to provide something worthwhile and results are fairly clear cut. Look at the annotations on the graph - 
  • Specifically the results of 75%-100% quartile for all three tests. 
  • Results of this top quartile under bull and bear market regimes.
Note:
The above is not a system nor it is a recommendation. Just a research into of one of the market characteristics. Feel free to let me know your conclusions from results. Also feel free to agree/disagree. 


Wish you all good health and good trading!

"There is just one life for each of us........ Be yourself!"

Study: Market performance by VIX regimes

This study is about bull and bear markets (S&P 500) performance by VIX regime. For the test, I used SPY etf as the proxy for S&P 500. 

Definitions:
  • Bull Market Phase - Market is above 200 day simple moving average. 
  • Bear Market  Phase - Market is below 200 day simple moving average. 
  • VIX Regimes:  0-15 (low volatility), 15-30, 30-45, 45-60 (high volatility)
Bull Market Test
  • Market is in Bull Market phase.
  • Go long when market transitions from previous VIX regime to new regime.
  • Exit long when market transitions from current VIX regime to next regime.
Bear Market Test
  • Market is in Bear Market phase.
  • Go short when market transitions from previous VIX regime to new regime.
  • Exit short when market transitions from current VIX regime to next regime.
Misc
  • Test Duration: 1996 t0 Current
  •  Friction less results i.e., no commissions, no slippage.
  • Long only trades.

Results Analysis - Bull Markets: 
  1. Profitable in all 3 VIX regimes. The Trades category provides an idea of how many times the market entered into a particular volatility range.    
  2. The Win% is highest in VIX range 30-45. But the number of time market entered into that VIX range is relatively less.  
  3. Average Win/Loss Ratio and Average trade returns are highest in VIX range 0-15. I wonder if it is because of low volatility anomaly in markets?

Results Analysis - Bear Markets:  
  1. As expected, results show bear markets are more volatile than bull markets. Unlike bull markets, bear markets entered VIX 45-60 range multiple times. 
  2. Long trades are profitable in the volatility regime 30-45. Not sure Why?  
  3. Another is high average win/loss ratio in volatility regime 0-15. Why? 
 Feel free to let me know if your conclusions from results is different from above. Also I am curious to hear your thoughts on above 3 questions.
 

Note: The above is not a system nor it is a recommendation. Just a study of one of the market characteristics.

Study: Day of Week Performance by VIX regime

Today while scanning through WallStreetCurrents site, I came across a post on new Volatility ETF (VIXH). What caught my attention in that ETF prospectus was its rules based on VIX levels for buying VIX options. Thought will check out how those VIX rules would fare if I apply it on SPY.

Now rather than blindly buying SPY at each VIX level, thought I will combine with another study I am checking currently i.e., week of the day effect on SPY. (Note: If any readers are interested in pure VIX level based entries test then please let me know. I will do in one of the future posts).

Test:
  • Divide VIX range into 4 levels : 0-15, 15-30, 30-45, 45-60. (Note: My levels are slightly different from ETF but that shouldn't make much difference).
  • Buy @ market next day open and sell after 2 days. Note: Only one position at a time. Next position is opened after the current position is closed. I think this condition is more realistic.
  • Finally tabulate the performance metrics categorized by VIX level and Week of the day.
  • Test Duration - 1995 to 2012 Current. Caveats - Results are frictionless i.e., no slippage & no commission.
SPY ETF - Week of the day profile by VIX regime
Results:
Some takeaways
  • Poor performance of longs when VIX level is above 45.
  • Low performance of longs when VIX level is below 15. But draw downs are also low. So may be risk parity approach to increase the returns.
  • The sweet spot seems to be to go long on SPY only when VIX level is between 15-45. 
In the ETF prospectus, rules related to VIX level are as follows:
  • VIX futures less than or equal to 15, no VIX calls are purchased
  • VIX futures above 15 and less than or equal to 30, 1% of portfolio in VIX calls
  • VIX futures above 30 and less than or equal to 50, 0.50% of portfolio in VIX calls
  • VIX futures above 50, no VIX calls are purchased
Your thoughts?

Share