using System; using System.Text; using WealthLab; using WealthLab.Indicators; using System.Drawing;namespace WealthLab.Strategies { class QQQQCrash : WealthScript { //Create parameters private StrategyParameter bbPeriod; private StrategyParameter bbStdDev; private StrategyParameter exitDays; public QQQQCrash() { bbPeriod = CreateParameter("Bollinger Period", 10, 6, 20, 2); bbStdDev = CreateParameter("Std Dev", 1.5, 1, 3, 0.25); exitDays = CreateParameter("Timed Exit", 20, 1, 30, 1); } protected override void Execute() { //Obtain parameters values int bbPer = bbPeriod.ValueInt; double bbSD = bbStdDev.Value; int timedExit = exitDays.ValueInt; BBandLower bbL = BBandLower.Series( Close, bbPer, bbSD ); PlotSeries(PricePane, bbL, Color.Silver, LineStyle.Solid, 2); for (int bar = bbPer; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position Pos = LastPosition; if (bar + 1 - Pos.EntryBar >= timedExit) SellAtMarket(bar + 1, Pos, "Time-based"); else if (Closebar > Pos.EntryPrice) SellAtMarket(bar + 1, Pos); } else { if (Closebar < bbLbar) if( BuyAtMarket(bar + 1) != null ) LastPosition.Priority = -Closebar; } } CMO cmo = CMO.Series( Close, 7 ); } } }
Equity curve before applying Analysis Series filter
Analysis Series filter
if (Closebar < bbLbar) if( CMO.Series( Close, 7 )bar < -60 ) if( BuyAtMarket(bar + 1) != null ) LastPosition.Priority = -Closebar;
Equity curve after applying Analysis Series filter