After struggling quite a bit, I've got a very basic system that
doesn't produce any signals and certainly has some flaws here and
there :) If anyone cares to take a look I'd be thrilled:
// System rules:
// - The stock gaps up more than 1 percent
// - The stock's volume in the first 30 minutes of the day is higher
than 25% of the stock's
// average daily volume in the last 30 trading days
// - Buy when price exceeds the 30 min Opening Range high
// - Close position if price drops under 30 min Opening Range low
// - Trailing Stop at 1%
// - Stoploss at 0.5%
// ***** Opening Gap Code *****
TimeFrameSet (inDaily);
OpeningGap = (O - Ref (C, -1));
OpeningGapPct = (OpeningGap / Ref (C, -1)) * 100;
GapOK = OpeningGapPct > 1;
TimeFrameRestore ();
// ***** Average Daily Volume Code *****
TimeFrameSet (inDaily);
AvgVol30Days = Sum ( V, 30);
TimeFrameRestore ();
// ***** Opening Volume Code *****
dn = DateNum();
StartDay = dn != Ref (dn, -1);
FirstOpeningBar = Ref (StartDay, 0);
LastOpeningBar = Ref (StartDay, -29);
if (FirstOpeningBar = 1)
OpeningVolume = 0;
else ;
if (LastOpeningBar = 1)
OpeningVolume = Sum (V,29);
else ;
VolumeOK = IIf (OpeningVolume > (TimeFrameExpand (AvgVol30Days,
inDaily, expandFirst) * 0.25), 1, 0);
// ***** Opening Range Code *****
if (FirstOpeningBar = 1)
OpeningHigh = HHV (H,29);
else ;
if (LastOpeningBar = 1)
OpeningLow = LLV (L,29);
else ;
// ***** System Logic *****
Buy = GapOK AND VolumeOK AND (H > OpeningHigh);
BuyPrice = ValueWhen ( Buy, O, 1);
Sell = (L > OpeningLow);
ApplyStop (stopTypeLoss, stopModePercent, 0.5, 1, Volatile=False,
ReEntryDelay=0);
ApplyStop (stopTypeTrailing, stopModePercent, 1, 1, Volatile=False,
ReEntryDelay=0);