TRADERS’ TIPS

December 2015

Tips Article Thumbnail

For this month’s Traders’ Tips, the focus is Markos Katsanos’s article in this issue, “Trading The Loonie.” Here, we present the December 2015 Traders’ Tips code with possible implementations in various software.

Code for MetaStock is already provided by Katsanos in the article, which S&C subscribers will find in the Subscriber Area of our website here.

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

eSIGNAL: DECEMBER 2015

For this month’s Traders’ Tip, we’ve provided the studies BBDivergenceIndicator.efs and the BBDivergenceStrategy.efs based on the formulas described in Markos Katsanos’s article in this issue, “Trading The Loonie.”

In the article, the author presents a trading system that’s based on the positive correlation between the currencies of major oil exporters and the price of oil. Katsanos focuses on the relationship of the Canadian dollar and the price of oil, and uses an indicator and strategy based on the divergence between them as indicated by a Bollinger Band study.

The eSignal studies contain formula parameters that may be configured through the edit chart window (right-click on the chart and select “edit chart”). A sample chart implementing the studies is shown in Figure 1.

Sample Chart

FIGURE 1: eSIGNAL. Here is an example of the indicator and strategy plotted on a daily chart of CAD A0-FX.

To discuss these studies 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 scripts (EFS) are also shown below.

BBDivergenceIndicator.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright В© 2015) 
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with 
    each new release. 

Description:        
    Trading The Loonie by Markos Katsanos

Formula Parameters:                     Default:
Length BB Divergence                    20
Secondary Symbol                        CL #F 

Version:            1.00  10/08/2015

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(){

    setStudyTitle("BBDivergenceStrategy");
    setIntervalsBackfill(true);
    
    var x = 0;

    fpArray[x] = new FunctionParameter("fpLength", FunctionParameter.NUMBER);
    with(fpArray[x++]){
        setName("Length BB Divergence");
        setLowerLimit(1); 
        setDefault(20);
    }

    fpArray[x] = new FunctionParameter("fpSecondarySymbol", FunctionParameter.STRING);
    with(fpArray[x++]){
        setName("Secondary Symbol");    
        setDefault('CL #F');
    }
}
 
var bInit = false;
var bVersion = null;

var xClose = null;
var xSecClose = null;

var xBol = null;
var xSecBol = null;

var xDiverg = null;

