TRADERS’ TIPS

June 2016

Tips Article Thumbnail

For this month’s Traders’ Tips, the focus is Ken Calhoun’s article that appeared in the May 2016 issue, titled “ATR Breakout Entries.” Here, we present the June 2016 Traders’ Tips code with possible implementations in various software.

The Traders’ Tips section is provided to help the reader implement a selected technique from an article in this issue or another recent issue. The entries here are contributed by software developers or programmers for software that is capable of customization.


logo

TRADESTATION: JUNE 2016

In “ATR Breakout Entries,” which appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, author Ken Calhoun presents a method for finding strong swing trading breakouts by using a combination of J. Welles Wilder’s average true range along with simple moving average crossovers.

Here, we are providing TradeStation code (EasyLanguage) based on the article for both an indicator and a strategy. The indicator can be used in the TradeStation Scanner to search for candidate stocks as well as in a chart to visualize the results (Figure 1). The strategy can be used to backtest the symbols of your choice.

Sample Chart

FIGURE 1: TRADESTATION. Here are sample TradeStation Scanner results from the ATR breakout indicator and strategy applied to a daily chart of Outerwall Inc. (OUTR).

// TASC Jun 2016
// ATR Breakout by Ken Calhoun

inputs:
	ATRLength( 14 ),
	ATRLookBack( 14 ),
	MovAvgLength( 100 ),
	BarSizeMultiplier( 1.5 ),
	BarSizeLookBack( 5 ) ;
	
variables:
	ATRValue( 0 ),
	AvgValue( 0 ),
	BarSizeOK( false ) ;	


ATRValue = AvgTrueRange( ATRLength ) ;
AVGValue = Average( Close, MovAvgLength ) ;
BarSizeOK = Range > Average( Range, BarSizeLookBack ) 
	* BarSizeMultiplier ;


if Close crosses above AvgValue and
	ATRValue >= Highest( ATRValue[1], ATRLookBack ) and
	BarSizeOK then
		begin
		Alert ;
		Plot1( High, "ATR Breakout" ) ;
		end ;

Strategy: _ATR Breakout

// TASC Jun 2016
// ATR Breakout by Ken Calhoun

inputs:
	ATRLength( 14 ),
	ATRLookBack( 14 ),
	MovAvgLength( 100 ),
	BarSizeMultiplier( 1.5 ),
	BarSizeLookBack( 5 ),
	BreakoutAmount( .50 ),
	StopAmount( 2 ) ;
	
variables:
	ATRValue( 0 ),
	AvgValue( 0 ),
	BarSizeOK( false ) ;	


ATRValue = AvgTrueRange( ATRLength ) ;
AVGValue = Average( Close, MovAvgLength ) ;
BarSizeOK = Range > Average( Range, BarSizeLookBack ) 
	* BarSizeMultiplier ;


if Close crosses above AvgValue and
	ATRValue >= Highest( ATRValue[1], ATRLookBack ) and
	BarSizeOK then
		Buy next bar at High + BreakoutAmount Stop ; 
		
		
SetStopShare ;
SetStopLoss( StopAmount ) ;

To download this EasyLanguage code, please visit our TradeStation and EasyLanguage support forum. The code for this article can be found here: https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=142776. The ELD filename is “TASC_JUN2016.ELD.”

For more information about EasyLanguage in general, please see: https://www.tradestation.com/EL-FAQ.

This article is for informational purposes. No type of trading or investment recommendation, advice, or strategy is being made, given, or in any manner provided by TradeStation Securities or its affiliates.

—Doug McCrary
TradeStation Securities, Inc.
www.TradeStation.com

BACK TO LIST

logo

TC2000 VERSION 16: JUNE 2016

The breakout strategy described by Ken Calhoun in his May 2016 article in S&C, “ATR Breakout Entries” can be easily applied in TC2000 version 16 using TC2000’s EasyScan and the new simulated trading features.

We scanned the US common stocks list to find stocks between $20 and $70, with a minimum 90-day range of $5.00 and daily volume above one million shares. We also filtered for stocks that had just crossed up through their 100-day moving average. This produced a list of 30 stocks. We stepped through the list to find stocks where ATR was at a 14-day high. SPR was one of the few examples we found at the time we ran the scan. (See Figure 2.)

Sample Chart

