ATR afl

29
TRADERS’ TIPS June 2009 Here is this month’s selection of Traders’ Tips, contributed by various developers of technical analysis software to help readers more easily implement some of the strategies presented in this and other issues. Other code appearing in articles in this issue is posted in the Subscriber Area of our website at http://technical.traders.com /sub/sublogin.asp. Login requires your last name and subscription number (from mailing label). Once logged in, scroll down to beneath the “Optimized trading systems” area until you see “Code from articles.” From there, code can be copied and pasted into the appropriate technical analysis program so that no retyping of code is required for subscribers. You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply “select” the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose “copy” from the browser menu. The copied text can then be “pasted” into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open web page, data can be transferred with ease. This month’s tips include formulas and programs for: TRADESTATION: AVERAGE TRUE RANGE TRAILING STOPS ESIGNAL: AVERAGE TRUE RANGE TRAILING STOPS WEALTH-LAB: AVERAGE TRUE RANGE TRAILING STOPS AMIBROKER: AVERAGE TRUE RANGE TRAILING STOPS NEUROSHELL TRADER: AVERAGE TRUE RANGE TRAILING STOPS AIQ: AVERAGE TRUE RANGE TRAILING STOPS TRADERSSTUDIO: AVERAGE TRUE RANGE TRAILING STOPS STRATASEARCH: AVERAGE TRUE RANGE TRAILING STOPS STOCKFINDER: AVERAGE TRUE RANGE TRAILING STOPS NEOTICKER: AVERAGE TRUE RANGE TRAILING STOPS TRADECISION: AVERAGE TRUE RANGE TRAILING STOPS NINJATRADER: AVERAGE TRUE RANGE TRAILING STOPS WAVE59: AVERAGE TRUE RANGE TRAILING STOPS VT TRADER: AVERAGE TRUE RANGE TRAILING STOPS TRADE-IDEAS: AVERAGE TRUE RANGE TRAILING STOPS METASTOCK: AVERAGE TRUE RANGE TRAILING STOPS (VERVOORT ARTICLE CODE) TRADESTATION: AVERAGE TRUE RANGE TRAILING STOPS Sylvain Vervoort’s article in this issue, “Average True Range Trailing Stops,” describes a technique for generating trading signals with average true range calculations. Once the initial entry is made, any number of reversals may follow. The strategy’s first trade date and first trade direction are established by user inputs. To download the EasyLanguage code for this study, go to the TradeStation and EasyLanguage Support Forum (https://www.tradestation.com/Discussions/forum.aspx?Forum_ID=213). Search for the file “Vervoort ATR Trail.eld.” 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. FIGURE 1: TRADESTATION, ATR TRAILING STOP STRATEGY. Here is an example of the Vervoort ATR_Trail strategy on a chart of Google, Inc. (GOOG). The levels at which the strategy enters new long positions are displayed by the cyan lines. The short entry levels are displayed by the magenta lines. The chart on the left displays the levels based on the original ATR trail calculation. In the chart at right, the modified calculations are used. Strategy: Vervoort ATR_Trail { Modified ATR Trailing Stop } inputs: TrailType ( 1 ), { enter 1 for modified version, any other number for unmodified version } ATR_Period( 5 ), ATR_Factor( 3.5 ), Quantity( 100 ), InitialMonth( 1 ), InitialDay( 1 ), TRADERS’ TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2... 1 of 29 9/27/2009 8:11 AM

description

Amibroker afl and atr

