Wealth-Lab Wiki

API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers Pending Deletion PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers
RSS

Navigation


Quick Search
»
Advanced Search »


TASC 2015-12 | Trading The Loonie (Katsanos)

RSS

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) && 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
www.wealth-lab.com

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki. Some of the icons created by FamFamFam.