Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2017-07 | Trading The Nikkei (Katsanos)

RSS

Traders' Tip text

We've added Markos Katsanos' Regression Divergence indicator to the Wealth-Lab TASCIndicators library for easy reference in any Strategy.

Buy signals were produced when the divergence crossed above 75 and turned down during the next three days. The opposite event, i.e. the crossing under 25 and turning up, generated short signals.

Image

Figure 1. Trades generated by the intermarket divergence system with the 50-day regression divergence indicator plotted on the top.

Get the companion Strategy's C# code by downloading it right from Wealth-Lab's "Open Strategy" dialog:

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

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { private StrategyParameter slider1; private StrategyParameter slider2; private StrategyParameter slider3; public MyStrategy() { slider1 = CreateParameter("Regression Period",50,2,300,20); slider2 = CreateParameter("Div.Mom. Period",50,2,300,20); slider3 = CreateParameter("ROC Period",3,2,300,20); } protected override void Execute() { var fxy = GetExternalSymbol("FXY",true); var spy = GetExternalSymbol("SPY",true); var rd = RegressionDivergence.Series(Bars,fxy,spy,slider1.ValueInt,slider2.ValueInt,slider3.ValueInt); int STD = 25, OB = 90,//STOCHASIC D1 = 3, //ROC DAYS D2 = 25, //MA LR DAYS DIVDAYS = 50,// REGRESSION DAYS IMDAYS = 50;// DIVERGENCE MOMENTUM DAYS double CR3CR = 0.8; //CORRELATION WITH SEC3 int DIVCRIT = 75, LAG = 3; // DIVERGENCE CRITICAL double STP = 1.5; // STOP LOSS % int EXIT = 11; // TIME EXIT DAYS var ls = LineStyle.Solid; var OS=100-OB; var DIVSHORT = 100-DIVCRIT; var STOC=(SMA.Series(Close-Lowest.Series(Low,STD),3)*100)/(SMA.Series(Highest.Series(High,STD)-Lowest.Series(Low,STD),3)); //STOC = StochK.Series(Bars,3); var MA1=SMA.Series(Close,D2); var LR=100*LinearRegSlope.Series(Close,D2);

var RS1 =(Close/(Close>>D1)-1)*100; var RS2 =(fxy.Close/(fxy.Close>>D1)-1)*100; var RS3 =(spy.Close/(spy.Close>>D1)-1)*100; var CR2 = Correlation.Series(RS1,RS2,DIVDAYS); var CR3 = Correlation.Series(RS1,RS3,DIVDAYS); //var pop = StdDevCalculation.Population; //var b2=CR2*StdDev.Series(RS1,DIVDAYS,pop)/(StdDev.Series(RS2,DIVDAYS,pop)+0.001); //var a2=SMA.Series(RS1,DIVDAYS)-b2*SMA.Series(RS2,DIVDAYS); //var PRED2=b2*RS2+a2; //var DIV2=PRED2-RS1; //var IM2=(SMA.Series(DIV2 - Lowest.Series(DIV2,IMDAYS), 2) * 100)/(SMA.Series(Highest.Series(DIV2, IMDAYS) - Lowest.Series(DIV2, IMDAYS),2)+0.01);

ChartPane rdPane = CreatePane(40,true,true); PlotSeries(rdPane,rd,Color.FromArgb(255,255,0,0),LineStyle.Solid,1); DrawHorzLine(rdPane,DIVSHORT,Color.Brown,ls,1); DrawHorzLine(rdPane,DIVCRIT,Color.CadetBlue,ls,1); for(int bar = GetTradingLoopStartBar(60); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; int barssinceentry = bar+1 - p.EntryBar;

if( barssinceentry>= EXIT ) ExitAtClose(bar,Position.AllPositions,"TIME"); else if( p.PositionType == PositionType.Long ) { if( barssinceentry>3 && Close[bar]<Close[bar-barssinceentry]*(1.0-STP/100d) && STOC[bar]>OS) SellAtMarket(bar+1,p,"STOP");

if( barssinceentry>7 && Close[bar]<Highest.Series(Close,barssinceentry)[bar]*(1.0-STP/100d) ) SellAtMarket(bar+1,p,"TRAIL"); } else { if( barssinceentry>3 && Close[bar]>Close[bar-barssinceentry]*(1.0+STP/100d) && STOC[bar]<OB) CoverAtMarket(bar+1,p,"INITIAL STOP");

if( barssinceentry>7 && Close[bar]>Lowest.Series(Close,barssinceentry)[bar]*(1.0+STP/100d) ) CoverAtMarket(bar+1,p,"TRAIL COVER"); } } else { if( (rd[bar-LAG]>DIVCRIT) && (rd[bar]<rd[bar-LAG]) && (rd[bar]>DIVSHORT) && (CR3[bar]<CR3CR) && (LR[bar]>=LR[bar-1] || Close[bar]>MA1[bar]) ) BuyAtClose(bar,"DIVJPY");

if( (rd[bar-LAG]<DIVSHORT) && (rd[bar]>rd[bar-LAG]) && (rd[bar]<DIVCRIT) && (CR3[bar]<CR3CR) && (LR[bar]<=LR[bar-1] || Close[bar]<MA1[bar]) ) ShortAtClose(bar,"NDIVJPY"); } } } } }

Eugene (Gene Geren)
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.


ScrewTurn Wiki. Some of the icons created by FamFamFam.