Using TradeStation’s COT Indicator to Develop a Trading System

TradeStation’s COT (Commitment of Traders) Indicator:

TradeStation COT Indicator

TradeStation now includes the historic COT (Commitment of Traders) report in the form of an indicator.

If you can plot it then you can use it in a Strategy.  The following code listing takes the Indicator code and with very few modifications turns it into a trading system.

{
Net positions of various groups of traders from the CFTC's weekly Commitments of
Traders report.  "Net" positions are calculated by taking the number of contracts
that a group of traders is long and subtracting the number of contracts that that
group of traders is short.

The user input "FuturesOnly_Or_FuturesAndOptions_1_or_2" determines whether the
CFTC's "Futures Only" report is used, or the "Futures and Options" report is
used to determine the positions of the various groups of traders.  By default, the
"Futures Only" report is used.

Plot1:  Commercial traders' net position
Plot2:  Non-commercial traders' net position
Plot3:  Speculators' net positions, for speculators not of reportable size
Plot4:  Zero line

If an error occurs retrieving one of the values used by this study, or if the value
is not applicable or non-meaningful, a blank cell will be displayed in RadarScreen or
in the OptionStation assets pane.  In a chart, no value will be plotted until a value
is obtained without generating an error when retrieved.
}

input:  FuturesOnly_Or_FuturesAndOptions_1_or_2( 1 ) ; { set to 1 to use the CFTC's
 "Futures Only" report, set to 2 (or to any value other than 1) to use the "Futures
 and Options" report }

variables:
	Initialized( false ),
	FieldNamePrefix( "" ),
	CommLongFieldNme( "" ),
	CommShortFieldNme( "" ),
	NonCommLongFieldNme( "" ),
	NonCommShortFieldNme( "" ),
	SpecLongFieldNme( "" ),
 	SpecShortFieldNme( "" ),
    CommLong( 0 ),
	oCommLongErr( 0 ),
	CommShort( 0 ),
	oCommShortErr( 0 ),
	NonCommLong( 0 ),
	oNonCommLongErr( 0 ),
	NonCommShort( 0 ),
	oNonCommShortErr( 0 ),
	SpecLong( 0 ),
	oSpecLongErr( 0 ),
	SpecShort( 0 ),
	oSpecShortErr( 0 ),
	CommNet( 0 ),
	NonCommNet( 0 ),
	SpecNet( 0 ) ;

if Initialized = false then
	begin
	if Category > 0 then
		RaiseRuntimeError( "Commitments of Traders studies can be applied only to" +
		 " futures symbols." ) ;
	Initialized = true ;
	FieldNamePrefix = IffString( FuturesOnly_Or_FuturesAndOptions_1_or_2 = 1,
	 "COTF-", "COTC-" ) ;
	CommLongFieldNme = FieldNamePrefix + "12" ;
	CommShortFieldNme = FieldNamePrefix + "13" ;
	NonCommLongFieldNme = FieldNamePrefix + "9" ;
	NonCommShortFieldNme = FieldNamePrefix + "10" ;
	SpecLongFieldNme = FieldNamePrefix + "16" ;
 	SpecShortFieldNme = FieldNamePrefix + "17" ;	
	end ;

CommLong = FundValue( CommLongFieldNme, 0, oCommLongErr ) ;
CommShort = FundValue( CommShortFieldNme, 0, oCommShortErr) ;
NonCommLong = FundValue( NonCommLongFieldNme, 0, oNonCommLongErr ) ;
NonCommShort = FundValue( NonCommShortFieldNme, 0, oNonCommShortErr );
SpecLong = FundValue( SpecLongFieldNme, 0, oSpecLongErr ) ; 
SpecShort = FundValue( SpecShortFieldNme, 0, oSpecShortErr ) ;

if oCommLongErr = fdrOk and oCommShortErr = fdrOk then
	begin
	CommNet = CommLong - CommShort ;
	Print ("CommNet ",commNet);
	end ;

if oNonCommLongErr = fdrOk and oNonCommShortErr = fdrOk then
	begin
	NonCommNet = NonCommLong - NonCommShort ;
	end ;

if oSpecLongErr = fdrOk and oSpecShortErr = fdrOk then
	begin
	SpecNet = SpecLong - SpecShort ;
	end ;
If CommNet < 0  then sellShort tomorrow at open;
If CommNet > 0 then buy tomorrow at open;


{ ** Copyright (c) 2001 - 2010 TradeStation Technologies, Inc. All rights reserved. ** 
  ** TradeStation reserves the right to modify or overwrite this analysis technique 
     with each release. ** }
COT Indicator Converted To Strategy

Line numbers 90 and 91 informs TS to take a long position if the Net Commercial Interests are positive and a short position if the Commercials are negative.  I kept the original comments in place in  case you wanted to see how the indicator and its associated function calls work.  The linchpin of this code lies in the function call FundValue.  This function call pulls fundamental data from the data servers and provides it in an easy to use format.  Once you have the data you can play all sorts of games with it.  This is just a simple system to see if the commercial traders really do know which direction the market is heading.

if you test this strategy on the ES you will notice a downward sloping 45 degree equity curve.  This leads me to believe the commercials are trying their best to  use the ES futures to hedge other market positions.  If you go with the non Commercials you will see  a totally different picture.  To do this just substitute the following two lines:

If CommNet < 0 then sellShort tomorrow at open;
If CommNet > 0 then buy tomorrow at open;

With:

If NonCommNet < 0 then sellShort tomorrow at open;
If NonCommNet > 0 then buy tomorrow at open;

I said a totally different picture not a great one.  Check out if the speculators know better.

Leave a Reply