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 2010-01 | Vortex Indicator (Botes & Siepman)

RSS

Traders' Tip text

We’ve add the Vortex Indicators to our TASCIndicators library for easy reference and programmed a stop and reverse version of the suggested trading strategy using an ATR trailing stop. On the S&P e-mini, the strategy was effective in entering and remaining in large trends, garnering more than $33,000 in profits trading 2 contracts 24 times over the past two years (no slippage or commissions). As typically observed when using stops, tightening the stop by reducing the ATR factor reduced trading profit.


Image

Figure 1. The strategy to reverse on a stop was effective in remaining in strong trends despite multiple Vortex crossings.


WealthScript Code (C#)

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 { //Pushed indicator StrategyParameter statements private StrategyParameter vmPeriod; private StrategyParameter atrFactor;

public MyStrategy() { vmPeriod = CreateParameter("VM Period",14,5,100,10); atrFactor = CreateParameter("ATR Factor",4,1,5,0.5);

} protected override void Execute() { int period = vmPeriod.ValueInt; int xBar = 0; // Crossing bar or stop bar bool bull = false; double triggerPrice = -1d; double stopPrice = -1d; DataSeries vmPlus = VMPlus.Series(Bars ,period); DataSeries vmMinus = VMMinus.Series(Bars ,period); DataSeries atr = atrFactor.Value * ATR.Series(Bars, 10); ChartPane paneVM = CreatePane(40,true,true); PlotSeries(paneVM, vmPlus, Color.Blue, LineStyle.Solid, 2); PlotSeries(paneVM, vmMinus, Color.Red, LineStyle.Solid, 2); PlotStops(); HideVolume(); for(int bar = period; bar < Bars.Count; bar++) { if (CrossOver(bar, vmPlus, vmMinus)) { SetBackgroundColor(bar, Color.LightBlue); bull = true; xBar = bar; } else if (CrossUnder(bar, vmPlus, vmMinus)) { SetBackgroundColor(bar, Color.LightPink); bull = false; xBar = bar; } if (IsLastPositionActive) { Position p = LastPosition; if (p.PositionType == PositionType.Long) { if (!bull) { SellAtStop(bar + 1, p, Low[xBar]); ShortAtStop(bar + 1, Low[xBar]); } else if (SellAtTrailingStop(bar + 1, p, Close[bar] - atr[bar], "T-Stop")) xBar = bar + 1; } else { if (bull) { CoverAtStop(bar + 1, p, High[xBar]); BuyAtStop(bar + 1, High[xBar]); } else if (CoverAtTrailingStop(bar + 1, p, Close[bar] + atr[bar], "T-Stop")) xBar = bar + 1; } } else if (xBar > period) // initial and re-entry { if (bull) BuyAtStop(bar + 1, High[xBar]); else ShortAtStop(bar + 1, Low[xBar]); } } } } }

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.