TASC 2011-08 | Automated Techniques For Intraday Traders (Coles)

Modified on 2011/07/13 07:20 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

Wealth-Lab users are welcome to give these two time-based techniques a try and turn their screens into drawing boards. The code is available for instant download from Wealth-Lab's "Open Strategy" dialog. An additional library, “Community Components”, also available for download to Wealth-Lab customers from our site www.wealth-lab.com (Extensions section), is required for the strategy to function.


Image

Figure 1. A Wealth-Lab Developer 6.2 chart showing the Fibonacci/Lucas bar chart markup applied to a Daily chart of AAPL (Apple Inc).


Users should be aware that with methods without a rock solid starting point, it's an open question whether does automating line placement on the chart removes the subjectivity. Our example strategy automates finding the starting point on the chart of any time frame by searching for the recent 10% peak or trough (whichever happened later) – the percentage is configurable by dragging the "Reversal %" slider in the bottom left part of the screen.

One thing's for sure: If you draw enough lines on a chart, some of them are bound to hit important turning points.

WealthScript Code (C#)

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

namespace WealthLab.Strategies { public class FibLucas : WealthScript { private StrategyParameter paramAmount; int">"> fib = new int[ {5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765}; int">"> lucas = new int[ {3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571}; Font font = new Font("Wingdings", 8, FontStyle.Bold); Font font2 = new Font("Verdana", 7, FontStyle.Regular); string upArrow = Convert.ToChar(0x00E9).ToString(); string dnArrow = Convert.ToChar(0x00EA).ToString(); public FibLucas() { paramAmount = CreateParameter("Reversal %", 10, 2, 50, 1); } // Marking bars private void Highlighter( int[] array, double barsSince, int bar, Color color) { for( int i = 0; i < array.GetLength(0); i++ ) { if( barsSince == arrayi ) { AnnotateBar(upArrow, bar, false, color, Color.Transparent, font); AnnotateBar(arrayi.ToString(), bar, false, color, Color.Transparent, font2); SetBarColor( bar, color ); break; } } } protected override void Execute() { // Variable definition, series creation and array initialization PeakTroughMode pct = PeakTroughMode.Percent; double amt = paramAmount.Value; Peak p = Peak.Series( High, amt, pct ); PeakBar pb = PeakBar.Series( High, amt, pct ); Trough t = Trough.Series( Low, amt, pct ); TroughBar tb = TroughBar.Series( Low, amt, pct ); Calculate c = new Calculate(this); // pass an instance of the WealthScript object DataSeries barsSince = new DataSeries(Bars,"Bars Since Start"); int markbar = -1; int init = -1; SetBarColors( Color.Silver,Color.Silver ); HideVolume(); // Build auxiliary binary wave DataSeries start = new DataSeries( Bars, "start" ); for(int bar = Bars.Count-1; bar >= 0; bar--) { int i = Math.Max( (int)tbbar, (int)pbbar ); if( i > -1 ) { starti = i; init = i; break; } else starti = -1; } for(int bar = init; bar < Bars.Count; bar++) { // Building BarsSince series if( c.BarsSince( bar, CrossOver(bar, start, 0) ) == 0) markbar = bar; if( markbar > 0 ) barsSincebar = bar - markbar; // Marking Fibonacci/Lucas bars Highlighter( fib, barsSincebar, bar, Color.Blue ); Highlighter( lucas, barsSincebar, bar, Color.Red ); } } } }