Transcript of ATR afl

  • TRADERS TIPS

    June 2009Here is this months selection of Traders Tips, contributed by various developers of technical analysis software to help readers

    more easily implement some of the strategies presented in this and other issues.

    Other code appearing in articles in this issue is posted in the Subscriber Area of our website at http://technical.traders.com

    /sub/sublogin.asp. Login requires your last name and subscription number (from mailing label). Once logged in, scroll down to

    beneath the Optimized trading systems area until you see Code from articles. From there, code can be copied and pasted into

    the appropriate technical analysis program so that no retyping of code is required for subscribers.

    You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply select the

    desired text by highlighting as you would in any word processing program, then use your standard key command for copy

    or choose copy from the browser menu. The copied text can then be pasted into any open spreadsheet or other

    software by selecting an insertion point and executing a paste command. By toggling back and forth between an

    application window and the open web page, data can be transferred with ease.

    This months tips include formulas and programs for:

    TRADESTATION: AVERAGE TRUE RANGE TRAILING STOPS

    ESIGNAL: AVERAGE TRUE RANGE TRAILING STOPS

    WEALTH-LAB: AVERAGE TRUE RANGE TRAILING STOPS

    AMIBROKER: AVERAGE TRUE RANGE TRAILING STOPS

    NEUROSHELL TRADER: AVERAGE TRUE RANGE TRAILING STOPS

    AIQ: AVERAGE TRUE RANGE TRAILING STOPS

    TRADERSSTUDIO: AVERAGE TRUE RANGE TRAILING STOPS

    STRATASEARCH: AVERAGE TRUE RANGE TRAILING STOPS

    STOCKFINDER: AVERAGE TRUE RANGE TRAILING STOPS

    NEOTICKER: AVERAGE TRUE RANGE TRAILING STOPS

    TRADECISION: AVERAGE TRUE RANGE TRAILING STOPS

    NINJATRADER: AVERAGE TRUE RANGE TRAILING STOPS

    WAVE59: AVERAGE TRUE RANGE TRAILING STOPS

    VT TRADER: AVERAGE TRUE RANGE TRAILING STOPS

    TRADE-IDEAS: AVERAGE TRUE RANGE TRAILING STOPS

    METASTOCK: AVERAGE TRUE RANGE TRAILING STOPS (VERVOORT ARTICLE CODE)

    TRADESTATION: AVERAGE TRUE RANGE TRAILING STOPS

    Sylvain Vervoorts article in this issue, Average True Range Trailing Stops, describes a technique for generating trading signals

    with average true range calculations. Once the initial entry is made, any number of reversals may follow. The strategys first trade

    date and first trade direction are established by user inputs.

    To download the EasyLanguage code for this study, go to the TradeStation and EasyLanguage Support Forum

    (https://www.tradestation.com/Discussions/forum.aspx?Forum_ID=213). Search for the file Vervoort ATR Trail.eld.

    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.

    FIGURE 1: TRADESTATION, ATR TRAILING STOPSTRATEGY. Here is an example of the VervoortATR_Trail strategy on a chart of Google, Inc. (GOOG).The levels at which the strategy enters new longpositions are displayed by the cyan lines. The shortentry levels are displayed by the magenta lines. Thechart on the left displays the levels based on theoriginal ATR trail calculation. In the chart at right, themodified calculations are used.

    Strategy: Vervoort ATR_Trail

    { Modified ATR Trailing Stop }inputs:

    TrailType ( 1 ), { enter 1 for modified version, any other number for unmodified version }ATR_Period( 5 ),ATR_Factor( 3.5 ),Quantity( 100 ),InitialMonth( 1 ),InitialDay( 1 ),

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    1 of 29 9/27/2009 8:11 AM

  • InitialDay( 1 ),InitialYear( 2009 ),FirstTrade( 1 ) ; { enter 1 for long, any other number for short }

    variables:Loss( 0 ),HiLo( 0 ),HRef( 0 ),LRef( 0 ),HiLoHRefMax( 0 ),HiLoHRefMaxLRefMax( 0 ),ATRMod( 0 ),WaitingForEntry( true ),Trail( 0 ),LineNum( 0 ),ReturnVal( 0 ) ;

    if TrailType 1 then

    Loss = ATR_Factor * AvgTrueRange( ATR_Period )else

    beginHiLo = iff( High - Low < 1.5 * Average( High - Low, ATR_Period ), High - Low, 1.5 * Average( High - Low, ATR_Period ) ) ;HRef = iff( Low = Low[1], Close[1] - Low, ( Close[1] - Low ) - 0.5 * ( Low[1] - High ) ) ;HiLoHRefMax = Maxlist( HiLo, HRef ) ;HiLoHRefMaxLRefMax = Maxlist( HiLoHRefMax, LRef ) ;ATRMod = XAverage( HiLoHRefMaxLRefMax, 2 * ATR_Period - 1 ) ;Loss = ATR_Factor * ATRMod ;end ;

    if WaitingForEntry and Year( Date ) + 1900 >= InitialYearand Month( Date ) >= InitialMonth and DayOfMonth( Date ) >= InitialDay

    thenbeginif FirstTrade = 1 then

    beginBuy Quantity shares this bar Close ;

    WaitingForEntry = false ;Trail = Close - Loss ;end

    elsebeginSell short Quantity shares this bar at Close ;

    WaitingForEntry = false ;Trail = Close + Loss ;end ;

    end else if WaitingForEntry[1] = false then

    beginif Close > Trail[1] and Close[1] > Trail[2] then

    { continued long }Trail = MaxList( Trail[1], Close - Loss )

    else if Close < Trail[1] and Close[1] < Trail[2] then

    { continued short }Trail = MinList( Trail[1], Close + Loss )

    else if Close > Trail[1] then { close is above trail }Trail = Close - Loss

    else Trail = Close + Loss ;

    if MarketPosition = -1 and Close > Trail and Trail > 0 then

    beginBuy Quantity shares this bar Close ;LineNum = TL_New( Date[1], Time[1], Trail[1], Date, Time, Trail[1] ) ;ReturnVal = TL_SetColor( LineNum, Cyan ) ;end

    else if MarketPosition = 1 and Close < Trail thenbeginSell short Quantity shares this bar at Close ;LineNum = TL_New( Date[1], Time[1], Trail[1], Date, Time, Trail[1] ) ;ReturnVal = TL_SetColor( LineNum, Magenta ) ;end

    else if Trail[1] > 0 thenbegin

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    2 of 29 9/27/2009 8:11 AM

  • beginLineNum = TL_New( Date[1], Time[1], Trail[1], Date, Time, Trail ) ;if Close > Trail then

    ReturnVal = TL_SetColor( LineNum, Magenta )else

    ReturnVal = TL_SetColor( LineNum, Cyan ) ;end ;

    end ;

    Mark Mills

    TradeStation Securities, Inc.

    A subsidiary of TradeStation Group, Inc.

    www.TradeStation.com

    BACK TO LIST

    ESIGNAL: AVERAGE TRUE RANGE TRAILING STOPS

    For this months Traders Tip, weve provided the following three formulas: ATR_TrailingStop.efs, Modified_ATR.efs, and

    Modified_ATR_TrailingStop.efs based on the formula code from Sylvain Vervoorts article in this issue, Average True Range

    Trailing Stops.

    The ATR trailing stop formula is configured for backtesting only. This formula plots the trailing stop based on a five-period ATR

    with a multiple of 3.5. These parameters are configurable through the Edit Studies option of the Advanced Chart. In addition, the

    formula draws labels and arrows to highlight the trade signals, which may be disabled in Edit Studies. The strategy can be set to

    show long or short signals.

    The modified ATR formula simply plots the indicator with a default of five periods. This parameter may be configured through

    the Edit Studies option of the Advanced Chart. The modified ATR trailing stop formula is similar to the ATR trailing stop except

    that it uses the modified ATR. This formula uses the same defaults, which are also configurable through the Edit Studies option

    of the Advanced Chart.

    To discuss this study or download complete copies of the formula code, please visit the EFS Library Discussion Board forum

    under the Forums link at www.esignalcentral.com or visit our EFS KnowledgeBase at www.esignalcentral.com/support

    /kb/efs/. The eSignal formula scripts (EFS) are also available for copying and pasting from the STOCKS & COMMODITIES website

    at Traders.com.

    FIGURE 2: ESIGNAL, AVERAGE TRUE RANGE TRAILINGSTOP. Here is a demonstration of the ATR trailingstop, the modified ATR, and the modified ATR trailingstop.

    ATR_TrailingStop.efs

    /*********************************Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2009. 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: Average True Range Trailing Stops, by Sylvain Vervoort

    Version: 1.0 04/09/2009

    Formula Parameters: Default: ATR Period 5 ATR Multiplication 3.5 Long or Short Long Show Line Trailing Stop True Show Labels True Show Arrows True Display Cursor Labels True Line Color Red

    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); setStudyTitle("ATR Trailing Stops"); setCursorLabelName("ATR Trailing Stop", 0); setShowTitleParameters(false); setDefaultBarFgColor(Color.red, 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarThickness(2, 0);

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    3 of 29 9/27/2009 8:11 AM

  • setDefaultBarThickness(2, 0);

    askForInput(); var x=0; fpArray[x] = new FunctionParameter("nATRPeriod", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("ATR Period"); setLowerLimit(1); setUpperLimit(100); setDefault(5); } fpArray[x] = new FunctionParameter("nATRMultip", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("ATR Multiplication"); setLowerLimit(1); setUpperLimit(10); setDefault(3.5); } fpArray[x] = new FunctionParameter("bShowTS", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Line Trailing Stop"); addOption("true"); addOption("false"); setDefault("true"); } fpArray[x] = new FunctionParameter("bShowL", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Labels"); addOption("true"); addOption("false"); setDefault("true"); } fpArray[x] = new FunctionParameter("bShowArrows", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Arrows"); addOption("true"); addOption("false"); setDefault("true"); } fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Display Cursor Labels"); setDefault(true); } fpArray[x] = new FunctionParameter("sStrategy", FunctionParameter.STRING); with(fpArray[x++]){ setName("Long or Short"); addOption("Long"); addOption("Short"); setDefault("Long"); } fpArray[x] = new FunctionParameter("cColor", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Line Color"); setDefault(Color.red); } }

    var bInit = false;var bVersion = null;var xATRTrailingStop = null;var xClose = null;

    function main(nATRPeriod, nATRMultip, sStrategy, bShowTS, bShowL, bShowArrows, ViewValue, cColor){var nClose = 0;var nClose1 = 0;var nATRTS = 0;var nATRTS1 = 0;

    if (bVersion == null) bVersion = verify(); if (bVersion == false) return;

    if(bInit==false){ setShowCursorLabel(ViewValue); setDefaultBarFgColor(cColor, 0); xClose = close(); xATRTrailingStop = efsInternal("ATRTrailingStop", nATRPeriod, nATRMultip, xClose); bInit=true; }

    if(getCurrentBarIndex() == 0) return; nClose = xClose.getValue(0); nClose1 = xClose.getValue(-1); nATRTS = xATRTrailingStop.getValue(0);

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    4 of 29 9/27/2009 8:11 AM

  • nATRTS = xATRTrailingStop.getValue(0); nATRTS1 = xATRTrailingStop.getValue(-1); if (nATRTS1 == null) return;

    if (nClose1 < nATRTS1 && nClose > nATRTS1) { if (bShowArrows) drawShape( Shape.UPARROW, BelowBar1, Color.green); if (sStrategy == "Long") { if (bShowL) drawTextRelative(0, BelowBar2, " LONG", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5); Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR); } else { if (bShowL) drawTextRelative(0, BelowBar2, " EXIT", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5); if (Strategy.isShort()) Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR); } } if (nClose1 > nATRTS1 && nClose < nATRTS1) { if (bShowArrows) drawShape( Shape.DOWNARROW, AboveBar1, Color.red); if (sStrategy == "Long") { if (bShowL) drawTextRelative(0, AboveBar2, " EXIT", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5); if (Strategy.isLong()) Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR); } else { if (bShowL) drawTextRelative(0, AboveBar2, "SHORT", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME , "Arial Black", 10, "b"+(getCurrentBarCount()), -5); Strategy.doShort("Short", Strategy.MARKET, Strategy.NEXTBAR); } }

    if (bShowTS == false) return; return xATRTrailingStop.getValue(0);}

    var xATR = null;var nRef = 0;var bSecondInit = false;

    function ATRTrailingStop(nATRPeriod, nATRMultip, xSClose){var nClose = 0;var nClose1 = 0;var nLoss = 0;var nRes = 0;var nRef = ref(-1);

    if (bSecondInit == false) { xATR = atr(nATRPeriod); bSecondInit = true; } nClose = xSClose.getValue(0); nClose1 = xSClose.getValue(-1); nLoss = nATRMultip * xATR.getValue(0); if (nLoss == null || nClose1 == null) return; if (nClose > nRef && nClose1 > nRef) { nRes = Math.max(nRef, nClose - nLoss); } else { if (nClose < nRef && nClose1 < nRef) { nRes = Math.min(nRef, nClose + nLoss); } else { if (nClose > nRef) { nRes = nClose - nLoss; } else { nRes = nClose + nLoss; } } } return nRes;}

    function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 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= http://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text. RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade");

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    5 of 29 9/27/2009 8:11 AM

  • null, 13, "upgrade"); return b; } else { b = true; } return b;}

    Modified_ATR_TrailingStop.efs

    /*********************************Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2009. 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: Modified Average True Range Trailing Stops, by Sylvain Vervoort

    Version: 1.0 04/09/2009

    Formula Parameters: Default: ATR Period 5 ATR Multiplication 3.5 Long or Short Long Show Line Trailing Stop True Show Labels True Show Arrows True Display Cursor Labels True Line Color Red

    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); setStudyTitle("Modified ATR Trailing Stops"); setCursorLabelName("Modified ATR TS", 0); setShowTitleParameters(false);

    setDefaultBarFgColor(Color.red, 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarThickness(2, 0);

    askForInput(); var x=0; fpArray[x] = new FunctionParameter("nATRPeriod", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("ATR Period"); setLowerLimit(1); setUpperLimit(100); setDefault(5); } fpArray[x] = new FunctionParameter("nATRMultip", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("ATR Multiplication"); setLowerLimit(1); setUpperLimit(10); setDefault(3.5); } fpArray[x] = new FunctionParameter("bShowTS", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Line Trailing Stop"); addOption("true"); addOption("false"); setDefault("true"); } fpArray[x] = new FunctionParameter("bShowL", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Labels"); addOption("true"); addOption("false"); setDefault("true"); } fpArray[x] = new FunctionParameter("bShowArrows", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Show Arrows"); addOption("true");

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    6 of 29 9/27/2009 8:11 AM

  • addOption("true"); addOption("false"); setDefault("true"); } fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN); with(fpArray[x++]){ setName("Display Cursor Labels"); setDefault(true); } fpArray[x] = new FunctionParameter("sStrategy", FunctionParameter.STRING); with(fpArray[x++]){ setName("Long or Short"); addOption("Long"); addOption("Short"); setDefault("Long"); } fpArray[x] = new FunctionParameter("cColor", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Line Color"); setDefault(Color.red); } }

    var bInit = false;var bVersion = null;var xATRTrailingStop = null;var xClose = null;

    function main(nATRPeriod, nATRMultip, sStrategy, bShowTS, bShowL, bShowArrows, ViewValue, cColor){var nClose = 0;var nClose1 = 0;var nATRTS = 0;var nATRTS1 = 0;

    if (bVersion == null) bVersion = verify(); if (bVersion == false) return;

    if(bInit==false){ setShowCursorLabel(ViewValue); setDefaultBarFgColor(cColor, 0); xClose = close(); xATRTrailingStop = efsInternal("ModifiedATRTrailingStop", nATRPeriod, nATRMultip, xClose); bInit=true; } if(getCurrentBarIndex() == 0) return; nClose = xClose.getValue(0); nClose1 = xClose.getValue(-1); nATRTS = xATRTrailingStop.getValue(0); nATRTS1 = xATRTrailingStop.getValue(-1); if (nATRTS1 == null) return;

    if (nClose1 < nATRTS1 && nClose > nATRTS1) { if (bShowArrows) drawShape( Shape.UPARROW, BelowBar1, Color.green); if (sStrategy == "Long") { if (bShowL) drawTextRelative(0, BelowBar2, " LONG", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5); Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR); } else { if (bShowL) drawTextRelative(0, BelowBar2, " EXIT", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5); if (Strategy.isShort()) Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR); } } if (nClose1 > nATRTS1 && nClose < nATRTS1) { if (bShowArrows) drawShape( Shape.DOWNARROW, AboveBar1, Color.red); if (sStrategy == "Long") { if (bShowL) drawTextRelative(0, AboveBar2, " EXIT", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5); if (Strategy.isLong()) Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR); } else { if (bShowL) drawTextRelative(0, AboveBar2, "SHORT", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME , "Arial Black", 10, "b"+(getCurrentBarCount()), -5); Strategy.doShort("Short", Strategy.MARKET, Strategy.NEXTBAR); } }

    if (bShowTS == false) return;

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    7 of 29 9/27/2009 8:11 AM

  • return xATRTrailingStop.getValue(0);}

    var xHigh_Low = null;var xATR_Modif = null;var nRef = 0;var bSecondInit = false;

    function ModifiedATRTrailingStop(nATRPeriod, nATRMultip, xSClose){var nBarState = getBarState();var nClose = 0;var nClose1 = 0;var nLoss = 0;var nRes = 0;var nRef = ref(-1);

    if (bSecondInit == false) { xHigh_Low = efsInternal("Calc_High_Low"); xATR_Modif = efsInternal("Calc_ATRMod", nATRPeriod, nATRMultip, xSClose, xHigh_Low, sma(nATRPeriod, xHigh_Low)) bSecondInit = true; } nClose = xSClose.getValue(0); nClose1 = xSClose.getValue(-1); nLoss = nATRMultip * xATR_Modif.getValue(0); if (nLoss == null) return; if (nClose > nRef && nClose1 > nRef) { nRes = Math.max(nRef, nClose - nLoss); } else { if (nClose < nRef && nClose1 < nRef) { nRes = Math.min(nRef, nClose + nLoss); } else { if (nClose > nRef) { nRes = nClose - nLoss; } else { nRes = nClose + nLoss; } } } return nRes;}

    function Calc_High_Low() {var nRes = high(0) - low(0); if (nRes == null) return; return nRes;}

    var bThirdInit = false;var xHigh = null;var xLow = null;

    function Calc_ATRMod(nATRPeriod, nATRMultip, xTClose, xHigh_Low, xMA_High_Low) {var nHiLo = 0;var nHref = 0;var nLref = 0;var ndiff1 = 0;var ndiff2 = 0;var nHigh_Low = 0;var nMA_High_Low = 0;var nAtrMod = 0;

    if (bThirdInit == false) { xHigh = high(); xLow = low(); bThirdInit = true; }

    var nClose = xTClose.getValue(0); var nClose1 = xTClose.getValue(0); var nHigh = xHigh.getValue(0); var nHigh1 = xHigh.getValue(0); var nLow = xLow.getValue(0); var nLow1 = xLow.getValue(0);

    nHigh_Low = xHigh_Low.getValue(0); nMA_High_Low = xMA_High_Low.getValue(0) * 1.5;

    if (nHigh_Low == null || nMA_High_Low == null) return; if (nHigh_Low < nMA_High_Low) { nHiLo = nHigh_Low; } else { nHiLo = nMA_High_Low; }

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    8 of 29 9/27/2009 8:11 AM

  • if (nLow = nLow1) { nLref = nClose1 - nLow; } else { nLref = (nClose1 - nLow) - (nLow1 - nHigh) / 2; }

    ndiff1 = Math.max(nHiLo, nHref); ndiff2 = Math.max(ndiff1, nLref); nAtrMod = (ndiff2 + (nATRPeriod - 1) * ref(-1)) / nATRPeriod;

    if (nAtrMod == null) return; return nAtrMod;}

    function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 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= http://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;}

    Modified/ATR.efs

    /*********************************Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2009. 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: Modified Average True Range, by Sylvain Vervoort

    Version: 1.0 04/09/2009

    Formula Parameters: Default: ATR Period 5 Line Color Red

    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(false); setStudyTitle("Modified ATR"); setCursorLabelName("Modified ATR", 0); setShowTitleParameters(false); setDefaultBarFgColor(Color.red, 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarThickness(2, 0); askForInput(); var x=0; fpArray[x] = new FunctionParameter("nATRPeriod", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("ATR Period"); setLowerLimit(1); setUpperLimit(100); setDefault(5); } fpArray[x] = new FunctionParameter("cColor", FunctionParameter.COLOR);

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    9 of 29 9/27/2009 8:11 AM

  • fpArray[x] = new FunctionParameter("cColor", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Line Color"); setDefault(Color.red); } }

    var bInit = false;var bVersion = null;var xATR_Modif = null;

    function main(nATRPeriod, cColor){var nATR_Modif = 0;

    if (bVersion == null) bVersion = verify(); if (bVersion == false) return;

    if(bInit==false){ setDefaultBarFgColor(cColor, 0); xATR_Modif = efsInternal("Calc_ATRMod", nATRPeriod); bInit=true; }

    nATR_Modif = xATR_Modif.getValue(0); if (nATR_Modif == null) return;

    return nATR_Modif;}

    var xHigh_Low = null;var xATR_ModifTmp = null;var nRef = 0;var bSecondInit = false;

    function Calc_ATRMod(nATRPeriod, nATRMultip){var nRes = 0; if (bSecondInit == false) { xHigh_Low = efsInternal("Calc_High_Low"); xATR_ModifTmp = efsInternal("Calc_ATRModResult", nATRPeriod, xHigh_Low, sma(nATRPeriod, xHigh_Low)) bSecondInit = true; } nRes = xATR_ModifTmp.getValue(0); if (nRes == null) return; return nRes;}

    function Calc_High_Low() {var nRes = high(0) - low(0); if (nRes == null) return; return nRes;}

    var bThirdInit = false;var xClose = null;var xHigh = null;var xLow = null;

    function Calc_ATRModResult(nATRPeriod, xHigh_Low, xMA_High_Low) {var nHiLo = 0;var nHref = 0;var nLref = 0;var ndiff1 = 0;var ndiff2 = 0;var nHigh_Low = 0;var nMA_High_Low = 0;var nAtrMod = 0;

    if (bThirdInit == false) { xClose = close(); xHigh = high(); xLow = low(); bThirdInit = true; }

    var nClose = xClose.getValue(0); var nClose1 = xClose.getValue(0); var nHigh = xHigh.getValue(0); var nHigh1 = xHigh.getValue(0); var nLow = xLow.getValue(0); var nLow1 = xLow.getValue(0);

    nHigh_Low = xHigh_Low.getValue(0); nMA_High_Low = xMA_High_Low.getValue(0) * 1.5;

    if (nHigh_Low == null || nMA_High_Low == null) return;

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    10 of 29 9/27/2009 8:11 AM

  • if (nHigh_Low < nMA_High_Low) { nHiLo = nHigh_Low; } else { nHiLo = nMA_High_Low; }

    if (nLow = nLow1) { nLref = nClose1 - nLow; } else { nLref = (nClose1 - nLow) - (nLow1 - nHigh) / 2; }

    ndiff1 = Math.max(nHiLo, nHref); ndiff2 = Math.max(ndiff1, nLref); nAtrMod = (ndiff2 + (nATRPeriod - 1) * ref(-1)) / nATRPeriod;

    if (nAtrMod == null) return; return nAtrMod;}

    function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 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= http://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;}

    Jason Keck

    eSignal, a division of Interactive Data Corp.

    800 815-8256, www.esignalcentral.com

    BACK TO LIST

    WEALTH-LAB: AVERAGE TRUE RANGE TRAILING STOPS

    The modified ATR indicator presented by Sylvain Vervoort in Average True Range Trailing Stops in this issue is available in

    Wealth-Labs TascIndicator library version 1.0.7.0 and later.

    Here, well provide the WealthScript code to enter a discretionary position, long or short, on the open of a specified date given

    by the strategy parameters. Included is the ATRTrail class, which utilizes the modified ATR to calculate a trailing stop based on

    the most-recent close. You can use it with any of your strategies. Once you create an ATRTrail object, just pass the bar number to

    the ATRTrail.Price method. As with last months article, if you prefer to use touch stops, WealthScripts built-in

    ExitAtTrailingStop method is convenient.

    See Figure 3 for a sample chart.

    FIGURE 3: WEALTH-LAB, MODIFIED AVERAGE TRUERANGE STOP. INTCs three black crows following adoji-island reversal made a nice setup to enter shortwith a relatively tight stop at the center of thepattern.

    WealthScript Code (C#):

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    11 of 29 9/27/2009 8:11 AM

  • WealthScript Code (C#):

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

    namespace WealthLab.Strategies{ /* Class that encapsulates the ATR Trailing Stop, closing basis */ public class ATRTrail { private WealthScript ws; private Bars bars; private double stopPrice; private bool longPosition; private DataSeries atrMod; public ATRTrail(WealthScript wL, Bars b, bool positionLong, double initialStop, int period, double factor ) { ws = wL; bars = b; longPosition = positionLong; stopPrice = initialStop; atrMod = factor * TASCIndicators.ATRModified.Series(bars, period); } // Call this method to update and return the stop price on each bar after entry public double Price(int bar) { double prevPrice = stopPrice; double newPrice; if (longPosition) { newPrice = bars.Close[bar] - atrMod[bar]; stopPrice = newPrice > stopPrice ? newPrice : stopPrice; } else { newPrice = bars.Close[bar] + atrMod[bar]; stopPrice = newPrice < stopPrice ? newPrice : stopPrice; } ws.DrawLine(ws.PricePane, bar-1, prevPrice, bar, stopPrice, Color.Blue, LineStyle.Solid, 1); return stopPrice; } } public class SAC_ATRTrailingStops : WealthScript { private StrategyParameter _isLong = null; private StrategyParameter _initStop = null; private StrategyParameter _period = null; private StrategyParameter _atrMult = null; private StrategyParameter _y = null; private StrategyParameter _m = null; private StrategyParameter _d = null; public SAC_ATRTrailingStops() { _isLong = CreateParameter("Long = 1", 1, 0, 1, 1); _initStop = CreateParameter("Initial Stop", 1.0, 0.25, 50.0, 0.25); _period = CreateParameter("ATR Period", 5, 2, 100, 1); _atrMult = CreateParameter("ATR Multiplier", 3.5, 1.0, 5.0, 0.1); _m = CreateParameter("Month", 4, 1, 12, 1); _d = CreateParameter("Day", 13, 1, 31, 1); _y = CreateParameter("Year", 2009, 1990, 2012, 1); } /* Execute a strategy - trade on a specified date */ protected override void Execute() { DateTime dt; try { dt = new DateTime(_y.ValueInt, _m.ValueInt, _d.ValueInt); } catch { DrawLabel(PricePane, "Invalid Date", Color.Red); return; } int b = Bars.ConvertDateToBar(dt, false); if (b < 1) {

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    12 of 29 9/27/2009 8:11 AM

  • DrawLabel(PricePane, "Date does not exist on chart", Color.Red); return; } if( _isLong.ValueInt == 1 ) BuyAtMarket(b, "Discretionary"); else ShortAtMarket(b, "Discretionary"); Position p = LastPosition; // After creating a position, initialize a stop object ATRTrail atrStop = new ATRTrail(this, Bars, p.PositionType == PositionType.Long, _initStop.Value, _period.ValueInt, _atrMult.Value); for(int bar = b + 1; bar < Bars.Count; bar++) { if (p.Active) { if (p.PositionType == PositionType.Long) { if( Close[bar] < atrStop.Price(bar) ) ExitAtMarket(bar + 1, p); } else if( Close[bar] > atrStop.Price(bar) ) ExitAtMarket(bar + 1, p); } } } }}

    Robert Sucher

    www.wealth-lab.com

    BACK TO LIST

    AMIBROKER: AVERAGE TRUE RANGE TRAILING STOPS

    In Average True Range Trailing Stops in this issue, author Sylvain Vervoort continues his study of various trailing stop

    techniques. Implementing modified average true range stops is easy in AmiBroker Formula Language thanks to its built-in

    looping support, so we dont need any external DLLs.

    A ready-to-use AmiBroker formula for the ATR trailing stop technique is presented in Listing 1. This formula is an enhanced

    version of the one given in last months Traders Tips for Vervoorts May 2009 STOCKS & COMMODITIES article. In addition to

    the fixed and standard ATR stop techniques given last month, the formula allows the user to select the modified ATR method

    from the stop mode list. Most of the code is unchanged, with only a calculation added for the modified ATR. To use it, enter

    the formula into the Editor, then press Apply Indicator (see Figure 4). To adjust the stop mode and its parameters, click on the

    chart with right mouse button and select parameters from the context menu.

    FIGURE 4: AMIBROKER, MODIFIED AVERAGE TRUERANGE STOP. Here is a daily chart of CRM showing the3.5-multiple, modified ATR(5) trailing stop, with buy(green) and sell (red) arrows.

    LISTING 1

    Version(5.20); // requires v5.20 SetBarsRequired(sbrAll); // get start date Start = Cross( DateNum(), ParamDate("Start date", "2005-10-30" ) ); Started = Flip( Start, 0 ); StopMode = ParamList("Stop Mode", "Fixed|Chandelier|Modified ATR" ); StopLevel = Param("Fixed perc %", 14, 0.1, 50, 0.1)/100; StopATRFactor = Param("ATR multiple", 4, 0.5, 10, 0.1 ); StopATRPeriod = Param("ATR period", 14, 3, 50 ); // calculate support and resistance levels if( StopMode == "Fixed" ) // fixed percent trailing stop { sup = C * ( 1 - stoplevel );

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    13 of 29 9/27/2009 8:11 AM

  • sup = C * ( 1 - stoplevel ); res = C * ( 1 + stoplevel ); } else // Chandelier ATR-based stop if( StopMode == "Chandelier" ) { sup = C - StopATRFactor * ATR( StopATRPeriod ); res = C + StopATRFactor * ATR( StopATRPeriod ); } else { HL = H - L; MAHL = 1.5 * MA( HL, StopATRPeriod ); HiLo = IIf( HL < MAHL, HL, MAHL ); H1 = Ref( H, -1 ); L1 = Ref( L, -1 ); C1 = Ref( C, -1 ); Href = IIf( L = L1, C1 - L, ( C1 - L ) - ( L1 - H ) / 2 ); diff1 = Max( HiLo, HRef ); diff2 = Max( diff1, LRef ); ATRmod = Wilders( diff2, StopATRPeriod ); sup = C - StopATRFactor * ATRmod ; res = C + StopATRFactor * ATRmod ; } // calculate trailing stop line trailARRAY = Null; trailstop = 0; for( i = 1; i < BarCount; i++ ) { if( Started[ i ] == 0 ) continue; if( C[ i ] > trailstop AND C[ i - 1 ] > trailstop ) trailstop = Max( trailstop, sup[ i ] ); else if( C[ i ] < trailstop AND C[ i - 1 ] < trailstop ) trailstop = Min( trailstop, res[ i ] ); else trailstop = IIf( C[ i ] > trailstop, sup[ i ], res[ i ] ); trailARRAY[ i ] = trailstop; } // generate buy/sell signals based on crossover with trail stop line Buy = Start OR Cross( C, trailArray ); Sell = Cross( trailArray, C ); PlotShapes(Buy*shapeUpArrow,colorGreen,0,trailarray); PlotShapes(Sell*shapeDownArrow,colorRed,0,trailarray); Plot( Close,"Price",colorBlack,styleBar); //SetBarFillColor( colorYellow ); Plot( trailARRAY,"trailing stop level", colorRed, styleLine );

    Tomasz Janeczko, AmiBroker.com

    www.amibroker.com

    BACK TO LIST

    NEUROSHELL TRADER: AVERAGE TRUE RANGE TRAILING STOPS

    The average true range trailing stop technique described by Sylvain Vervoort in his article in this issue, Average True Range

    Trailing Stops, can be implemented in NeuroShell Trader by combining a few of NeuroShell Traders built-in indicators plus

    the trading strategy wizard. First, to recreate J. Welles Wilders exponential averagebased average true range indicator, select

    New Indicator from the Insert menu and use the Indicator Wizard to create the following indicator:

    Average true range (ATR) indicator:

    ExpAvg( Subtract ( Max2(High, Lag(Close,1)), Min2( Low, Lag(Close,1))), 9 )

    To recreate Sylvain Vervoorts average true range trailing stop reversal system, select New Trading Strategy from the Insert

    menu and enter the following in the appropriate locations of the Trading Strategy Wizard:

    Long protective stop:Subtract( MaxValueSinceEntryFilled(TradingStrategy, High, 1), Multiply2( 3.5, WilderAverageTrueRange)) Short protective stop:Add2( MinValueSinceEntryFilled(TradingStrategy, Low, 1), Multiply2( 3.5, WilderAverageTrueRange))

    If you wish to create an average true range trailing stop system using your own trading systems entry rules, simply combine the

    trailing stops listed above with your own entry/exit conditions.

    To recreate the modified average true range indicator, select New Indicator from the Insert menu and use the Indicator

    Wizard to create the following indicators:

    HiLo

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    14 of 29 9/27/2009 8:11 AM

  • HiLo Min2(Subtract(High,Low), MovAvg(Subtract(High,Low),5)) HrefSubtract(Subtract(High, Lag(Close,1)), IfThenElse( A=B(High, Lag(Low,1)), 0, Divide(Subtract(Lag(Low,1), High), 2))) Modified Average True RangeExpAvg( Max3( HiLo, Href, Lref ), 9)

    To recreate the modified average true range trailing stop reversal system, enter the following formula in the appropriate locations

    of the Trading Strategy Wizard:

    Long protective stop:Subtract( MaxValueSinceEntryFilled(TradingStrategy #2, High, 1), Multiply2( 3.5, ModifiedAverageTrueRange)) Short protective stop:Add2( MinValueSinceEntryFilled(TradingStrategy #2, Low, 1), Multiply2( 3.5, ModifiedAverageTrueRange))

    If you wish to create a modified average true range trailing stop system using your own trading systems entry rules, simply

    combine the modified average true range trailing stops listed above with your own entry/exit conditions.

    FIGURE 5: NEUROSHELL TRADER, AVERAGE TRUERANGE TRAILING STOP SYSTEM

    If you have NeuroShell Trader Professional, you can also choose whether the system parameters should be optimized. After

    backtesting the trading strategies, use the Detailed Analysis button to view the backtest and trade-by-trade statistics for each

    strategy.

    For more information on NeuroShell Trader, visit www.NeuroShell.com.

    Marge Sherald, Ward Systems Group, Inc.

    301 662-7950, [email protected]

    www.neuroshell.com

    BACK TO LIST

    AIQ: AVERAGE TRUE RANGE TRAILING STOPS

    The AIQ code is shown here for the date-specific version of the average true range (ATR) trailing stop and the modified average

    true range (ATRM) trailing stop described by Sylvain Vervoort in his article in this issue, Average True Range Trailing Stops.

    This ATR stop code can be pasted into any system of your choice and then used as the exit. The date-specific version (in which a

    start date is manually entered in the EDS code as an input, and then the stop starts trailing as of that date) has been coded and

    provided here as well. This stop can be plotted on a chart for the purposes of checking trades one at a time. Be sure to set all the

    inputs to match your objective.

    !! AVERAGE TRUE RANGE TRAILING STOP (DATE SPECIFIC VERSION)! Author: Sylvain Vervoort, TASC, June 2009! Coded by: Richard Denning 4/12/09

    ! INPUTS:mo is 10.da is 2.yr is 2008.isLong is 1. ! 1 = for longs, 0 = for shortsatrLen is 5.atrMult is 3.5.

    ! ABBREVIATIONS:C is [close].C1 is valresult(C,1).H is [high].L is [low].

    ! AVERAGE TRUE RANGETR is Max(H - L,max(abs(C1 - L),abs(C1- H))). ATR is expAvg(TR,atrLen).

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    15 of 29 9/27/2009 8:11 AM

  • ! ATR TRAILING STOP FROM DATEstartDate is makeDate(mo,da,yr).daysSinceStart is scanany(ruledate() = startDate, 5040)

    then offSetToDate(month(),day(),year()).loss is ATR * atrMult. longStop is C-Loss.shortStop is C+Loss.maxVal is iff(reportdate() >= startDate,^highresult(longStop,^daysSinceStart+1),C). minVal is iff(reportdate() >= startDate,^lowresult(shortStop,^daysSinceStart+1),C).

    ! PLOT "TRAIL" AS CUSTOM INDICATOR TO SEE STOP ON CHART:trail is iff(reportdate() >= startDate and isLong = 1,maxVal,

    iff(reportdate() >= startDate and isLong 1,minVal,C)).

    Buy if reportdate() = startDate and isLong = 1.Exit if C < trail.SellShort if reportdate() = startDate and isLong 1.Cover if C > trail.

    !_____________The following code must go on a second EDS file_______________

    !! MODIFIED AVERAGE TRUE RANGE TRAILING STOP (DATE SPECIFIC VERSION)! Author: Sylvain Vervoort, TASC, June 2009! Coded by: Richard Denning 4/12/09

    ! INPUTS:mo is 10.da is 2.yr is 2008.isLong is 1. ! 1 = for longs, 0 = for shortsatrLen is 5.atrMult is 3.5.

    ! ABBREVIATIONS:C is [close].C1 is valresult(C,1).H is [high].H1 is valresult(H,1).L is [low].L1 is lowresult(L,1).

    ! MODIFIED AVERAGE TRUE RANGEAvgRng is simpleAvg(H - L, atrLen) . HiLo is iff(H - L < 1.5 * AvgRng, H - L, 1.5*AvgRng).HLmax is (H - C1) - (L - H1) / 2.Href is iff(L = L1, C1 - L, LHmax).Diff1 is Max(HiLo,Href).Diff2 is Max(Diff1,Lref).ATRM is expAvg(Diff2,atrLen*2-1,0).

    ! ATR TRAILING STOP FROM DATEstartDate is makeDate(mo,da,yr).daysSinceStart is scanany(ruledate() = startDate, 5040)

    then offSetToDate(month(),day(),year()).loss is ATRM * atrMult. longStop is C-Loss.shortStop is C+Loss.maxVal is iff(reportdate() >= startDate,^highresult(longStop,^daysSinceStart+1),C). minVal is iff(reportdate() >= startDate,^lowresult(shortStop,^daysSinceStart+1),C).

    ! PLOT "TRAIL" AS CUSTOM INDICATOR TO SEE STOP ON CHART:trail is iff(reportdate() >= startDate and isLong = 1,maxVal,

    iff(reportdate() >= startDate and isLong 1,minVal,C)).

    Buy if reportdate() = startDate and isLong = 1.Exit if C < trail.SellShort if reportdate() = startDate and isLong 1.Cover if C > trail.

    The code can be downloaded from the AIQ website at www.aiqsystems.com and also from

    www.TradersEdgeSystems.com/traderstips.htm. It can also copied and pasted from the STOCKS & COMMODITIES website at

    Traders.com.

    Richard Denning

    for AIQ Systems

    [email protected]

    BACK TO LIST

    TRADERSSTUDIO: AVERAGE TRUE RANGE TRAILING STOPS

    The TradersStudio implementation of the fixed-percentage trailing stop system and the date-specific version based on Average

    True Range Trailing Stops by Sylvain Vervoort is discussed here.

    The average true range (ATR) trailing stop should have an advantage over the fixed-percentage trailing stop that was tested last

    month in my May 2009 Traders Tip, since the stop can adapt to the changing volatility of both the overall market as well as to

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    16 of 29 9/27/2009 8:11 AM

  • month in my May 2009 Traders Tip, since the stop can adapt to the changing volatility of both the overall market as well as to

    each individual stocks volatility and changes in volatility.

    In my May 2009 Traders Tip, I modified Vervoorts fixed-percentage trailing stop system by adding market timing and also by

    trading both the long and short sides. This system, if traded both long and short, would be always in, but since I added a market-

    timing filter based on a general-market trend-following filter, it will only trade long when the market trend is up or short when

    the market trend is down.

    The coded version of Vervoorts ATR trailing stop system that I am supplying here has the options of trading either long only,

    short only, or both long and short. It also has the option to apply a market-trend filter using the S&P 500 index (SPX) to

    determine whether to trade long or short. I decided to stick with the authors list of stocks for the tests.

    One advantage in testing stocks with TradersStudio over other programs is that both the unadjusted price series as well as the

    split-adjusted series are available in the tests. This can make a big difference in the computation of commissions when they are

    based on the number of shares traded. (Other programs compute commissions on a cents-per-share basis, and unless you know

    the actual price of the stock and the actual number of shares that would have been traded, commissions cannot be computed

    accurately.) In addition, with TradersStudio, we are able to correctly apply a minimum price rule to eliminate very low-priced

    stocks. When only split-adjusted data is available, we cannot accurately apply a price filter because we dont know whether a

    stock is low-priced due to a split or was really trading at a low price in real time. TradersStudio also has the ability to compute

    the dividends that you would have been received or paid (if short).

    FIGURE 6: TITLE.blurb

    In Figure 6, I show a comparison of the equity curves: the left one represents trading both long and short using a trend filter on

    the SPX with optimized parameters using the fixed-percentage trailing stop system from the May 2009 issue, while the one on the

    right shows this issues modified ATR trailing stop (ATRM) system with optimized parameters. Just by looking at the two equity

    curves, its hard to tell which is preferable, although the ATRM (right curve) appears smoother with smaller drawdowns.

    Looking at the table in Figure 7, which shows some key metrics for the two trailing-stop methods, we see that the ATRM stops

    are preferable, since we obtain slightly more net profit with lower drawdown, better profit factor, and better profit-to-maximum

    drawdown ratios with fewer trades. I also found that there is a slight improvement (not shown) by using the ATRM system

    versus the ATR system.

    FIGURE 7: TITLE.blurb

    To measure the robustness of the parameter sets from the ATRM system optimization, in Figure 8 I show two three-dimensional

    models. The left model shows the two parameters compared to the net profit, and the right model shows the two parameters

    compared to the maximum drawdown. The ATR-length parameter is less sensitive to changes than the ATR multiple. The range

    of good parameters is five to 10 days for the ATR length, and 4.5 to 5.5 for the ATR multiple. All tests used 300 days for the

    moving average length on the SPX trend filter. I used a TradersStudio add-in to produce the three-dimensional models.

    FIGURE 8: TITLE.blurb

    The code can be downloaded from the TradersStudio website at www.TradersStudio.com ->Traders Resources->FreeCode as

    well as from www.TradersEdgeSystems.com/traderstips.htm. It can also be copied and pasted from the STOCKS &

    COMMODITIES website at www.Traders.com.

    ' AVERAGE TRUE RANGE TRAILING STOPS (ATR and ATRM)' Author: Sylvain Vervoort, TASC June 2009' Coded by: Richard Denning 4/8/09' www.tradersEdgeSystems.com

    Sub ATR_TSSR(tsStartDate,WilderLenATR,multATR,longOnly,useMktTm,spxLen,useModATR)'tsStartDate = date that trading is to start after bars back has been satisfied' use TradeStation date format of YYYMMDD example 1/20/2003 = 1030120'WilderLenATR = 5, multATR = 3.5, unitSiz = 1, longOnly = 2 (both long and short)

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    17 of 29 9/27/2009 8:11 AM

  • 'WilderLenATR = 5, multATR = 3.5, unitSiz = 1, longOnly = 2 (both long and short)'longOnly = 1 (trade long side only), longOnly = -1 (short side only)'useMktTm = 1 will apply an SPX trend filter so that trades are taken only in' the direction of the trend of the SP500 index; any other value' and no market timing filter is applied' spxLen = 250' useModATR = 1 uses modified ATR; any other value uses standard ATRDim unitSizDim trail As BarArrayDim rsAIQst As BarArrayDim size As BarArrayDim SPXc As BarArrayDim OKtoBuy, OKtoSellunitSiz = 1SPXc = C Of independent1OKtoBuy = SPXc > Average(SPXc,spxLen,0) And SPXc[1] > Average(SPXc,spxLen,1)OKtoSell = SPXc < Average(SPXc,spxLen,0) And SPXc[1] < Average(SPXc,spxLen,1)If useModATR = 1 Then trail = ATRM_TRAIL_STOP(WilderLenATR, multATR)Else trail = ATR_TRAIL_STOP(WilderLenATR, multATR)End If

    size = (1000 / TSCLose) / unitSiz

    If Not CrossesOver(C,trail,0) And Not CrossesUnder(C,trail,0) Then size = size[1]If useMktTm = 1 Then If Date >= MigrateDate(tsStartDate) Then If longOnly >= 1 And OKtoBuy Then If CrossesOver(C,trail,0) Then Buy("LE",size,0,CloseEntry,Day) If CrossesUnder(C,trail,0) Then ExitLong("LX","",size[1],0, CloseExit,Day) End If If (longOnly = MigrateDate(tsStartDate) Then If longOnly >= 1 Then If CrossesOver(C,trail,0) Then Buy("LE",size,0,CloseEntry,Day) If CrossesUnder(C,trail,0) Then ExitLong("LX","",size[1],0, CloseExit,Day) End If If (longOnly trail[1] And C[1]>trail[2] Then trail = maxValElse If Ctrail[1] And C[1]trail[2] Then trail = shortStopElse trail = CEnd IfEnd IfEnd If

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    18 of 29 9/27/2009 8:11 AM

  • End IfEnd If ATR_TRAIL_STOP = trail

    End Function

    '_____________________________________________

    Function ATRM_Wilder(WilderLen)' computes average true range as modified using Wells Wilder averaging method Dim AvgRng As BarArray Dim HiLo As BarArray Dim Href As BarArray Dim Lref As BarArray Dim HLmax As BarArray Dim LHmax As BarArray Dim Diff1 As BarArray Dim Diff2 As BarArray AvgRng = Average(H - L, WilderLen) HiLo = IIF(H - L < 1.5 * AvgRng, H - L, 1.5*AvgRng) HLmax = (H - C[1]) - (L - H[1]) / 2 Href = IIF(L = L[1], C[1] - L, LHmax) Diff1 = Max(HiLo,Href) Diff2 = Max(Diff1,Lref) ATRM_Wilder = XAverage(Diff2,WilderLen*2-1,0)End Function

    '_____________________________________________

    Function ATRM_TRAIL_STOP(WilderLen,multATR)' coputes the modified ATR trailing stop' suggested default parameters: WilderLen = 5, multATR = 3.5Dim lossDim longStopDim shortStopDim maxValDim minValDim ATRval As BarArrayDim trail As BarArrayloss = ATRM_Wilder(WilderLen)*multATRlongStop = C - lossshortStop = C + lossmaxVal = Max(trail[1],longStop)minVal = Min(trail[1],shortStop)If C>trail[1] And C[1]>trail[2] Then trail = maxValElse If Ctrail[1] And C[1]trail[2] Then trail = shortStopElse trail = CEnd IfEnd IfEnd IfEnd If ATRM_TRAIL_STOP = trail

    End Function

    '_____________________________________________

    'ATR Trailing Stop Indicatorsub ATR_TRAIL_STOP_IND(WilderLen,multATR) plot1(ATR_TRAIL_STOP(WilderLen,multATR))End Sub

    '_____________________________________________

    'ATR Modified Trailing Stop IndicatorSub ATRM_TRAIL_STOP_IND(WilderLen,multATR) plot1(ATRM_TRAIL_STOP(WilderLen,multATR))End Sub

    '_____________________________________________

    Richard Denning

    for TradersStudio

    [email protected]

    BACK TO LIST

    STRATASEARCH: AVERAGE TRUE RANGE TRAILING STOPS

    In the current series of articles by Sylvain Vervoort on stop methods, including the one in this issue, Average True Range

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    19 of 29 9/27/2009 8:11 AM

  • In the current series of articles by Sylvain Vervoort on stop methods, including the one in this issue, Average True Range

    Trailing Stops, Vervoort has provided some helpful methods for implementing trailing stops. Based on our tests, the strategy

    presented in this months article provides some performance increases over the methods discussed in his article last month

    (Using Initial And Trailing Stops).

    In our tests, both the fixed-percentage trailing stop method and the modified ATR trailing stop method were run against the

    NASDAQ 100 components from 2004 to 2007 using a spread of 0.04 and commissions of $10.00 on either side. A range of

    variables was also added to test the percentage, period, and factor values. Surprisingly, every parameter set for both of the

    trailing stop approaches created profitable results. However, the modified ATR trailing stop clearly had the better performance,

    with higher returns and shorter holding periods.

    FIGURE 9: STRATASEARCH, MODIFIED ATR WITHTRAILING STOPS. One approach is to buy when theprice rises above the modified ATR line, and sell whenthe price crosses below.

    One issue, noted last month in this column as well, is that the percentage profitability never rose above 50% for either approach.

    Likewise, both approaches performed poorly when tested exclusively in 2008. Thus, these trailing stops may benefit greatly from

    the use of supporting indicators. The automated search in StrataSearch can help users find supporting indicators that improve

    either of these trailing-stop approaches.

    As with all other StrataSearch Traders Tips, additional information, including plugins, can be found in the Shared Area of the

    StrataSearch user forum.

    //****************************************************// ATR Modified//****************************************************period = parameter("Period");HiLo=If(H-L

  • FIGURE 10: STOCKFINDER, ATR TRAILING STOP. Thischart demonstrates the fixed-percentage stop, averagetrue range trailing stop (ATR TS), modified ATR TS,and a modified ATR.

    Craig Shipman

    Worden Brothers, Inc

    www.Worden.com, www.StockFinder.com

    BACK TO LIST

    NEOTICKER: AVERAGE TRUE RANGE TRAILING STOPS

    In the article Average True Range Trailing Stops in this issue, Sylvain Vervoort presents a modified version of the average true

    range indicator. This modified version, along with the trailing stop based on modified ATR, can be implemented in NeoTicker

    using formula language.

    The indicator is named Tasc modified average true range (Listing 1) with three parameters: integer parameter ATR period; real

    number parameter ATR multiplication; and datetime parameter start date. Start date is a datetime setting parameter that determines

    which date the trailing stop will beginning plotting. This indicator has two plots: the first plot will return the modified ATR value,

    and the second plot is the trailing stop value. By default, only the trailing stop plot will show (Figure 11).

    FIGURE 11: NEOTICKER, ATR TRAILING STOP

    LISTING 1

    $period := choose(param1 < 1, 1, param1 > 100, 100, param1);$atrfact := choose(param2 < 1, 1, param2 > 10, 10, param2);MidPrice := H-L;$HiLo := if(MidPrice < 1.5*average(MidPrice, $period), MidPrice, 1.5*average(MidPrice, $period));$Href := if (L = L(1), C(1)-L, ((C(1)-L)-(L(1)-H))/2);diff1 := maxlist($HiLo, $Href);diff2 := maxlist(diff1, $Lref);$atrmod := 1/$period*diff2 + ($period-1)/$period*qc_xaverage(1,diff2,$period);$loss := $atrfact*$atrmod;plot1 := $atrmod;plot2 := choose(C>plot2(1) and C(1)>plot2(1), maxlist(plot2(1),C-$loss), Cplot2(1), C-$loss, C+$loss);success2 := date(0) > param3;

    A downloadable version of the indicator will be available at the NeoTicker blog site (http://blog.neoticker.com).

    Kenneth Yuen, TickQuest Inc.

    www.tickquest.com

    BACK TO LIST

    TRADECISION: AVERAGE TRUE RANGE TRAILING STOPS

    In his series of articles on stop methods, Sylvain Vervoort demonstrates the importance of considering a warning signal and

    setting stops at the right time to avoid getting stopped out by the normal noise of the market. This issues article, Average True

    Range Trailing Stops, describes a trailing-stop method based on the average true range (ATR) trailing stop.

    Using the Function Builder in Tradecision, create the Stop_Trail_ATR_Mod function for a modified ATR trailing stop value as

    follows:

    function (Period:numeric=5,atrfact:Numeric=3.5):Numeric;var HiLo:=0; Href:=0;

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    21 of 29 9/27/2009 8:11 AM

  • Href:=0; Lref:=0; diff1:=0; diff2:=0; atrmod:=0; loss:=0; result:=0;end_var

    HiLo:=iff(H - L < 1.5 * Mov(H - L, period, S), H - L, 1.5 * Mov(H - L, period, S)); Href:=iff(L = Ref(L, -1), Ref(C, -1) - L, (Ref(C, -1) - L) - (Ref(L, -1) - H) / 2);

    diff1:=Max(HiLo, Href); diff2:=Max(diff1, Lref);

    atrmod:=EMA(diff2,period); loss:=atrfact*atrmod;

    if HISTORYSIZE this\1\ AND C\1\ > this\1\ then result := Max(this\1\,C-loss); else begin if C < this\1\ then result := Min(this\1\,C+loss); else begin if C > this\1\ then result := C-loss; else result := C+loss; end; end; end;return result; Then you specify the strategy rules in Tradecision's Strategy Builder:Entry Long:if Date() = 080102 then return true;return false;

    Exit Long:return CrossBelow(Stop_Trail_ATR_Mod(5,3.5),C);Entry Short:if Date() = 081201 then return true;return false;

    Exit Short:return CrossAbove(Stop_Trail_ATR_Mod(5,3.5),C);

    FIGURE 12: TRADECISION, MODIFIED AVERAGE TRUERANGE TRAILING STOP. Here is a 3.5 times five-periodmodified ATR average plotted on a chart of DD.

    As mentioned in Vervoorts article, youll need to enter the starting date manually. To define Date(), use a numeric value in the

    Yymmdd format. Date returns 080102 if the day is January 2, 2008. See Figure 12.

    To import the strategy into Tradecision, visit the area Traders Tips from TASC magazine at http://tradecision.com/support

    /tasc_tips/tasc_traders_tips.htm or copy the code from the STOCKS & COMMODITIES website at www.Traders.com.

    Yana Timofeeva

    Alyuda Research, Inc.

    510 931-7808, [email protected]

    www.tradecision.com

    BACK TO LIST

    NINJATRADER: AVERAGE TRUE RANGE TRAILING STOPS

    The ATR trailing stop technique discussed by Sylvain Vervoort in his article in this issue, Average True Range Trailing Stops,

    has been implemented as an indicator available for download at www.ninjatrader.com/SC/June2009SC.zip.

    Once it is downloaded, from within the NinjaTrader Control Center window, select the menu File > Utilities > Import

    NinjaScript and select the downloaded file. This indicator is for NinjaTrader version 6.5 or greater.

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    22 of 29 9/27/2009 8:11 AM

  • NinjaScript and select the downloaded file. This indicator is for NinjaTrader version 6.5 or greater.

    You can review the indicators source code by selecting the menu Tools > Edit NinjaScript > Indicator from within the

    NinjaTrader Control Center window and selecting ATRTrailingStop. A sample chart is shown in Figure 13.

    NinjaScript indicators are compiled DLLs that run native, not interpreted, which provides you with the highest possible

    performance.

    FIGURE 13: NINJATRADER, ATR TRAILING STOP. Hereis an example of the ATR trailing stop indicator on adaily chart of AMD.

    Raymond Deux & Josh Peng

    NinjaTrader, LLC

    www.ninjatrader.com

    BACK TO LIST

    WAVE59: AVERAGE TRUE RANGE TRAILING STOPS

    In Average True Range Trailing Stops in this issue, Sylvain Vervoort implements an ATR stop algorithm that he uses as both a

    reversal system and as a way to apply a trailing stop to open positions entered using other methods.

    We were interested to see how Vervoorts trailing stop method handled recent action in the volatile stock indexes, so we applied

    it to the Dow Jones Industrial Average. You can see in Figure 14 that it stayed short for the latter half of 2008 and reversed to a

    long position in March 2009. According to this tool, the market looks ready to regain some of the losses posted last year. Just be

    wary if we cross back underneath the red line!

    FIGURE 14: WAVE59, ATR TRAILING STOP. Here isVervoorts trailing stop method applied to the DowJones Industrial Average. It stayed short for the latterhalf of 2008 and reversed to a long position in March2009.

    We are offering four scripts that implement Vervoorts approach in Wave59. As always, users of Wave59 can download these

    scripts directly using the QScript Library, found at http://www.wave59.com/library.

    Indicator 1: ATR reversal system

    #This script plots Sylvain Vervoort's ATR Stop Value#as described in the June 2009 issue of Stocks&Commodities#Period: period to get ATR value, using wilder's average function#Multiplier: factor to multiply the ATR value by to calculate stop amount#Act_as_System: if true, use as trading system, otherwise just linesinput:period(5),multiplier(3.5),act_as_system(false),color(red),thickness(1);

    #initialize variablesif (barnum==barsback) { stopval=close; buysell=1;}

    #calculate atr valuesatr=wilder_average(truerange(),period);bigatr=atr*multiplier;

    #calculate long stopsif (buysell>0) {

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    23 of 29 9/27/2009 8:11 AM

  • if (buysell>0) { stopval=close-bigatr; stopval=max(stopval,stopval[1]); if (close0) { stopval=close-bigatr; stopval=max(stopval,stopval[1]); if (close
  • text_setstring(txref,to_string(stopval));} Indicator 3: This script uses Vervoort's Modified ATR calculation

    #This script plots Sylvain Vervoort's Modified ATR Stop Value#as described in the June 2009 issue of Stocks&Commodities#Period: period to get modified ATR value#Multiplier: factor to multiply the ATR value by to calculate stop amount#Act_as_System: if true, use as trading system, otherwise just linesinput:period(5),multiplier(3.5),act_as_system(false),color(red),thickness(1);

    #initialize variablesif (barnum==barsback) { stopval=close; buysell=1;}

    #calculate Vervoort's modified atr valuessimplehilo=average(high-low,period);if (high-lowhigh[1]) href-=(low-close[1])/2;lref=abs(low-close[1]);if (high0) { stopval=close-bigatr; stopval=max(stopval,stopval[1]); if (close

  • href=abs(high-close[1]);if (low>high[1]) href-=(low-close[1])/2;lref=abs(low-close[1]);if (high0) { stopval=close-bigatr; stopval=max(stopval,stopval[1]); if (closeTools>Indicator Builder>[New] button1.

    In the Indicator Bookmark, type the following text for each field:

    Name: TASC - 06/2009 - Trailing Stoploss Reversal Level (ATR)Short Name: tasc_TSRLATRLabel Mask: TASC - 06/2009 - Trailing Stoploss Reversal Level (ATR) (%price%,%atrperiods%,%atrmult%) | %TSL%Placement: Price FrameInspect Alias: tasc_TSRLATR

    2.

    In the Input Bookmark, create the following variables:[New] button... Name: price , Display Name: Price , Type: price , Default: close[New] button... Name: atrperiods , Display Name: ATR Periods , Type: integer , Default: 14[New] button... Name: atrmult , Display Name: ATR Multiplier , Type: float , Default: 3.0000

    3.

    In the Output Bookmark, create the following variables:

    [New] button...Var Name: TSLName: (TSL)Line Color: redLine Width: thinLine Type: dashed

    4.

    In the Formula Bookmark, copy and paste the following formula:

    {Provided By: Capital Market Services, LLC & Visual Trading Systems, LLC}

    5.

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    26 of 29 9/27/2009 8:11 AM

  • Systems, LLC}{Copyright: 2009}{Description: TASC, June 2009 - "Average True Range Trailing Stops" by Sylvian Vervoort}{File: tasc_TSRLATR.vtsrc - Version 1.0}

    Loss:= ATR(atrperiods)*atrmult;

    TSL:= if(BarCount()>=atrperiods, if(ref(price,-1)>PREV(0) AND price>PREV(0),max(PREV(0),price-Loss), if(ref(price,-1)

  • FIGURE 16: TRADE-IDEAS, ALERTS CONFIGURATION.The combination of alerts and filters used to createSylvain Vervoorts modified ATR volatility stopstrategy are shown here.

    Type or copy/paste this shortened string directly into a browser then copy/paste the full length link into Trade-Ideas PRO using

    the Collaborate feature (right-click in any strategy window):

    http://bit.ly/1WrpZ (case sensitive)

    This strategy also appears on the Trade-Ideas blog, http://marketmovers.blogspot.com/, or you can build the strategy from

    Figure 16, which shows the configuration of this strategy, where one alert and nine filters are used with the following settings:

    Running Up Now (in 1 minute or less), $0.75

    Min Price Filter = 5 ($)

    Max Price Filter = 50 ($)

    The definitions of these indicators appear here: http://www.trade-ideas.com/Help.html.

    Thats the strategy, but what about the trading rules? How should the opportunities that the strategy finds be traded? For the

    stop-loss, we used one of the more advanced options available in the OddsMaker. Instead of using a traditional stop-loss, we

    selected Another alert as the exit condition called Trailing stop, volatility down. This alert is triggered when a stock moves

    down an amount equal to the average 15-minute volatility multiplied by the number of 15-minute bars we decide on in this

    case, 2. For example, if the average 15-minute volatility is 10 cents, this alert would not trigger until a stock moves down at least

    20 cents.

    Here is what The OddsMaker tested for the past three weeks ended 4/9/2009 given the following trade rules:

    On each alert, sell short the symbol (price moves down to be a successful trade)

    Schedule an exit for the stocks 30 minutes after entry

    Start trading from the open and stop trading 30 minutes later

    Set a stop using the alert, trailing stop, volatility down, with a setting of two bars

    The OddsMaker summary provides evidence of how well this strategy and our trading rules did. The settings are shown in

    Figure 17.

    FIGURE 17: TRADE-IDEAS, ODDSMAKER. Here is thebacktesting configuration for the modified ATRvolatility stop strategy.

    The results (last backtested for the three-week period ended 4/9/2009) are shown in Figure 18. The summary reads as follows:

    This strategy generated 498 trades of which 339 were profitable for a win rate of 68.07%. The average winning trade generated

    $0.38 in profit and the average loser lost $0.18. The net winnings of using this strategy for 15 trading days generated $105.06

    points. If you normally trade in 100-share lots, this strategy would have generated $10,506. The z-score or confidence factor that

    the next set of results will fall within this strategys average winner and loser is 100%.

    FIGURE 18: TRADE-IDEAS, RESULTS. Here are sampleresults from The Oddsmaker for the modified ATRvolatility stop strategy.

    You can find an explanation of The OddsMaker backtest results in more detail from the online user manual at

    http://www.trade-ideas.com/OddsMaker/Help.html.

    TRADERS TIPS - June 2009 http://www.traders.com/Documentation/FEEDbk_Docs/2...

    28 of 29 9/27/2009 8:11 AM

  • http://www.trade-ideas.com/OddsMaker/Help.html.

    Dan Mirkin & David Aferiat

    Trade Ideas, LLC

    [email protected], www.trade-ideas.com

    BACK TO LIST

    METASTOCK: AVERAGE TRUE RANGE TRAILING STOPS (VERVOORT ARTICLE CODE)

    The code for MetaStock to implement the average true-range trailing stop method, as described by author Sylvain Vervoort In

    Average True Range Trailing Stops, in this issue, is provided below.

    MODIFIED ATR WITH TRAILING STOPS

    {SVE_Stop_Trail_ATR_Mod}period:=Input(ATR period :,1,100,5);atrfact:=Input(ATR multiplication :,1,10,3.5);HiLo:=If(H-LPREV AND Ref(C,-1)>PREV,Max(PREV,C-loss),If(C