using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators; using Community.Indicators;namespace WealthLab.Strategies { public class TASC201806 : WealthScript { private StrategyParameter _w1; private StrategyParameter _w2; private StrategyParameter _w3; private StrategyParameter _w4; private StrategyParameter _w5; private StrategyParameter _exit; public TASC201806() { _w1 = CreateParameter("VFI", 1, 1, 1, 1); _w2 = CreateParameter("MA", 1, 1, 1, 1); _w3 = CreateParameter("MA > MA-4", 1, 1, 1, 1); _w4 = CreateParameter("Stiffness", 1, 1, 1, 1); _w5 = CreateParameter("Market", 2, 2, 2, 1); _exit = CreateParameter("Time exit", 20, 20, 180, 10); } protected override void Execute() { //parameters int w1 = _w1.ValueInt, w2 = _w2.ValueInt, w3 = _w3.ValueInt, w4 = _w4.ValueInt, w5 = _w5.ValueInt, TimedExit = _exit.ValueInt; var vfi = VFI.Series(Bars, 130, 3, 0.2, 2.5); var spy = GetExternalSymbol("SPY",true); var emaSpy = EMAModern.Series( spy.Close, 100 ); var maxStiffness = 7; var ScoreRating = 5; //STIFFNESS var MA100 = TASCIndicators.FastSMA.Series(Close, 100); var closeBelowMA100 = SeriesIsBelow.Series(Close, MA100, 1); var Stiffness = Sum.Series(closeBelowMA100, 63); // DIPS BELOW MA var Score = new DataSeries(Bars,"Score"); for(int bar = 4; bar < Bars.Count; bar++) { var cond1 = (vfibar > 0) ? 1 : 0; //MONEY FLOW var cond2 = (Closebar > MA100bar) ? 1 : 0; //MA var cond3 = (MA100bar > MA100bar - 4) ? 1 : 0; //MA DIRECTION var cond4 = (Stiffnessbar <= maxStiffness) ? 1 : 0; //STIFFNESS var cond5 = (emaSpybar >= emaSpybar - 2) ? 1 : 0; //MARKET DIRECTION Scorebar = w1*cond1 + w2*cond2 + w3*cond3 + w4*cond4 + w5*cond5; } for(int bar = GetTradingLoopStartBar(1); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if ( bar+1 - p.EntryBar >= TimedExit ) SellAtMarket( bar+1, p, "Timed" ); } else { if( Scorebar > ScoreRating ) BuyAtMarket( bar+1); } } HideVolume(); var sp = CreatePane(40,false,true); var vp = CreatePane(30,false,true); var ep = CreatePane(80,false,true); PlotSeries( sp, Score, Color.DarkGreen, LineStyle.Histogram, 3); PlotSeries( vp,vfi,Color.FromArgb(255,0,0,0),LineStyle.Solid,2); PlotSymbol( ep,spy,Color.Blue,Color.Red); PlotSeries( ep,emaSpy,Color.Blue,LineStyle.Solid,1); } } }