using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators;namespace WealthLab.Strategies { public class TASCAug2020 : WealthScript { private StrategyParameter slider1; private StrategyParameter slider2; public TASCAug2020() { slider1 = CreateParameter("PMO period 1",35,2,300,20); slider2 = CreateParameter("PMO period 2",20,2,300,20); } protected override void Execute() { var ls = LineStyle.Solid; var ixy = GetExternalSymbol("IXY", true).Close; var ixr = GetExternalSymbol("IXR", true).Close; var pmo_ixy = PMO.Series(ixy, slider1.ValueInt, slider2.ValueInt); var pmo_ixr = PMO.Series(ixr, slider1.ValueInt, slider2.ValueInt); int xoBar = -1, xuBar = -1; ChartPane panePMO = CreatePane( 40, true, true); HideVolume(); PlotSeries( panePMO, pmo_ixy, Color.Green, ls, 1); PlotSeries( panePMO, pmo_ixr, Color.Red, ls, 1); for(int bar = GetTradingLoopStartBar( Math.Max(pmo_ixy.FirstValidValue, pmo_ixr.FirstValidValue)); bar < Bars.Count; bar++) { bool xo = CrossOver( bar, pmo_ixy, pmo_ixr); bool xu = CrossUnder( bar, pmo_ixy, pmo_ixr); if (xo) { xoBar = bar; DrawCircle( panePMO, 15, bar, pmo_ixy[bar], Color.Green, LineStyle.Solid, 1, true); } if (xu) { xuBar = bar; DrawCircle( panePMO, 15, bar, pmo_ixy[bar], Color.Red, LineStyle.Solid, 1, true); } SetBackgroundColor( bar, (xoBar > xuBar) ? Color.FromArgb(20, Color.Green) : Color.FromArgb(20, Color.Red)); if (xoBar == xuBar) SetBackgroundColor( bar, Color.Transparent); if (xoBar == xuBar) continue; if (IsLastPositionActive) { Position p = LastPosition; if (xu) SellAtMarket( bar + 1, p, "Trend change"); } else { if (xoBar > xuBar) BuyAtMarket( bar + 1); } } } } }