TASC 2015-12 | Trading The Loonie (Katsanos)

Modified on 2015/10/31 14:46 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

CAD/USD aka the loonie is a petrocurrency like NOK/USD, USD/RUB and the like. The oil price 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 key rate periodically come into play.

This month's system is most likely to exhibit periods of prosperous behavior while crude oil is volatile, and is expected to take a break during prolonged rangebound movements like in 2011-2013.

In addition to 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.

Image

Figure 1. 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.

A participating indicator, Correlation, is part of the Community Indicators library, driven by the Wealth-Lab user community. To run this Wealth-Lab 6 strategy code below, install the indicator library (or update to the actual version using Extension Manager) from our website wealth-lab.com, 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 a line of code yourself.

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) && stobar>85) || (llvDivbar < -20 && rocOilbar < -3) || (Closebar < llvbar-1 && correlation60bar < -0.4); bool cover = (CrossOver(bar, macd, macdSignal) && stobar<25 && (oilbar >= (1 + 4.0/100d) * llvOilbar) ) || (hhvDivbar>20 && rocOilbar>4.5 ) || (Closebar > hhvbar-1 && correlation60bar < -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 = (hhvDivbar > 20) && (divergencebar < divergencebar-1) && (rocbar>0) && (movbar > movbar-2) && (correlation20bar > -0.4); bool shrt = (llvDivbar < -20) && (divergencebar > divergencebar-1) && (rocbar<0) && (movbar < movbar-2) && (correlation20bar > -0.4); if( buy ) BuyAtMarket(bar+1); else if( shrt ) ShortAtMarket(bar+1); } } } } }


Eugene
Wealth-Lab team
www.wealth-lab.com