using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators; using TASCIndicators;namespace WealthLab.Strategies { public class PctB : WealthScript { private StrategyParameter esdbPeriod; private StrategyParameter esdbStdDev; public PctB() { esdbPeriod = CreateParameter("ESD Bands Period", 20, 5, 50, 5); esdbStdDev = CreateParameter("Std Dev", 2, 1, 5, 0.25); } protected override void Execute() { var period = esdbPeriod.ValueInt; var sd = esdbStdDev.Value; var esdbL = ESDBandLower.Series(Close,period,sd); var esdbU = ESDBandUpper.Series(Close,period,sd); DataSeries PctESDBW = ( Close - esdbL ) / ( esdbU - esdbL ); PctESDBW.Description = "% ESDB Width"; DataSeries pctESDBBelow = SeriesIsBelowValue.Series( PctESDBW, 0.2, 3 ); ChartPane xob_pane = CreatePane( 20, true, true ); PlotSeries( xob_pane, pctESDBBelow, Color.DarkRed, WealthLab.LineStyle.Solid, 1 ); ChartPane PctBBWPane = CreatePane( 20, true, true ); PlotSeries( PctBBWPane, PctESDBW, Color.Blue, WealthLab.LineStyle.Solid, 2 ); Color fillColor = Color.FromArgb(16, 0, 0, 255); PlotSeriesFillBand( PricePane, esdbU, esdbL, Color.Blue, fillColor, LineStyle.Solid, 1); HideVolume(); for(int bar = PctESDBW.FirstValidValue; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( PctESDBWbar >= 0.8 ) SellAtMarket( bar+1, LastPosition ); } else { if( bar >= pctESDBBelowbar+3 && pctESDBBelowbar-3 > pctESDBBelowbar-4 ) { SetBackgroundColor( bar, Color.FromArgb(231, 255, 231) ); if( BuyAtMarket( bar+1 ) != null ) LastPosition.Priority = -Closebar; } } } } } }