TASC 2016-04 | Trading Gap Reversals (Calhoun)

Modified on 2016/03/04 12:31 by Eugene — Categorized as: TASC Traders Tips

The WealthScript code for Wealth-Lab for Ken Calhoun's "Trading Gap Reversals" technique is presented. Through parameter “sliders” at the bottom you can tune this system by modifying the parameters like gap percent, trailing stop value, and thresold for entry.

Figure 1: The example trade in FTNT (Fortinet) in January 2016.

This strategy's code has been modified to trade only once a day, and exit as soon as gap is closed in addition to the other exits. It's advised that motivated users also experiment with replacing the fixed dollar variables with a fraction of ATR to make the system more adaptive. Additionally, rules can be inversed to explore the short side.

```using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;namespace WealthLab.Strategies
{
{
private StrategyParameter gapPct;
{
gapPct = CreateParameter("Gap %", 10, 1, 30, 1);
sellStp = CreateParameter("Sell stop", 0.40, 0.10, 1.0, 0.1);
}		protected override void Execute()
{
DataSeries trigger = Bars.Close * (1 - gapPct.Value / 100) >> 1;
int cnt = 0;

for (int bar = 1; bar < Bars.Count; bar++)
{
if( Date[bar].Date > Date[bar-1].Date )
cnt++;

Position p = LastPosition;

if (IsLastPositionActive)
{
double amount = p.MFEAsOfBar(bar) / p.Shares + p.EntryPrice - sellStp.Value;
if(!SellAtStop(bar+1, p, p.EntryPrice - sellStp.Value, "Initial"))
if(!SellAtTrailingStop(bar+1, p, amount, "Trailing"))
SellAtLimit(bar+1, p, p.AutoProfitLevel, "Gap closed");
}
else if (p == null || !p.Active && p.EntryBar < (bar - Bars.IntradayBarNumber(bar)))
{
if( cnt > 0 )
{
int firstBarToday = bar - Bars.IntradayBarNumber(bar);
int lastBarYesterday = firstBarToday - 1;
bool priceFilter = (Close[firstBarToday] >= 20) && (Close[firstBarToday] <= 70);
bool gap = (Open[firstBarToday] <= trigger[lastBarYesterday]);

if( priceFilter && gap && Bars.IntradayBarNumber(bar) > 0 )
{