FIGURE 2: TC2000. This shows an example chart of SPR on a daily time frame. We placed a buy-stop order at $47.88, which is 50 cents above the high the day that SGEN crossed up through its 100-day moving average.

In addition to placing a buy-stop order above the high, we placed a profit target order 15% above the entry price and an 8% trailing stop order. If you would like a copy of this layout to use in your TC2000 software, just send an email to support@TC2000.com and we’ll send it to you. You can try the simulated trading features in TC2000 for yourself at www.TC2000.com.

—Patrick Argo
Worden Brothers, Inc.
www.TC2000.com

BACK TO LIST

logo

METASTOCK: JUNE 2016

In “ATR Breakout Entries,” which appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, author Ken Calhoun explains a high-volatility breakout trading system. The formulas given here are some ways to employ this strategy in MetaStock.

Exploration for new setups
This exploration will return just those instruments giving new setup signals. It lists the current closing price and the target entry price. “WRB” signifies that the setup signal was a wide range bar. “Inc Vol” shows if the volume was increasing on the setup bar. Both of these are additional confirmation signals; they are not required for the setup.

Column A:
Column Name: Close
Formula:
C

Column B:
Column Name: W R B
Formula:
H-L > Ref(1.5 * HHV(H-L, 5), -1) 

Column C:
Column Name: Inc Vol
Formula:
V > Ref(V, -1)

Column D:
Column Name: target
Formula:
H + 0.5

Filter:
Formula:
LLV(V, 90) >= 1000000 AND
H-L >= 5 AND Cross(C, Mov(C,100,S)) AND
ATR(14) > Ref(HHV(ATR(14), 14), -1) AND
LLV(C, 90) >= 15 AND HHV(C, 90) <= 70

Expert advisor
The only exit specified in the article was an initial/trailing stop of $2. If you wish to see the setup, entry, and exit signals on a chart, you can put the following formulas in an expert advisor:

Setup:
symbol: diamond
formula:
LLV(V, 90) >= 1000000 AND
H-L >= 5 AND Cross(C, Mov(C,100,S)) AND
ATR(14) > Ref(HHV(ATR(14), 14), -1) AND
LLV(C, 90) >= 15 AND HHV(C, 90) <= 70


Buy signal:
symbol: up arrow
formula:
stop:= 2;
setup:= LLV(V, 90) >= 1000000 AND
H-L >= 5 AND Cross(C, Mov(C,100,S)) AND
ATR(14) > Ref(HHV(ATR(14), 14), -1) AND
LLV(C, 90) >= 15 AND HHV(C, 90) <= 70;
target:= ValueWhen(1, setup, H+0.5);
el:= H >= target;
eprice:= If(OPEN > target, OPEN, target);
trade:= If( PREV<=0, If(el, eprice-stop, 0),
If(L < PREV, -1, PREV));
trade > 0 AND Ref(trade <=0, -1)


Exit signal:
symbol:  stop sign
formula:
stop:= 2;
setup:= LLV(V, 90) >= 1000000 AND
H-L >= 5 AND Cross(C, Mov(C,100,S)) AND
ATR(14) > Ref(HHV(ATR(14), 14), -1) AND
LLV(C, 90) >= 15 AND HHV(C, 90) <= 70;
target:= ValueWhen(1, setup, H+0.5);
el:= H >= target;
eprice:= If(OPEN > target, OPEN, target);
trade:= If( PREV<=0, If(el, eprice-stop, 0),
If(L < PREV, -1, PREV));
trade = -1

—William Golson
MetaStock Technical Support
www.metastock.com

BACK TO LIST

logo

eSIGNAL: JUNE 2016

For this month’s Traders’ Tip, we’ve provided the study ATR Breakout.efs based on the formula described in Ken Calhoun’s May 2016 S&C article, “ATR Breakout Entries.” In the article, Calhoun presents a method for trading the market based J. Welles Wilder’s average true range (ATR) and a simple moving average (SMA).

This study contains formula parameters that may be configured through the edit chart window (right-click on the chart and select “edit chart”). A sample chart demonstrating the strategy is shown in Figure 3.

Sample Chart

FIGURE 3: eSIGNAL. Here is an example of the ATR breakout study plotted on a daily chart of NUGT.