function main(fpLength, fpSecondarySymbol){

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

    if (!bInit){
        
        xClose = close();
        xSecClose = close(sym(fpSecondarySymbol));
        
        xBol = efsInternal('Calc_Bol', fpLength, xClose);
        xSecBol = efsInternal('Calc_Bol', fpLength, xSecClose);
        
        xDiverg = efsInternal('Calc_Div', xBol, xSecBol);
        
        bInit = true; 
    }

    var nDiverg = xDiverg.getValue(0);

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

var xBolSMA = null;
var xSTDDev = null;
var bInitInt = false;

function Calc_Bol(nLength, xSource){
    
    if (!bInitInt){
        xBolSMA = sma(nLength, xSource);
        xSTDDev = stdDev(nLength, xSource);
        
        bInitInt = true;
    }
    
    var nSource = xSource.getValue(0);
    var nBolSMA = xBolSMA.getValue(0);
    var nSTDDev = xSTDDev.getValue(0);
    
    if (nSource == null || nBolSMA == null || nSTDDev == null)
        return;
    
    var nBol = 1 + ((nSource - nBolSMA + 2 * nSTDDev) / (4 * nSTDDev + .0001));
    
    return nBol;
}

function Calc_Div(xBol1, xBol2){
      
    var nBol1 = xBol1.getValue(0);
    var nBol2 = xBol2.getValue(0);

    if (nBol1 == null || nBol2 == null)
        return;
    
    nDiverg = (nBol2 - nBol1) / nBol1 * 100 ;
    
    return nDiverg;
}

function verify(){
    var b = false;
    if (getBuildNumber() < 3742){
        
        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;
}

BBDivergenceStrategy.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright В© 2015) 
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with 
    each new release. 

Description:        
    Trading The Loonie by Markos Katsanos

Formula Parameters:                     Default:
Length BB Divergence                    20
Secondary Symbol                        CL #F 
Long Trend Color                        green
Short Trend Color                       red

Version:            1.00  10/08/2015

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(){

    setStudyTitle("BBDivergenceStrategy");
    setPriceStudy(true);
    setIntervalsBackfill(true);
    
    var x = 0;

    fpArray[x] = new FunctionParameter("fpLength", FunctionParameter.NUMBER);
    with(fpArray[x++]){
        setName("Length BB Divergence");
        setLowerLimit(1); 
        setDefault(20);
    }

    fpArray[x] = new FunctionParameter("fpSecondarySymbol", FunctionParameter.STRING);
    with(fpArray[x++]){
        setName("Secondary Symbol");    
        setDefault('CL #F');
    }

    fpArray[x] = new FunctionParameter("fpLongColor", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Long Color");    
        setDefault(Color.green);
    }
    
    fpArray[x] = new FunctionParameter("fpShortColor", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Short Color");    
        setDefault(Color.red);
    }
}
 
var bInit = false;
var bVersion = null;

var xClose = null;
var xSecClose = null;

var xLow = null;
var xHigh = null;
var xOpen = null;

var xBol = null;
var xSecBol = null;

var xDiverg = null;

var xHHV = null;
var xHighHHV = null;
var xLLV = null;
var xLowLLV = null;
var xSecLLV = null;

var xROC = null;
var xSecROC = null;

var xCorrelEntry = null;
var xCorrelExit = null;

var xSecSMA = null;

var xMACD = null;
var xSignal = null;
var xStoch = null;

var nTagID = 0;

var nDefLotSize = null;

function main(fpLength, fpSecondarySymbol, fpLongColor, fpShortColor){

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

    if (!bInit){
        
        xClose = close();
        xSecClose = close(sym(fpSecondarySymbol));
              
        xLow = low();
        xHigh = high();
        xOpen = open();
        
        xBol = efsInternal('Calc_Bol', fpLength, xClose);
        xSecBol = efsInternal('Calc_Bol', fpLength, xSecClose);
        
        xDiverg = efsInternal('Calc_Div', xBol, xSecBol);
        
        xHHV = hhv(3, xDiverg);
        xHighHHV = hhv(15, xHigh);
        xLLV = llv(3, xDiverg);
        xLowLLV = llv(15, xLow);
        xSecLLV = llv(4, xSecClose);
        
        xROC = roc(2);
        xSecROC = roc(3, xSecClose);
        
        xCorrelEntry = efsInternal("Calc_Correlation", 20, xClose, xSecClose);
        xCorrelExit = efsInternal("Calc_Correlation", 60, xClose, xSecClose);
        
        xSecSMA = sma(40, xSecClose);
        
        xMACD = macd(12, 26, 9);
        xSignal = macdSignal(12, 26, 9);
        xStoch = stochD(30, 1, 3);
        
        bInit = true; 
    }

    if (isLastBarOnChart()) return; 

    var nDiverg = xDiverg.getValue(0);
    var nPrevDiverg = xDiverg.getValue(-1);
        
    var nClose = xClose.getValue(0);
    var nSecClose = xSecClose.getValue(0);
    
    var nHHV = xHHV.getValue(0);
    var nHighHHV = xHighHHV.getValue(-1);
    var nLLV = xLLV.getValue(0);
    var nLowLLV = xLowLLV.getValue(-1);
    var nSecLLV = xSecLLV.getValue(0);
    
    var nROC = xROC.getValue(0);
    var nSecROC = xSecROC.getValue(0);
    
    var nSecSMA = xSecSMA.getValue(0);
    var nPrev2SecSMA = xSecSMA.getValue(-2);
    
    var nCorrelEntry = xCorrelEntry.getValue(0);
    var nCorrelExit = xCorrelExit.getValue(0);
    
    var nStoch = xStoch.getValue(0);
       
    if (nDiverg == null || nPrevDiverg == null || nHHV == null || nHighHHV == null ||
        nLLV == null || nLowLLV == null || nSecLLV == null || nROC == null ||  nSecROC == null ||
        nSecSMA == null || nPrev2SecSMA == null || nCorrelEntry == null || nCorrelExit == null || 
        nStoch == null)
        return;
    
    nDefLotSize = Strategy.getDefaultLotSize();
    
    var nPrice = xOpen.getValue(1);
    
    if (!Strategy.isLong()){
        if ((nHHV > 20) && (nDiverg < nPrevDiverg) && (nROC > 0) && (nSecSMA > nPrev2SecSMA) && (nCorrelEntry > -.4)){
            
            Strategy.doLong("Entry Long", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT);
            drawShapeRelative(1, BelowBar1, Shape.UPTRIANGLE, null, fpLongColor, Text.PRESET, nTagID++);
            drawTextRelative(1, BelowBar2, "Entry Long", fpLongColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
            drawTextRelative(1, BelowBar3, nDefLotSize + " @ " + formatPriceNumber(nPrice), fpLongColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
        }
    }

    if (Strategy.isLong()){
        if ((crossAbove(xSignal, xMACD) && (nStoch > 85)) ||  
            (nLLV < -20 && nSecROC < -3) ||
            (nClose < nLowLLV && nCorrelExit < -.4)){
                
            Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT);
            drawShapeRelative(1, AboveBar1, Shape.SQUARE, null, fpShortColor, Text.PRESET, nTagID++);
            drawTextRelative(1, AboveBar2, "Exit Long", fpShortColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
            drawTextRelative(1, AboveBar3, nDefLotSize + " @ " + formatPriceNumber(nPrice), fpShortColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
        }
    }
     
    if (!Strategy.isShort()){
        if ((nLLV < -20) && (nDiverg > nPrevDiverg) && (nROC < 0) && (nSecSMA < nPrev2SecSMA) && (nCorrelEntry > -.4)){
    
           Strategy.doShort("Entry Short", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT);
           drawShapeRelative(1, AboveBar1, Shape.DOWNTRIANGLE, null, fpShortColor, Text.PRESET, nTagID++);
           drawTextRelative(1, AboveBar2, "Entry Short", fpShortColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
           drawTextRelative(1, AboveBar3, nDefLotSize + " @ " + formatPriceNumber(nPrice), fpShortColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++); 
        }
    }
  
    if (Strategy.isShort()){
        if ((crossAbove(xMACD, xSignal) && (nStoch < 25) && nSecClose >= (1 + 4 / 100) * nSecLLV ) ||
            (nHHV > 20 && nSecROC > 4.5) ||
            (nClose > nHighHHV && nCorrelExit < -.4)){
                
            Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT);
            drawShapeRelative(1, BelowBar1, Shape.SQUARE, null, fpLongColor, Text.PRESET, nTagID++);
            drawTextRelative(1, BelowBar2, "Exit Short", fpLongColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
            drawTextRelative(1, BelowBar3, nDefLotSize + " @ " + formatPriceNumber(nPrice), fpLongColor, null, Text.PRESET|Text.CENTER|Text.BOLD, null, null, nTagID++);
        }
    }
}

function crossAbove(xSource1, xSource2){
        
    var bReturnValue = false;
    
    var nSource1 = xSource1.getValue(0);
    var nSource2 = xSource2.getValue(0);
    
    if (nSource1 > nSource2) {
       
        var i = -1;
    
        while (!bReturnValue){
        
            var nPrevSource1 = xSource1.getValue(i);
            var nPrevSource2 = xSource2.getValue(i);
        
            if (nPrevSource1 == null || nPrevSource2 == null)
                break;
                
            if (nPrevSource1 != nPrevSource2){
                if (nPrevSource2 > nPrevSource1)
                     bReturnValue = true; 
                break;
            }
            i--;
        }
    }

    return bReturnValue;
} 

var xBolSMA = null;
var xSTDDev = null;
var bInitInt = false;

function Calc_Bol(nLength, xSource){
    
    if (!bInitInt){
        xBolSMA = sma(nLength, xSource);
        xSTDDev = stdDev(nLength, xSource);
        
        bInitInt = true;
    }
    
    var nSource = xSource.getValue(0);
    var nBolSMA = xBolSMA.getValue(0);
    var nSTDDev = xSTDDev.getValue(0);
    
    if (nSource == null || nBolSMA == null || nSTDDev == null)
        return;
    
    var nBol = 1 + ((nSource - nBolSMA + 2 * nSTDDev) / (4 * nSTDDev + .0001));
    
    return nBol;
}

function Calc_Div(xBol1, xBol2){
      
    var nBol1 = xBol1.getValue(0);
    var nBol2 = xBol2.getValue(0);

    if (nBol1 == null || nBol2 == null)
        return;
    
    nDiverg = (nBol2 - nBol1) / nBol1 * 100 ;
    
    return nDiverg;
}

var xCorSMA1 = null;
var xCorSMA2 = null;

function Calc_Correlation(nLength, xSource1, xSource2){

    if (getBarState() == BARSTATE_ALLBARS){
        xCorSMA1 = sma(nLength, xSource1);
        xCorSMA2 = sma(nLength, xSource2);
    }

    var nSX = xCorSMA1.getValue(0);
    var nSY = xCorSMA2.getValue(0);

    if (nSX == null || nSY == null)
        return;
    
    var nCor1 = null;
    var nCor2 = null;
    var nCor3 = null;

    for (var i = 0; i < nLength; i++){
        var nX = xSource1.getValue(-i);
        var nY = xSource2.getValue(-i);
        nCor1 += (nX - nSX) * (nY - nSY);
        nCor2 += (nX - nSX) * (nX - nSX);
        nCor3 += (nY - nSY) * (nY - nSY);
    }

    var nCorrelationRes = nCor1 / Math.sqrt(nCor2) / Math.sqrt(nCor3);

    return nCorrelationRes;
}

function verify(){
    var b = false;
    if (getBuildNumber() < 3742){
        
        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: DECEMBER 2015

In “Trading The Loonie” in this issue, author Markos Katsanos explains the heavy correlation between the Canadian dollar and crude oil. He then goes on to describe how one could trade this correlation. Using similar logic as that employed in Bollinger Bands, Katsanos has built a study to provide buy and sell signals for trading the Canadian dollar future.

We have replicated his BBDivergence study and strategy using our proprietary scripting language, thinkscript. We have made the loading process extremely easy: simply click on the links https://tos.mx/v0vYZd and https://tos.mx/rdRUvt and choose “Save script to thinkorswim,” then “Backtest in thinkScript.” Choose to rename your study and strategy as “BBDivergence.” You can adjust the parameters of this study within the edit studies window to fine-tune your variables.

In the example shown in Figure 2, you see a chart of /6C, which is the Canadian dollar future. Just below the volume and open interest indicator is Katsanos’s BBDivergence indicator, which is used to define the conditions that trigger the trade plotted. Finally, in the bottom indicator, you can see that over this four-year charted time frame, the BBDivergence strategy has produced a positive return.

Sample Chart

FIGURE 2: THINKORSWIM. This example chart shows the Canadian dollar future.

For more on this indicator, please see Katsanos’s article.

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

BACK TO LIST

logo

WEALTH-LAB: DECEMBER 2015

This Traders’ Tip is based on “Trading The Loonie” in this issue by Markos Katsanos.

The CAD/USD, also known as the “loonie,” is a petrocurrency like NOK/USD, USD/RUB and others. The price of oil undoubtedly plays the major role in its exchange rate for the most part. However, the correlation with oil is not always a positive 1.0, since other drivers like the key rate or carry trading periodically come into play.

The system is most likely to exhibit periods of prosperous behavior while crude oil is volatile and trending, and is expected to take a break during prolonged range-bound movements like in 2011–2013.

In addition to the author’s use of the light crude oil (CLC) contract, it may also make sense to experiment with the WTI contract to measure correlation. Some believe that this blend follows Canada’s Western Canadian Select more accurately. We leave testing this idea to motivated traders.

A participating indicator, correlation, is part of our Community Indicators library, which is driven by the Wealth-Lab user community. To run the Wealth-Lab 6 strategy code shown here, install the indicator library (or update to the actual version using the Extension Manager) from our website, wealth-lab.com, in the Extensions section.

After updating the library to v2015.07 or later, the correlation indicator can be found under the Community Indicators group. Applying it to charts or rule-based strategies is as easy as drag & drop without having to program any code yourself.

A sample chart is shown in Figure 3.

Sample Chart

FIGURE 3: WEALTH-LAB. Signals generated by the intermarket Bollinger Bands (BB) divergence method are superimposed on the chart as colored triangles. The 20-day BB divergence is plotted on the top and crude oil (light sweet) futures in the middle window.

Wealth-Lab 6 strategy code (C#):

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

namespace WealthLab.Strategies
{
	public class LoonieStrategy : WealthScript
	{
		private StrategyParameter paramPeriod;
		
		public LoonieStrategy()
		{
			paramPeriod = CreateParameter("days", 20, 2, 300, 1);
		}
		
		protected override void Execute()
		{
			int days = paramPeriod.ValueInt;
			StdDevCalculation s = StdDevCalculation.Sample;
			var oil = GetExternalSymbol("Light",true).Close;
			var bbCAD = 1 + ((Close - SMA.Series(Close,days) + 2*StdDev.Series(Close,days,s)) / (4*StdDev.Series(Close,days,s)+0.0001));
			var bbOil = 1 + ((oil - SMA.Series(oil,days) + 2*StdDev.Series(oil,days,s)) / (4*StdDev.Series(oil,days,s)+0.0001));
			var divergence =(bbOil-bbCAD)/bbCAD*100; divergence.Description = "Divergence";
			
			var hhvDiv = Highest.Series(divergence,3);
			var llvDiv = Lowest.Series(divergence,3);
			var llv = Lowest.Series(Low,15);
			var hhv = Highest.Series(High,15);
			var roc = ROC.Series(Close,2);
			var mov = SMA.Series(oil,40);
			var correlation20 = Correlation.Series(Close,oil,20);
			var correlation60 = Correlation.Series(Close,oil,60);
			var rocOil = ROC.Series(oil,3);
			var llvOil = Lowest.Series(oil,4);			
			var macd = MACD.Series(Close);
			var macdSignal = EMAModern.Series(macd,9);
			var sto = StochD.Series(Bars,30,3);
			
			ChartPane oilPane = CreatePane(50,true,true); HideVolume();
			PlotSymbol(oilPane,GetExternalSymbol("Light",true),Color.Green,Color.Red);
			ChartPane divPane = CreatePane(50,true,true);
			LineStyle ld = LineStyle.Dashed;
			PlotSeries(divPane,divergence,Color.Black,LineStyle.Solid,1);
			DrawHorzLine(divPane,20,Color.Black,ld,1);
			DrawHorzLine(divPane,-20,Color.Black,ld,1);
			
			for(int bar = GetTradingLoopStartBar(60); bar < Bars.Count; bar++)
			{
				if (IsLastPositionActive)
				{
					bool sell =
						(CrossUnder(bar, macd, macdSignal) && sto[bar]>85) ||
						(llvDiv[bar] < -20 && rocOil[bar] < -3) ||
						(Close[bar] < llv[bar-1] && correlation60[bar] < -0.4);					
					
					bool cover =
						(CrossOver(bar, macd, macdSignal) && sto[bar]<25 &&
						(oil[bar] >= (1 + 4.0/100d) * llvOil[bar]) ) ||
						(hhvDiv[bar]>20 && rocOil[bar]>4.5 ) ||
						(Close[bar] > hhv[bar-1] && correlation60[bar] < -0.4);
					
					Position p = LastPosition;
					if( p.PositionType == PositionType.Long )
					{
						if( sell )
							SellAtMarket(bar+1, p);
					}
					else
					{
						if( cover )
							CoverAtMarket(bar+1, p);
					}
				}
				else
				{
					bool buy = (hhvDiv[bar] > 20) && (divergence[bar] < divergence[bar-1]) &&
						(roc[bar]>0) && (mov[bar] > mov[bar-2]) && (correlation20[bar] > -0.4);
					
					bool shrt = (llvDiv[bar] < -20) && (divergence[bar] > divergence[bar-1]) &&
						(roc[bar]<0) && (mov[bar] < mov[bar-2]) && (correlation20[bar] > -0.4);
					
					if( buy )
						BuyAtMarket(bar+1);
					else
						if( shrt )
							ShortAtMarket(bar+1);	
				}
			}
		}
	}
}

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

BACK TO LIST

logo

AMIBROKER: DECEMBER 2015

In “Trading The Loonie” in this issue, author Markos Katsanos presents a trading system for CAD futures based on its relationship with price action on crude oil futures.

A ready-to-use formula for use in AmiBroker is shown here. To use the Bollinger Band divergence oscillator, enter the code in the formula editor and press the apply indicator button. You can adjust the averaging period using the parameters window. To backtest the system, click the send to analysis button in the formula editor and then the backtest button in the analysis window. You may need to change the symbol of crude oil futures to match your data provided symbology (the code shown here uses IQFeed symbology).

A sample chart is shown in Figure 4.

Sample Chart

FIGURE 4: AMIBROKER. Here is a daily chart of CAD futures (upper pane) with buy (green), sell (red), short (hollow red), and cover (hollow green) arrows generated by the system. The Bollinger Band divergence oscillator is shown in the bottom pane.

AmiBroker code:
  
// using IQFeed symbology here 
// you may need to adjust symbol for different data source 
SEC2 = Foreign( "QCL#", "C" ); // crude oil futures continuous 
D1 = Param( "BB DAYS " , 20, 1, 200, 1 ); 

sec1BOL = 1 + ( ( C - MA( C, D1 ) + 2 * StDev( C, D1 ) ) / 
                 ( 4 * StDev( C, D1 ) + 0.0001 ) ); 
sec2BOL = 1 + ( ( SEC2 - MA( SEC2, D1 ) + 2 * StDev( SEC2, D1 ) ) / 
                 ( 4 * StDev( SEC2, D1 ) + 0.0001 ) ); 
DIV1 = ( sec2BOL - sec1BOL ) / sec1bol * 100; 

Plot( Div1, "Bollinger Band Divergence", colorRed ); 

Buy =  HHV( DIV1, 3 ) > 20 AND 
       DIV1 < Ref( DIV1, -1 ) AND 
       ROC( C, 2 ) > 0 AND MA( SEC2, 40 ) > Ref( MA( SEC2, 40 ), -2 ) 
       and 
       Correlation( C, SEC2, 20 ) > -0.4; 

Filter = 1; 
AddColumn( Buy, "Buy" ); 

Sell = ( Cross( Signal(), MACD() ) 
         AND StochK( 30, 3 ) > 85 ) OR 
       ( LLV( DIV1, 3 ) < -20 AND ROC( SEC2, 3 ) < -3 ) OR 
       ( C < Ref( LLV( L, 15 ), -1 ) AND 
         Correlation( C, SEC2, 60 ) < -0.4 ); 


Short =  LLV( DIV1, 3 ) < -20 AND 
         DIV1 > Ref( DIV1, -1 ) AND 
         ROC( C, 2 ) < 0 AND 
         MA( SEC2, 40 ) < Ref( MA( SEC2, 40 ), -2 ) AND 
         Correlation( C, SEC2, 20 ) > -0.4; 


Cover =  ( Cross( MACD(), Signal() ) AND StochK( 30, 3 ) < 25 AND 
           SEC2 >= ( 1 + 4 / 100 ) * LLV( SEC2, 4 ) ) OR 
         ( HHV( DIV1, 3 ) > 20 AND ROC( SEC2, 3 ) > 4.5 ) OR 
         ( C > Ref( HHV( High, 15 ), -1 ) AND 
	     Correlation( C, SEC2, 60 ) < -0.4 ); 
  

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

BACK TO LIST

logo

NEUROSHELL TRADER: DECEMBER 2015

The Bollinger Band divergence indicator described by Markos Katsanos in his article in this issue, “Trading The Loonie,” 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 set up the following indicator:

BBDIV
Multiply2( 100, Divide( Sub( BB%B(Crude Oil Close,20,2), BB%B(Close,20,2)), Add2(100, BB%B( Close,20,2))))

To implement the Canadian loonie and crude oil divergence trading system, simply select new trading strategy from the insert menu and enter the following formulas in the appropriate locations of the trading strategy wizard:

BUY LONG CONDITIONS: [All of which must be true]

A>B( Max(BBDIV(Close,Crude Oil Close,20,2),3),20)
A<B( Momentum(BBDIV(Close,Crude Oil Close,20,2),1),0)
A>B( %Change(Close,2),0)
A>B( Momentum(Avg(Crude Oil Close,40),2),0)
A>B( LinXYReg r(Close,Crude Oil Close,20),-0.4)

SELL LONG CONDITIONS: [1 of which must be true]

And2( CrossAbove(MACD Signal(Close,9,12,26), MACD(Close,12,26)), A>B( Stoch%D( High, Low, Close, 30, 3), 85))
And2( A<B(Min(BBDIV(Close,Crude Oil Close,20,2),3),-20), A<B( %Change(Close,3),-3))
And2( A<B(Close,Lag(PriceLow(Low,15),1)),A<B(LinXYReg r(Close,Crude Oil Close,20), -0.4))

SELL SHORT CONDITIONS: [All of which must be true]

A<B( Min(BBDIV(Close,Crude Oil Close,20,2),3),-20)
A>B( Momentum(BBDIV(Close,Crude Oil Close,20,2),1),0)
A<B( %Change(Close,2),0)
A<B( Momentum(Avg(Crude Oil Close,40),2),0)
A>B( LinXYReg r(Close,Crude Oil Close,20),-0.4)

COVER SHORT CONDITIONS: [1 of which must be true]

And3( CrossBelow(MACD Signal(Close,9,12,26), MACD(Close,12,26)), A<B( Stoch%D( High, Low, Close, 30, 3), 25), A>=B(Crude Oil Close, Add2(1, Mul2(0.04, Min(Crude Oil Close,4)))))
And2( A>B(Max(BBDIV(Close,Crude Oil Close,20,2),3),20), A>B( %Change(Close,3),4.5))
And2( A>B(Close,Lag(PriceHigh(High,15),1)),A<B(LinXYReg r(Close,Crude Oil Close,20),-0.4))

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 is shown in Figure 5.

Sample Chart

FIGURE 5: NEUROSHELL TRADER. This NeuroShell Trader chart shows the Canadian loonie and crude oil Bollinger Band divergence system.

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

BACK TO LIST

logo

AIQ: DECEMBER 2015

Here is some code for use in AIQ based on Markos Katsanos’s article in this issue, “Trading The Loonie.” The code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm.

The code I am providing contains both the divergence indicator and a long-only trading system for the NASDAQ 100 list of stocks. Rather than trading forex, I wanted to try the divergence idea and the author’s entry rules on the NASDAQ 100 stocks. The stocks are traded long using the author’s entry rules with two of the parameters adjusted as shown at the top of the code file. The exit has been changed completely to use a profit protect (protect 50% of profits once a 20% profit is reached), a stop-loss (protect 75% of capital), and a time-stop exit (exit after 21 days). I used the NASDAQ 100 index (NDX) in place of the crude oil futures. The assumption is that since the stocks on the list are all in the NDX, they would generally be correlated to the index. The author’s entry rule filters out those with a negative correlation to the index. Note that I changed the minimum correlation from a -0.4 to 0.0. In addition, I found that increasing the minimum divergence from 20 to 2,000 increased the Sharpe ratio and decreased the maximum drawdown without affecting the annualized return.

Figure 6 shows the equity curve versus the NASDAQ 100 index for the period 1/5/2000 to 10/14/2015. Figure 7 shows the metrics for this same test period. The system clearly outperformed the index.

Sample Chart

FIGURE 6: AIQ. Here is a sample equity curve for the modified divergence system versus the NASDAQ 100 index for the period 1/5/2000 to 10/14/2015.

Sample Chart

FIGURE 7: AIQ. Here are the metrics for the modified system and the test settings.

!TRADING THE LOONIE
!Author: Markos Katsanos, TASC December 2015
!coded by: Richard Denning 10/17/15
!www.TradersEdgeSystems.com

!Set parameters:
 Define Len        20. !Default is 20
 Define F1          2. !Default is 2
 Define F2          4. !Default is 4
 IDX is         "NDX". !NASDAQ 100 index 
 IDXsLen is        40. !Default is 40
 minDIVERG is    2000. !Default is 20
 minROC is          0. !Default is 0
 minCorrel is     0.0. !Default is -0.4

!Close percent relative to BB band width for stock:
Variance is Variance([close],Len).
StdDev is Sqrt(Variance).
SMA is simpleavg([close],Len).
stkBB is 1+([close]-SMA+F1*StdDev)/(F2*StdDev).

!Close percent relative to BB band width for index:
IDXc is tickerUDF(IDX,[close]).
VarianceIdx is Variance(IDXc,Len).
StdDevIDX is Sqrt(Variance).
SMAidx is simpleavg(IDXc,Len).
idxBB is 1+(IDXc-SMAidx+F1*StdDevIDX)/(F2*StdDevIDX).

DIVERG is (idxBB-stkBB)/stkBB*100.     !PLOT AS CUSTOM INDICATOR
DIVERG1	is valresult(DIVERG,1).
ROC2 is ([close]/val([close],2)-1)*100.
ROC3 is ([close]/val([close],3)-1)*100.
ROC3idx is tickerUDF(IDX,ROC3).
IDXsma is simpleavg(IDXc,IDXsLen).
IDXsma2 is valresult(IDXsma,2).
HHVdiverg is highresult(DIVERG,3).

Setup1 if highresult(DIVERG,3) > minDIVERG.
Setup2 if DIVERG < valresult(DIVERG,1).
Setup3 if ([close]/val([close],2)-1)*100 > minROC.
Setup4 if IDXsma > valresult(IDXsma,2).
Setup5 if pCorrel > minCorrel.

Buy if 	Setup1 and
	Setup2 and 
	Setup3 and
	Setup4 and 
	Setup5.

BuyAlt if Buy.

LongExit1 if MACD<sigMACD and valrule(MACD>sigMACD,1) and
	     Stoch > 85.
LongExit2 if lowresult(DIVERG,3)<-20 and ROC3idx<-0.4.
LongExit3 if [close]<loval([close],15,1) and pCorrel<minCorrel.
LongExit if LongExit1 or LongExit2 or LongExit3.

AlterLongExit if {position days} >=21 or [close] <= (1-0.25)*{position entry price}.

!Code to Calculate Pearson's R [for entry]:
! PeriodtoTest is the number of lookback days.
! IndexTkr is the Instrument that you which to compare your list to.
PeriodToTest is Len.
IndexTkr is IDX.
ChgTkr is ([open] / val([open],PeriodToTest)-1)*100.
ChgIdx is TickerUDF(IndexTkr,ChgTkr).
Alpha is ChgTkr - ChgIdx.

ValUDF is (([close]-[open])/[open]) * 100.
ValIndex is TickerUDF(IndexTkr, ValUDF).
ValTkr is ValUDF.
SumXSquared is Sum(Power(ValIndex,2), PeriodToTest).
SumX is Sum(ValIndex, PeriodToTest).
SumYSquared is Sum(Power(ValTkr,2), PeriodToTest).
SumY is Sum(ValTkr, PeriodToTest).
SumXY is Sum(ValTkr*ValIndex, PeriodToTest).
SP is SumXY - ( (SumX * SumY) / PeriodToTest ).
SSx is SumXSquared - ( (SumX * SumX) / PeriodToTest ).
SSy is SumYSquared - ( (SumY * SumY) / PeriodToTest ).

!Pearson's R and Pearson's Coefficient of Determination:
pCorrel is SP/SQRT(SSX*SSY).

!Code to Calculate Pearson's R [for exit]:
! PeriodtoTest is the number of lookback days.
! IndexTkr is the Instrument that you which to compare your list to.
PeriodToTestX is 3*Len.
IndexTkrX is IDX.
ChgTkrX is ([open] / val([open],PeriodToTestX)-1)*100.
ChgIdxX is TickerUDF(IndexTkrX,ChgTkrX).
AlphaX is ChgTkrX - ChgIdxX.

ValUDFX is (([close]-[open])/[open]) * 100.
ValIndexX is TickerUDF(IndexTkrX, ValUDFX).
ValTkrX is ValUDFX.
SumXSquaredX is Sum(Power(ValIndexX,2), PeriodToTestX).
SumXX is Sum(ValIndexX, PeriodToTestX).
SumYSquaredX is Sum(Power(ValTkrX,2), PeriodToTestX).
SumYX is Sum(ValTkrX, PeriodToTestX).
SumXYX is Sum(ValTkrX*ValIndexX, PeriodToTestX).
SPX is SumXYX - ( (SumXX * SumYX) / PeriodToTestX).
SSxX is SumXSquaredX - ( (SumXX * SumXX) / PeriodToTestX ).
SSyX is SumYSquaredX - ( (SumYX * SumYX) / PeriodToTestX ).

!Pearson's R and Pearson's Coefficient of Determination:
pCorrelX is SPX/SQRT(SSXX*SSYX).

!MACD code:
S is 12.
L is 25.
X is 9.

ShortMACDMA is expavg([Close],S).
LongMACDMA is expavg([Close],L).

MACD is ShortMACDMA-LongMACDMA.
SigMACD is expavg(MACD,X).

!Stochastic
StochLen is 30.
Stoch is 100 * (([Close]-LoVal([Low],StochLen)) /
	(HiVal([High],StochLen) - LoVal([Low],StochLen))).

List if 1.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

BACK TO LIST

logo

TRADERSSTUDIO: DECEMBER 2015

The TradersStudio code based on Markos Katsanos’s article in this issue, “Trading the Loonie,” can be found at www.TradersEdgeSystems.com/traderstips.htm.

The following code files are provided in the download:

Figure 8 shows the DIVERG indicator on a chart of Apple Inc.

Sample Chart

FIGURE 8: TRADERSSTUDIO. Here is an example of the DIVERG indicator on a chart of Apple Inc.

'TRADING THE LOONIE
'Author: Markos Katsanos, TASC December 2015
'Coded by: Richard Denning 10/19/15
'www.TradersEdgeSystems.com

function DIVERG(bbLen,F1,F2)
'Set parameters:
 'bbLen = 20. 'Default = 20
 'F1 = 2 Default = 2
 'F2 = 4 Default = 4
 'IDX = "NDX" NASDAQ 100 Index for independent 1
 
'Close percent relative to BB band width for stock:
Dim SD As BarArray
Dim SMA As BarArray
Dim stkBB As BarArray 
SD = StdDev(C,bbLen)
SMA = Average(C,bbLen)
stkBB = 1+(C-SMA+F1*SD)/(F2*SD)

'Close percent relative to BB band width for index:
Dim IDXc As BarArray
Dim StdDevIDX As BarArray
Dim SMAidx As BarArray
Dim idxBB As BarArray
IDXc = C Of independent1
StdDevIDX = StdDev(idxc,bbLen)
SMAidx = Average(IDXc,bbLen)
idxBB = 1+(IDXc-SMAidx+F1*StdDevIDX)/(F2*StdDevIDX)

DIVERG = (idxBB-stkBB)/stkBB*100
end function
'----------------------------------------------------
'INDICATOR TO PLOT DIVERG:

sub DIVERG_IND(bbLen,F1,F2)
plot1(DIVERG(bbLen,F1,F2))

End Sub

—Richard Denning
info@TradersEdgeSystems.com
for TradersStudio

BACK TO LIST

logo

NINJATRADER: DECEMBER 2015

The TradingTheLoonie strategy and the Bollinger Band divergence indicator, which are discussed in Markos Katsanos’s article in this issue, “Trading The Loonie,” have been made available for download at www.ninjatrader.com/SC/December2015SC.zip.

Once you have downloaded them, 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 source code by selecting the menu Tools → Edit NinjaScript → Strategy from within the NinjaTrader Control Center window and selecting the “TradingtheLoonie” file. To view the indicator source code, go to Tools → Edit NinjaScript → Indicator and select the “BollingerBandDivergence” file.

NinjaScript uses compiled DLLs that run native, not interpreted, to provide the highest performance possible.

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

Sample Chart

FIGURE 9: NINJATRADER. The Bollinger Band divergence is displayed above the CL and 6C, both of which display the Bollinger Bands in their respective panels. The TradingtheLoonie strategy is displayed in the 6C panel of the chart.

—Raymond Deux and Zachary Gauld
NinjaTrader, LLC
www.ninjatrader.com

BACK TO LIST

logo

UPDATA: DECEMBER 2015

Our Traders’ Tip this month is based on “Trading The Loonie” by Markos Katsanos in this issue.

The author proposes that CAD/USD is a commodity currency, meaning it is highly correlated with the price of oil. The reason for this is that Canada’s main export destination is the US. Thus, when the price of oil is high, more US dollars will be flowing into the Canadian economy, increasing the value of the Canadian dollar. Conversely, when the price of oil is low, there will be a fall in the Canadian dollar value. This trading system primarily uses Bollinger Band divergences to judge the most opportune times to enter into a CAD futures trade.

The Updata code for this article 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 can paste the code shown below into the Updata custom editor and save it.


'CAD Trading System
Parameter "Bollinger Period" #PERIOD=20
Parameter "Bollinger Dev." @DEV=2 
PARAMETER "Ticker" ~TICKER=SELECT
PARAMETER "Donchian Entry Period" #HHLLPeriodEnt=3  
PARAMETER "Donchian Exit Period" #HHLLPeriodExt=4
PARAMETER "ROC Period" #ROCPeriod=2
PARAMETER "Average Period" #AVEPeriod=40
PARAMETER "Correl. Entry Period" #CORRPeriodEnt=20
PARAMETER "Correl. Exit Period" #CORRPeriodExt=60  
PARAMETER "MACD Ave 1" #MACDPeriod1=12
PARAMETER "MACD Ave 2" #MACDPeriod2=26
PARAMETER "MACD Signal" #MACDSignal=9  
PARAMETER "Stochastic 1" #StochasticPeriod1=30
PARAMETER "Stochastic 2" #StochasticPeriod2=3    
PARAMETER "|Correl. Thresh.|" @CORRTHRESH=0.4 
NAME "BB Divirgence Indicator [" @DEV "|" #PERIOD "]" "" 
INDICATORTYPE CHART   
DISPLAYSTYLE LINE 
@sec1BOLL=0 
@sec2BOLL=0  
@Div=0 
@MACD=0 
@MACDSig=0
@STOCHD=0 
@CorrelEntry=0 
@CorrelExit=0  
@UpperDonchEnt=0
@UpperDonchExt=0
@LowerDonchEnt=0
@LowerDonchExt=0
@AvgRef=0 
FOR #CURDATE=#PERIOD to #LASTDATE
   'BB Divirgence Indicator
   @sec1BOLL=1+((CLOSE-SGNL(CLOSE,#PERIOD,M))+2*STDDEV(CLOSE,#PERIOD))/(4*STDDEV(CLOSE,#PERIOD)+0.00001)  
   @sec2BOLL=1+((~TICKER-SGNL(~TICKER,#PERIOD,M))+2*STDDEV(~TICKER,#PERIOD))/(4*STDDEV(~TICKER,#PERIOD)+0.00001)
   @Div=100*(@sec2BOLL-@sec1BOLL)/@sec1BOLL 
   @MACD=MACD(#MACDPeriod1,#MACDPeriod2,E)
   @MACDSig=SGNL(@MACD,#MACDSignal,E)   
   @STOCHD=STOCHD(#StochasticPeriod1,#StochasticPeriod2,E)
   @CorrelEntry=BETA(CLOSE,~TICKER,#CORRPeriodEnt) 
   @CorrelExit=BETA(CLOSE,~TICKER,#CORRPeriodExt)
   @UpperDonchEnt=PHIGH(@Div,#HHLLPeriodEnt)
   @UpperDonchExt=PHIGH(~TICKER,#HHLLPeriodExt,1)
   @LowerDonchEnt=PLOW(@Div,#HHLLPeriodEnt)
   @LowerDonchExt=PLOW(~TICKER,#HHLLPeriodExt,M) 
   @AvgRef=SGNL(~TICKER,#AVEPeriod,M)
   'Long Entries
   IF @UpperDonchEnt>20 AND @Div<HIST(@Div,1) AND MOM(2)>0 AND @AvgRef>HIST(@AvgRef,1) AND @CorrelEntry>-@CORRTHRESH   
      BUY CLOSE
   ENDIF
   IF HASX(@MACD,@MACDSig,DOWN) AND @STOCHD<25 AND ~TICKER>1.04*PLOW(~TICKER,4)
      COVER CLOSE                           
   ENDIF
   IF @UpperDonchEnt>20 AND STUDY(~TICKER,MOM(3))>4.5 
      COVER CLOSE
   ENDIF
   IF CLOSE>PHIGH(HIGH,15,1) AND @CorrelExit<-@CORRTHRESH 
      COVER CLOSE
   ENDIF                        
   IF @Div>HIST(@Div,1) AND @AvgRef<HIST(@AvgRef,1) AND MOM(2)<0 AND @LowerDonchEnt<-20 AND @CorrelEntry>-@CORRTHRESH  
      SHORT CLOSE
   ENDIF
   IF HASX(@MACD,@MACDSig,UP) AND @STOCHD>85
      SELL CLOSE                           
   ENDIF
   IF @LowerDonchEnt<-20 AND STUDY(~TICKER,MOM(3))<-3
      SELL CLOSE
   ENDIF
   IF CLOSE<PLOW(LOW,15,1) AND @CorrelExit<-@CORRTHRESH 
      SELL CLOSE
   ENDIF    
   @PLOT=@Div
NEXT

Figure 10 shows an example of the Bollinger Band divergence indicator applied to CAD/USD and crude oil.

Sample Chart

FIGURE 10: UPDATA. Here, the Bollinger Band divergence indicator is applied to CAD/USD and crude oil in daily resolution.

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

BACK TO LIST

logo

TRADE NAVIGATOR: DECEMBER 2015

We have created a special file based on the formulas given in Markos Katsanos’s article in this issue, “Trading The Loonie,” to make it easy to download as a library in Trade Navigator. The filename is “SC201512.”

To download it, click on Trade Navigator’s blue telephone button, select download special file, then erase the word “upgrade” and type in “SC201512” (without the quotes), then click the start button. When prompted to upgrade, click the yes button. If prompted to close all software, click on the continue button. Your library will now download.

This library contains four indicators named “CAD Futures TS Buy,” “CAD Futures TS Sell,” “CAD Futures TS Sell Short,” and “CAD Futures TS Cover.” These indicators can be inserted into your chart (Figure 11) by opening the charting dropdown menu, then selecting the add to chart command, then selecting the highlight bars tab.

Sample Chart

FIGURE 11: TRADE NAVIGATOR. Here, the four indicators (buy, sell, sell short, cover) are applied to a monthly USD/CAD chart as highlight bars.

The TradeSense language for the indicators is as follows:

CAD Futures TS Buy 
&D1 := 20 
&SEC2 := Close Of "CL3-067" 
&sec1BOL := 1 + ((Close - MovingAvg (Close , &D1) + 2 * MovingStdDev (Close , &D1)) / (4 * MovingStdDev (Close , &D1) + .0001)) 
&sec2BOL := 1 + ((&SEC2 - MovingAvg (&SEC2 , &D1) + 2 * MovingStdDev (&SEC2 , &D1)) / (4 * MovingStdDev (&SEC2 , &D1) + .0001)) 
&DIV1 := (&sec2BOL - &sec1BOL) / &sec1bol * 100 
Highest (&DIV1 , 3) > 20 And &DIV1 < (&DIV1).1 And RateOfChange (Close , 2) > 0 And MovingAvg (&SEC2 , 40) > MovingAvg (&SEC2 , 40).2 And Correlation (Close , &SEC2 , 20) >= (-.4)

CAD Futures TS Sell
&D1 := 20 
&SEC2 := Close Of "CL3-067" 
&sec1BOL := 1 + ((Close - MovingAvg (Close , &D1) + 2 * MovingStdDev (Close , &D1)) / (4 * MovingStdDev (Close , &D1) + .0001)) 
&sec2BOL := 1 + ((&SEC2 - MovingAvg (&SEC2 , &D1) + 2 * MovingStdDev (&SEC2 , &D1)) / (4 * MovingStdDev (&SEC2 , &D1) + .0001)) 
&DIV1 := (&sec2BOL - &sec1BOL) / &sec1bol * 100 
(Crosses Above (MovingAvgX (MACD (Close , 12 , 26 , False) , 9 , False) , MACD (Close , 12 , 26 , False)) And StochK (30 , 3) > 85) Or (Lowest (&DIV1 , 3) < (-20) And RateOfChange (&SEC2 , 3) < (-3)) Or (Close < Lowest (Low , 15).1 And Correlation (Close , &SEC2 , 60) < (-.4))

CAD Futures TS Sell Short
&D1 := 20 
&SEC2 := Close Of "CL3-067" 
&sec1BOL := 1 + ((Close - MovingAvg (Close , &D1) + 2 * MovingStdDev (Close , &D1)) / (4 * MovingStdDev (Close , &D1) + .0001)) 
&sec2BOL := 1 + ((&SEC2 - MovingAvg (&SEC2 , &D1) + 2 * MovingStdDev (&SEC2 , &D1)) / (4 * MovingStdDev (&SEC2 , &D1) + .0001)) 
&DIV1 := (&sec2BOL - &sec1BOL) / &sec1bol * 100 
Lowest (&DIV1 , 3) < (-20) And &DIV1 > (&DIV1).1 And RateOfChange (Close , 2) < 0 And MovingAvg (&SEC2 , 40) < MovingAvg (&SEC2 , 40).2 And Correlation (Close , &SEC2 , 20) > (-.4)

CAD Futures TS Cover
&D1 := 20 
&SEC2 := Close Of "CL3-067" 
&sec1BOL := 1 + ((Close - MovingAvg (Close , &D1) + 2 * MovingStdDev (Close , &D1)) / (4 * MovingStdDev (Close , &D1) + .0001)) 
&sec2BOL := 1 + ((&SEC2 - MovingAvg (&SEC2 , &D1) + 2 * MovingStdDev (&SEC2 , &D1)) / (4 * MovingStdDev (&SEC2 , &D1) + .0001)) 
&DIV1 := (&sec2BOL - &sec1BOL) / &sec1bol * 100 
(Crosses Below (MACD (Close , 12 , 26 , False) , MovingAvgX (MACD (Close , 12 , 26 , False) , 9)) And StochK (30 , 3) < 25 And &SEC2 >= (1 + 4 / 100) * Lowest (&SEC2 , 4)) Or (Highest (&DIV1 , 3) > 20 And RateOfChange (&SEC2 , 3) > 4.5) Or (Close > Highest (High , 15).1 And Correlation (Close , &SEC2 , 60) < (-.4))

To create this indicator manually, click on the edit dropdown menu and open the trader’s toolbox (or use CTRL+T) and click on the functions tab. Now click on the new button, and a new function dialog window will open. In its text box, type in the code for the highlight bar. Ensure that there are no extra spaces at the end of each line. When completed, click on the verify button. You may be presented with an add inputs popup message if there are variables in the code. If so, click the yes button, then enter a value in the default value column. If all is well, when you click on the function tab, the code you entered will convert to italic font. Click on the save button, and type a name for the indicator.

Strategy

This library also contains a strategy called “SC CAD Futures Trading System.” This prebuilt strategy can be overlaid on your chart (Figure 12) by opening the charting dropdown menu, selecting the add to chart command, then selecting the strategies tab.

Sample Chart

FIGURE 12: TRADE NAVIGATOR. Strategy entry/exit points are displayed on a one-minute USD/CAD chart with profit/loss shading.

If you have any difficulty using the indicators or strategy, you can contact our technical support staff at 719 884-0245 or click on the live chat tool either under Trade Navigator’s help menu or near the top of our homepage at www.TradeNavigator.com. Our support hours are 6 am–7 pm (M-F) Mountain Time. Happy trading!

—Genesis Financial Technologies
www.TradeNavigator.com

BACK TO LIST

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