Page History: TASC 2011-04 | Identifying Cup Formations Early (Siligardos)
Compare Page Revisions
Page Revision: 2011/03/24 13:46
Traders' Tip text
Unsatisfied with scanning only for current semi-cups, we modified Dr. Siligardos’ excellent algorithm to be more apt for backtesting by identifying and drawing every semi-cup detected in a chart. By keying off of minor peaks and assuming that a semi-cup forms after each one, the amount of processing is greatly reduced and simultaneously eliminates the need to look back to an arbitrary level above the current price. To reduce the number of second peaks that form the same semi-cup, we added an extra grid constraint making the second column in the top row a “yellow box” (see article).
Once a semi-cup is detected, only two possible outcomes exist: it fails by making a new low or it starts turning up. New low failures are recorded for each semi-cup and the peak pattern re-enters “search mode” on the following bar at which time the grid is recalculated based on the new L0 low. Most often a new semi-cup is detected immediately. On the other hand, if price turns up and exceeds the L2 level, this is judged as a success and the semi-cup is frozen. In either case, the outcome is important to evaluate at every bar when backtesting, and these are indicated visually by red and blue arrows. Using the information in our semi-cup objects, we can even display the reference grid (Figure 1).
At the time of this writing (mid-February), a S&P 500 scan for semi-cups with a minimum of 30 Weekly bars returned AEE, AYE, ERTS, ETFC, EXC, FE, GME, HRB, KEY, LLL, LLY, MO, PBI, PPL, SAI, VLO, and WFR.
Figure 1. After a few semi-cup failures (red arrows), AAPL formed the mother of all cup and handles in early 2003. Note that in the Daily chart (inset) the mother cup spawned two “nested” semi-cups.
Note: The detection code submitted for the magazine has been added to the TASCIndicators library, version 2011.4.0.0
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators; // requires version 2011.4.0.0 min
namespace WealthLab.Strategies
{
public class SemiCupDetector : WealthScript
{
StrategyParameter _minCupBars;
StrategyParameter _reversalPct;
public SemiCupDetector()
{
_minCupBars = CreateParameter("Min Cup Bars", 20, 20, 100, 10);
_reversalPct = CreateParameter("Pk Rev. %", 5, 0.5, 8, 0.5);
}
protected override void Execute()
{
DataSeries peakBars = PeakBar.Series(Close, _reversalPct.Value, PeakTroughMode.Percent);
SemiCups semiCups = new SemiCups(this, _minCupBars.ValueInt, peakBars);
// semiCups.ProcessSemiCups(); // not required for TASCIndicators 2011.4.0.1
semiCups.Draw();
// Scan for current pattern
foreach (KeyValuePair kvp in semiCups.Cups)
{
SemiCup sc = kvp.Value;
if (sc.Active && sc.status == CupStatus.SemiCupDetected)
BuyAtMarket(Bars.Count);
}
}
}
}