To discuss this study or download a complete copy of the formula code, please visit the EFS library discussion board forum under the forums link from the support menu at www.esignal.com or visit our EFS KnowledgeBase at https://www.esignal.com/support/kb/efs/. The eSignal formula script (EFS) is also available below:

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2016. All rights reserved. This sample eSignal 
Formula Script (EFS) is for educational purposes only and may be 
modified and saved under a new file name.  eSignal is not responsible
for the functionality once modified.  eSignal reserves the right 
to modify and overwrite this EFS file with each new release.

Description:        
    ATR Breakout Entries by Ken Calhoun

Version:            1.00  02/08/2016

Formula Parameters:                     Default:
ATR Length                              14
Highest ATR Lookback                    14
SMA Length                              100
Use Wide Range condition                true
Wide Range Lookback                     7
Trailing Stop                           2



Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

**********************************/

var fpArray = new Array();

function preMain(){
    
    setPriceStudy(true);
    setCursorLabelName("SMA");
    var x=0;
    fpArray[x] = new FunctionParameter("ATRLength", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);
        setUpperLimit(1000);  
        setDefault(14);
        setName("ATR Length");
    }
    fpArray[x] = new FunctionParameter("ATRlb", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);
        setUpperLimit(1000);  
        setDefault(14);
        setName("Highest ATR Lookback");
    }
    fpArray[x] = new FunctionParameter("SMALength", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);
        setUpperLimit(1000);  
        setDefault(100);
        setName("SMA Length");
    }
    fpArray[x] = new FunctionParameter("isWR", FunctionParameter.BOOLEAN);
	with(fpArray[x++]){
        setDefault(true);
        setName("Use Wide Range condition");
    }
    fpArray[x] = new FunctionParameter("RangeLen", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);
        setUpperLimit(1000);  
        setDefault(7);
        setName("Wide Range Lookback");
    }
    fpArray[x] = new FunctionParameter("TrlStop", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(0.01);		
        setDefault(2);
        setName("Trailing Stop");
    }
}

var bInit = false;
var bVersion = null;
var xClose = null;
var xHigh = null;
var xLow = null;
var bIsLong = false;
var bEntryFound = false;
var vStopPrice = null;
var vHighOfDay = null;
var xSMA = null;
var xATR = null;
var xHighestATR = null;
var xRange = null;
var xWR = null;
var vHighestHigh = null;

function main(ATRLength,ATRlb,SMALength,isWR,RangeLen, TrlStop){
    
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;

    
    if(getBarState() == BARSTATE_ALLBARS){
        xClose = null;
        xHigh = null;
        xLow = null;
        bIsLong = false;
        bEntryFound = false;
        vStopPrice = null;
        bVersion = null;
        vHighOfDay = null;
        xSMA = null;
        xATR = null;
        xHighestATR = null;
        xRange = null;
        xWR = null;
        vHighestHigh = null;
        bInit = false;
    }

    if (!bInit){
        bIsLong = false;
        bEntryFound = false;
        xClose = close();
        xHigh = high();
        xLow = low();
        xSMA = sma(SMALength);
        xATR = atr(ATRLength);
        xHighestATR = hhv(ATRlb, xATR);
        
        if (isWR){
            xRange = efsInternal("calcRange", inv("D"));
            xWR = upperDonchian(RangeLen-1,xRange);
        }
        bInit = true;
    }
    if(xSMA.getValue(-1) == null) return;
    
    var nATR = xATR.getValue(0);
    var nSMA = xSMA.getValue(0);
    var nPrevSMA = xSMA.getValue(-1);
    var nPrevHATR = xHighestATR.getValue(-1)
    var nClose = xClose.getValue(0);
    var nLow = xLow.getValue(0);
    var nHigh = xHigh.getValue(0);
    var nPrevHigh = xHigh.getValue(-1);


    if (bIsLong){
        if (nHigh > vHighestHigh && (nLow - TrlStop) > vStopPrice) {
            vStopPrice = (nLow - TrlStop);
            vHighestHigh = nHigh
        }
        else if (nLow <= vStopPrice){
            drawTextRelative(0, AboveBar1, "\u00EA", Color.red, null, Text.PRESET|Text.CENTER, "Wingdings", 10, "Exit"+rawtime(0));
            drawText("Suggested Long Exit at "+formatPriceNumber(vStopPrice),BottomRow1,Color.red,Text.LEFT,"Text Exit"+rawtime(0));
            bIsLong = false;
            bEntryFound = false;
        }
    }
    
    if (bEntryFound && !bIsLong && nHigh >= vHighOfDay) {
        drawTextRelative(0,BelowBar1, "\u00E9", Color.green, null, Text.PRESET|Text.CENTER, "Wingdings", 10, "Long"+rawtime(0));
        drawText("Suggested Long Entry at "+formatPriceNumber(vHighOfDay),TopRow1,Color.green,Text.LEFT,"Text"+rawtime(0));
        bIsLong = true;
        vStopPrice = (nLow - TrlStop);
        vHighestHigh = nHigh;
    }

    if(!bIsLong && nATR >= nPrevHATR && nHigh > nSMA && nPrevSMA > nPrevHigh){
        if (!isWR || isWR && IsWideCandle()) { 
            vHighOfDay = nHigh + 0.5;
            bEntryFound = true;
        }
    }

    return nSMA;
}

