I've never been that big on pivot points, however, I do find them interesting and began dabbling with them recently. Pivot points are generally used on an intra-day basis, however, for this system, I used them on daily bars and calculated the values off of the weekly time frame. As it turns out, there is some decent profit potential with a simple pivot point system. I devised a basic mean reversion system and have applied it to Sector ETFs. Here are the rules:
Enter Long
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class DailyPivotTrader : Strategy
{
#region Variables
// Wizard generated variables
private int ma = 200; // Default setting for Ma
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossBelow(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S2, 1)
&& Close[0] > SMA(Ma)[0])
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (CrossBelow(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S3, 1)
&& Close[0] > SMA(Ma)[0])
{
EnterLong(DefaultQuantity, "");
}
// Condition set 3
if (CrossAbove(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R2, 1)
&& Close[0] < SMA(Ma)[0])
{
EnterShort(DefaultQuantity, "");
}
// Condition set 4
if (CrossAbove(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R3, 1)
&& Close[0] < SMA(Ma)[0])
{
EnterShort(DefaultQuantity, "");
}
// Condition set 5
if (CrossAbove(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP, 1))
{
ExitLong("", "");
}
// Condition set 6
if (CrossBelow(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP, 1))
{
ExitShort("", "");
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Ma
{
get { return ma; }
set { ma = Math.Max(1, value); }
}
#endregion
}
}
*******Delete this line********
Enter Long
- Close is greater than 200 day simple moving average;
- Close crosses below S2.
- Close crosses below S3, enter a second long position.
Enter Short
- Close is less than 200 day simple moving average;
- Close crosses above S2;
- Close crosses above S3, enter a second short position.
Here's a screen shot:
As you can see, this system buys dips and sells rallies. The 200 day moving average is a basic filter to screen for trades that are in the same direction as the trend. It's not the most sophisticated filter but it works just fine.
And the results please. I back-tested this system from 2008-today (Aug. 16, 2013). It is profitable, although not overwhelmingly, jaw-dropping profitable. One very positive factor is that it has pretty low drawdowns. With a basket of 12 etfs, it trades all through the volatility of 08' and 11' and the trending markets of 09' and 13' and it has had a max drawdown of -5.68%. That's pretty good. The cumulative profit is 39% but when you consider that profit with such a small drawdown, it makes this system look more attractive. (Note, I did not take out commissions or slippage. These will affect results some, but not too much as this is traded on a daily time frame.) Someone could apply 2x1 leverage and get a return of nearly 80% with a -11-12% drawdown, which is much more impressive. Another nice quality is the rather high winning percentage of 78.87%..which is about normal for a profitable mean reversion system. This can be good for traders that "have" to win more often than they lose, which is not necessary for a profitable system but it may be more in line with a trader's psychological makeup.
Here are the reports for the portfolio as a whole and the individual etfs. They were all profitable, some much more than others.
Here are the stats for the portfolio as a whole with couple of annotations pointing out some of the more relevant metrics.
So am I going to trade this system? Probably not, at least not right now. I've actually got better performing mean reversion systems that I'm currently trading (and by better performing, I don't just mean more profitable--that is part of it but the other systems also have a better history and they trade in a manner that I am 100% comfortable with and that I completely understand). I will however, still play around with this idea and see if I can tweak it a little more to my liking. Another thing that's worth is exploring is working a similar system on an intra-day time frame. That will take a little more work and I'll gladly post an update later to let you know of any progress.
For those of you who use ninja trader, below is the ninja script (NT7) for the system.
Hope everyone is enjoying that last bit of summer.
TLT
*******Delete this line when you paste into NT*******
#region Using declarationsusing System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class DailyPivotTrader : Strategy
{
#region Variables
// Wizard generated variables
private int ma = 200; // Default setting for Ma
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossBelow(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S2, 1)
&& Close[0] > SMA(Ma)[0])
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (CrossBelow(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S3, 1)
&& Close[0] > SMA(Ma)[0])
{
EnterLong(DefaultQuantity, "");
}
// Condition set 3
if (CrossAbove(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R2, 1)
&& Close[0] < SMA(Ma)[0])
{
EnterShort(DefaultQuantity, "");
}
// Condition set 4
if (CrossAbove(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R3, 1)
&& Close[0] < SMA(Ma)[0])
{
EnterShort(DefaultQuantity, "");
}
// Condition set 5
if (CrossAbove(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP, 1))
{
ExitLong("", "");
}
// Condition set 6
if (CrossBelow(Close, Pivots(PivotRange.Weekly, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP, 1))
{
ExitShort("", "");
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Ma
{
get { return ma; }
set { ma = Math.Max(1, value); }
}
#endregion
}
}
*******Delete this line********
2 comments:
Thanks for your posts, stumbled upon your blog and have been enjoying your posts. I am interested taking my trading in a similar direction. Particularly, would like to develop or tinker with strategies for automated trading. I just recently got a TD Ameritrade account and am trying to figure out the best way to set up automated trades based on trade strategies like this one. Years of experience trading, computer science degree that isn't being used and new to automated trading. If you have any recommendations I'm all ears.
Your best bet for setting up automated trading is to use the ninja trader platform to link to TD Ameritrade and have ninja trader send the orders based on your algorithms.
Post a Comment