function IsWideCandle(){
    if (xWR.getValue(0) > xWR.getValue(-1))
        return true;
    else return false;
}

function calcRange(){
    return high() - low();
}

function verify(){
    var b = false;
    if (getBuildNumber() < 779){
        
        drawTextAbsolute(5, 35, "This study requires version 12.1 or later.", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "error");
        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=https://www.esignal.com/download/default.asp", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "upgrade");
        return b;
    } 
    else
        b = true;
    
    return b;
}

—Eric Lippert
eSignal, an Interactive Data company
800 779-6555, www.eSignal.com

BACK TO LIST

logo

THINKORSWIM: JUNE 2016

In “ATR Breakout Entries,” which appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, author Ken Calhoun concisely covers the steps of how to create a trading strategy using two common indicators: the average true range, and a simple moving average to determine institutional buying and price breakouts.

We have built his strategy and a filter using our proprietary scripting language, thinkscript. We have made the loading process extremely easy: simply click on the links https://tos.mx/qShvp5 and https://tos.mx/mDtPet and choose view thinkScript strategy and view Scan Query. Choose to rename your strategy as “ATRBreakoutsLE” and you can save your Scan Query as “ATRBreakouts Scan.” You can adjust the parameters of this strategy within the edit studies window to fine-tune your variables.

Sample Chart

FIGURE 4: THINKORSWIM. Here is a sample chart of Verizon (VZ) with the ATRBreakoutsLE strategy added as well as the exit strategy TrailStopLX with a $1.00 value.

In Figure 4, you see a sample chart of Verizon (VZ) with the ATRBreakoutsLE strategy added. We have also added our exit strategies, TrailStopLX with a $1.00 value, based on Calhoun’s article. For more details about the trading strategy, please see Calhoun’s article in the May 2016 issue of S&C.

—thinkorswim
A division of TD Ameritrade, Inc.
www.thinkorswim.com

BACK TO LIST

logo

WEALTH-LAB: JUNE 2016

The WealthScript (C#) code for Ken Calhoun’s swing trading setup, which he describes in his article “ATR Breakout Entries” that appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, is provided here. In the article, Calhoun states that trade selection gets improved by avoiding low-volatility stocks. The idea is to find trading candidates among those in which there has been an increase in volatility and volume. See Figure 5.

Sample Chart

FIGURE 5: WEALTH-LAB. Here is an example of a breakout entry in NUGT in February 2016.

Because the trade may be entered “on any day following this signal,” we installed a timeout condition to invalidate the signal after five bars. In our limited testing, the setup is quite focused, so that many potential trade candidates may be missed. Traders might want to adjust the various criteria such as price, volume, and range to get more alerts.

In addition, since the setup tests price/volume levels that are hardcoded, there’s one special precaution that we must account for in the code if it’s intended for backtesting. Since traders mainly use back-adjusted price and volume data, comparing a price in the past with “today’s” price range would be peeking into the future. For example, AAPL’s adjusted price prior to the June 2014 seven-to-one split puts its data squarely in the strategy’s price range, when actually it never traded in the $15 to $75 range from 2009 to 2014. Considering this, to avoid this pitfall, the strategy first “unadjusts” the price/volume for future splits.

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using WealthLab.Rules;

namespace WealthLab.Strategies
{
	public class MyStrategy : WealthScript
	{
		protected override void Execute()
		{
			var ma = SMA.Series(Close,100);
			var atr = ATR.Series(Bars,14);
			var atr_hi = Highest.Series(atr,14);
			bool setupValid = false;
			int setupBar = -1, setupTimeout = 5;
			
			// Unadjusted price and volume series for future splits
			DataSeries reverseAdj;
			DataSeriesOp.SplitReverseFactor(this, "Split (Yahoo! Finance)", out reverseAdj);
			DataSeries CloseAdj = Close * reverseAdj;
			DataSeries VolumeAdj = Volume / reverseAdj;
			PlotSeries(PricePane, CloseAdj, Color.Black, LineStyle.Solid, 1);
			PlotSeries(VolumePane, VolumeAdj, Color.Black, LineStyle.Solid, 1);
			
			var range = (High - Low) * reverseAdj;
			var range_avg = SMA.Series(range,5);
			var vol_avg = SMA.Series(Volume/reverseAdj, 5);
			
			for(int bar = GetTradingLoopStartBar(100); bar < Bars.Count; bar++)
			{
				
				if (IsLastPositionActive)
				{
					Position p = LastPosition;
					double amount = p.Bars.Low[bar] - 2.0;
					SellAtTrailingStop(bar + 1, p, amount);
				}
				else
				{
					if( !setupValid )
					{
						if( (CloseAdj[bar] > 15.0) && (CloseAdj[bar] < 70.0) )
							if( range[bar] > 5.0 )
								if( VolumeAdj[bar] > 1000000 )
									if( atr[bar] == atr_hi[bar] )
										if( Close[bar] > ma[bar] )
											if( (range[bar] > (range_avg[bar] * 1.5)) || (VolumeAdj[bar] > (vol_avg[bar] * 1.5)) )
											{
												setupValid = true;
												setupBar = bar;
											}
					}
					if( setupValid )
					{					
						if( BuyAtStop(bar+1, High[setupBar] + 0.50) != null )
							setupValid = false;
						else
							// reset if Setup has timed out
							setupValid = bar + 1 - setupBar < setupTimeout;
					}					
				}
			}
		}
	}
}

—Robert Sucher & Eugene, Wealth-Lab team
MS123, LLC
www.wealth-lab.com

BACK TO LIST

logo

AMIBROKER: JUNE 2016

In “ATR Breakout Entries” which appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, author Ken Calhoun presents a very simple strategy based on price breakouts confirmed by an uptrending average true range (ATR).

A ready-to-use exploration and system formula that finds such opportunities is provided here (see Figure 6 for a sample implementation). To use the formula, enter the code in the formula editor and press send to analysis to perform explorations and/or backtests.

Note that we have found that the $2 stops suggested in the article did not produce profitable trades, so we changed it in our code to a 20% profit target and a 10% trailing stop activated after five days.

We would suggest running extensive backtests prior to using a trading system like this one, since a single example trade such as that given in the article does not necessarily make for a robust system.

Amibroker Code

Step1 = HHV( Close, 90 ) < 70 AND 
        LLV( Close, 90 ) > 15 AND    
        MA( V, 20 ) > 1000000; 
         
myatr = ATR( 14 );         
       
candleheight = High - Low; 
       
Step2 = HHVBars( myatr, 14 ) == 0 AND // at 14 day high 
      Close > MA( Close, 100 ) AND  // close above MA100 
      candleheight > 1.5 * Ref( candleheight, -1 ) AND // wide range candle 
      Volume > Ref( Volume, -1 ); // increase in volume 


TriggerPrice = ValueWhen( Cross( C, MA( C, 100 ) ), High ); 

// for backtest 
Buy = Hold( Step1 AND Step2, 10 ) AND 
      Close > TriggerPrice; 
    
Sell = 0; 

// profit target 
ApplyStop( stopTypeProfit, stopModePercent, 25); 
// trailing stop activated after 5 days 
ApplyStop( stopTypeTrailing, stopModePercent, 10, True, False, 0, 5  ); 

SetOption("MaxOpenPositions", 10 ); 
SetPositionSize(10, spsPercentOfEquity); 

// for exploration 
Filter = Step1 AND Step2; 
AddColumn( myatr, "ATR" ); 
AddColumn( TriggerPrice, "TriggerPrice" ); 
AddColumn( Buy, "Buy", 1.0 ); 

—Tomasz Janeczko, AmiBroker.com
www.amibroker.com

BACK TO LIST

logo

NINJATRADER: JUNE 2016

The ATR breakout strategy presented by Ken Calhoun in his May 2016 article in S&C, “ATR Breakout Entries,” is available for download at www.ninjatrader.com/SC/June2016SC.zip.

Once you have it downloaded, from within the NinjaTrader Control Center window, select the menu File → Utilities → Import NinjaScript and select the downloaded file. This file is for NinjaTrader Version 7.

You can review the strategy’s source code by selecting the menu Tools → Edit NinjaScript → Strategy from within the NinjaTrader Control Center window and selecting the ATRBreakout file.

NinjaScript uses compiled DLLs that run native, not interpreted, which provides you with the best performance possible.

The ATRBreakout adds the ATR, SMA, and VOL to the chart, which can be seen on the daily chart of NUGT in Figure 7.

Sample Chart

FIGURE 7: NINJATRADER. The ATRBreakout download adds the ATR, SMA, and VOL to the chart, which can be seen on this daily chart of NUGT.

—Raymond Deux & Patrick Hodges
NinjaTrader, LLC
www.ninjatrader.com

BACK TO LIST

logo

NEUROSHELL TRADER: JUNE 2016

The ATR breakout entry system presented by Ken Calhoun in his article that appeared last month in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, “ATR Breakout Entries,” can be easily implemented with a few of NeuroShell Trader’s 800+ indicators. Simply select new indicator from the insert menu and use the indicator wizard to create the following condition indicators:

Entry1:  CrossAbove(Close,Avg(Close,100))
Entry2:  High Channel Breakout(ATR(High,Low,Close,14),14),
Entry3:  A>B(Divide(Candle Body Length(O,H,L,C),Lag(Max(CandleBodyLength(O,H,L,C),5),1)),1.5)

EntryCondition:  And3(Entry1, Entry2, Entry3)

To implement the entry conditions as a trading system, simply select new trading strategy from the insert menu and enter the following in the appropriate locations of the trading strategy wizard:

BUY LONG CONDITIONS: [All of which must be true]
     A>B(Max(EntryCondition,10),0)
   
STOP PRICE: SelectiveAvg(Add2(High,0.5), EntryCondition,1)

LONG TRAILING STOP PRICES:
     TrailPricePnts(Trading Strategy,2)

Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download a copy of this or any previous Traders’ Tips.

A sample chart implementing the strategy is shown in Figure 8.

Sample Chart

FIGURE 8: NEUROSHELL TRADER. This NeuroShell Trader chart displays the ATR breakout entry system.

—Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com

BACK TO LIST

logo

AIQ: JUNE 2016

The AIQ code based on Ken Calhoun’s article from the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, “ATR Breakout Entries,” is provided at www.TradersEdgeSystems.com/traderstips.htm.

Figure 9 shows the EDS test results over the most recent four-year period on all stocks that meet the screening criteria. I had to lower the minimum range (“minR” input variable) from 5 down to 1 to get enough signals for a test.

Sample Chart

FIGURE 9: AIQ. Here are the EDS test summary results of a backtest on all stocks over the four-year period ending on 4/13/2016.

I tried some other exits and found that the trailing stop was not the best one to use.

!ATR Breakout Entries
!Author: Ken Calhoun, TASC June 2016
!Coded by: Richard Denning 4/13/2016
!www.TradersEdgeSystem.com

!INPUTS:
ATRwLen is 14.
minR 	is 1.
minP 	is 15.
maxP 	is 70.
avgVlen 	is 90.
minV	is 10000.
smaLen 	is 100.
trailAmt 	is 2.00.

! ABBREVIATIONS:
C 	is [close].
C1	is valresult(C,1).
H 	is [high].
L 	is [low].
O 	is [open].
V	is [volume].
V1 	is valresult(V,1).
avgV	is simpleavg(V,avgVlen).
smaC	is simpleavg(C,smaLen).
smaC1 	is valresult(smaC,1).
OSD 	is offSetToDate(month(),day(),year()).

! AVERAGE TRUE RANGE:
ATRlen 	is ATRwLen*2-1.
TR 	is Max(H - L,max(abs(C1 - L),abs(C1- H))). 
ATR	is expavg(TR,ATRlen).

step1 	if C > minP and C < maxP 
	and H - L >= minR
	and C > O
	and avgV > minV.

step2 	if ATR = highresult(ATR,ATRwLen) 
	and C > smaC 
	and H - L >= highresult(H-L,4,1)*1.5.

buyStopHos is scanany(C>smaC and C1<=smaC1,20) then OSD.
buyStopH is valresult(H,^buyStopHos).
step3	if H > buyStopH + 0.50.

Buy	if valrule(step1,1) and valrule(step2,1) and step3.
EntryPr	is max(buyStopH + 0.51,O).

PD	is {Position days}.
PHP	is highresult(C,PD).
PEP	is {Position Entry Price}.
Exit 	if L < Max(PEP-trailAmt,PHP-trailAmt).
ExitPr	is min(Max({Position Entry Price}-trailAmt,PHP-trailAmt),O) - 0.01.

Again, the code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

BACK TO LIST

logo

TRADERSSTUDIO: JUNE 2016

The TradersStudio code based on Ken Calhoun’s article that appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, “ATR Breakout Entries,” can be found at www.TradersEdgeSystems.com/traderstips.htm.

The following code file is provided in the download:

Figure 10 shows the equity curve trading the system on the NASDAQ 100 list of stocks over the period 10/1/1994 to 7/11/2014, trading one share per stock, with slippage and commissions deducted.

Sample Chart

FIGURE 10: TRADERSSTUDIO. Here is a sample equity curve trading the ATR breakout entry system on the NASDAQ 100 list of stocks over the period 10/1/1994 to 7/11/2014.

The code is shown here:

'ATR Breakout Entries
'Author: Ken Calhoun, TASC June 2016
'Coded by: Richard Denning 4/13/2016
'wwwTradersEdgeSystem.com

Sub ATR_BRK(atrLen,minR,minP,maxP,avgVLen,minV,smaLen,atrFact,fact,stopAmt)
'atrLen=14, minR=1, minP=15, maxP=70, avgVLen=90, minV=10000
'smaLen=100, trailAmt=2

Dim step1 As BarArray
Dim avgV As BarArray
avgV=Average(V,avgVLen)
step1=TSCLose>minP And TSCLose<maxP And TSHigh-TSLow>=minR And C>O And avgV>minV

Dim step2 As BarArray
Dim ATR As BarArray
Dim smaC As BarArray
Dim hATR As BarArray
smaC=Average(C,smaLen)
ATR=AvgTrueRange(atrLen)
step2=C>smaC And TSHigh-TSLow>=ATR*atrFact 

Dim buyStopHos As BarArray
Dim buyStopH As BarArray
buyStopHos=MRO(C>smaC And C[1]<=smaC[1],20)
If buyStopHos>-1 Then
    buyStopH=H[buyStopHos]
Else buyStopH=1000
End If

If step1 And step2 Then
    Buy("LE",1,buyStopH+fact,Stop,Day)
End If

If L<smaC Then
    ExitLong("LXsma","",1,smaC,Stop,Day)
End If
If L<EntryPrice-stopAmt Then
    ExitLong("LXstop","",1,EntryPrice-stopAmt,Stop,Day)
End If
End Sub

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST

logo

UPDATA: JUNE 2016

Our Traders’ Tip this month is based on “ATR Breakout Entries” by Ken Calhoun, which appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES.

In the article, Calhoun seeks to combine two classic technical analysis indicators: price crossing a moving average, and an average true range (ATR) indicator for timing the entry into stocks. By incorporating other mechanisms such as bar range filters and minimum volume thresholds for trade entry, Calhoun seeks to filter stocks for the most robust signals that carry the most momentum.

The Updata code is in the Updata library and may be downloaded by clicking the custom menu and system library. Those who cannot access the library due to a firewall issue may paste the code shown here into the Updata custom editor and save it.

'ATRwithMABreakouts
PARAMETER "Volume (x 100000)" @VOLTHRESH=100 
PARAMETER "ATR Period" @ATRPERIOD=14
PARAMETER "ATR Donchian" #ATRDONCH=14
PARAMETER "Average Period" #PERIOD=100
PARAMETER "Stop Trail ($)" @STOP=20
PARAMETER "Candle Mult." @MULT=1.5
DISPLAYSTYLE 4LINES 
INDICATORTYPE TOOL
INDICATORTYPE3 CHART
INDICATORTYPE4 TOOL
COLOUR RGB(200,0,0)
COLOUR2 RGB(0,200,0)
COLOUR3 RGB(200,200,200) 
COLOUR4 RGB(100,100,100) 
NAME "AVG[" #PERIOD "] STOP[" @STOP "]" ""
NAME3 "ATR[" @ATRPERIOD "][" #ATRDONCH "]" ""
@MOVAVG=0
@ATR=0
@RANGE=0 
@STOPLEVEL=0
FOR #CURDATE=#PERIOD TO #LASTDATE
     @RANGE=HIGH-LOW
     @MOVAVG=MAVE(#PERIOD)
     @ATR=ATR(@ATRPERIOD)   
     'ENTRIES
     IF ORDERISOPEN=1
        @STOPLEVEL=MAX(@STOPLEVEL,LOW(1)-@STOP)
        IF LOW<@STOPLEVEL
           SELL @STOPLEVEL
        ENDIF
     ENDIF 
     'EXITS 
     IF (@RANGE>HIST(@RANGE,1)*@MULT OR VOL>HIST(VOL,1)) AND VOL>@VOLTHRESH*100000
        IF HIST(@ATR>HIST(@ATR,1) AND @ATR>PHIGH(@ATR,#ATRDONCH,1) AND CLOSE>@MOVAVG,1) AND ORDERISOPEN=0
           BUY OPEN 
           @STOPLEVEL=LOW-@STOP
        ENDIF
     ENDIF 
     @PLOT=@MOVAVG  
     IF ORDERISOPEN=1
     @PLOT2=@STOPLEVEL  
     ELSE
     @PLOT2=-10000
     ENDIF
     @PLOT3=@ATR
     @PLOT4=PHIGH(@ATR,#ATRDONCH,1)
NEXT

A sample chart is shown in Figure 11.

Sample Chart

FIGURE 11: UPDATA. Here are example ATR breakout entries as applied to Direxion Gold Miner Bull (X3) ETF in daily resolution. The February 4th trade that was demonstrated in Ken Calhoun’s May 2016 S&C article is shown here with a blue arrow.

—Updata support team
support@updata.co.uk
www.updata.co.uk

BACK TO LIST

MICROSOFT EXCEL: JUNE 2016

In “ATR Breakout Entries,” which appeared in the May 2016 issue of Technical Analysis of STOCKS & COMMODITIES, author Ken Calhoun gives us a way to see powerful breakouts in their early stages.

NUGT begins to look like a gathering storm when the volume explodes in late September 2015.

Calhoun’s setup criteria are fairly severe in that setups do not appear very often (Figure 12). For NUGT, out of 1,330 bars of history, the setup conditions were met on only four occasions. Of these four, only two met the trade entry threshold of $0.50 above the high of the setup bar. In Figure 13 we can see one of each type.

Sample Chart

FIGURE 12: EXCEL, SETUP CRITERIA. You can see that there were not very many trades with this tough setup and entry criteria.

Sample Chart

FIGURE 13: EXCEL. This chart replicates the one from Ken Calhoun’s May 2016 article.

On October 28, 2015 we have a failed setup. The horizontal bar on the chart is the entry threshold price set $0.50 above the high of that setup bar. No subsequent bar exceeded that threshold before prices slid back under the 100-day moving average, thus negating the setup.

On February 3, 2016 we have another setup, and on February 4 we have a price bar that exceeds the entry threshold, triggering a long entry (green up arrow).

Using a $2.00 trailing stop, we would be stopped out on the next bar with a $0.41 per-share loss, even though it is an up bar continuing the existing trend. The bar simply opened too low for our trailing stop.

Being stopped out like this should not really be a surprise, given the price behavior for this ETF. At the entry bar for this trade, the average true range is 3.12 and it gets larger from there. So a larger stop allowance might be in order.

To see what would happen, I tried a $4.00 stop, which allowed the trade to run three more bars and turned a $7.33 per-share profit. A more robust exit strategy (or steady gambler’s nerves?) might allow one to stay in this trade longer to reap the benefits of this highly volatile uptrend.

New with this spreadsheet: A spin button in the charting controls (click to shift…) will allow the user to step the charting data forward or backward one bar at a time.

I find single-stepping can be a good way to test my understanding of the author’s ideas as I watch the evolution of the price behavior and the behavior of the author’s choice of indicators.

Enjoy!

The spreadsheet file for this Traders’ Tip can be downloaded from here. To successfully download it, follow these steps:

—Ron McAllister
Excel and VBA programmer
rpmac_xltt@sprynet.com

BACK TO LIST

Originally published in the June 2016 issue of
Technical Analysis of STOCKS & COMMODITIES magazine.
All rights reserved. © Copyright 2016, Technical Analysis, Inc.