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 TradersTips201012 : WealthScript { private StrategyParameter paramPT; private StrategyParameter paramSL; public TradersTips201012() { paramPT = CreateParameter("Profit Target %",10,1,100,1); paramSL = CreateParameter("Stop Loss %",10,1,100,1); } protected override void Execute() { DataSeries ma = SMA.Series(Close, 50); HullMA hma4 = HullMA.Series(Close,4); DataSeries rsiHma = RSI.Series( HullMA.Series(Close,9), 9 ); Color tp = Color.Transparent; LineStyle ls = LineStyle.Solid; ChartPane paneRsi = CreatePane(35,true,true); PlotSeries(PricePane,hma4,Color.Blue,LineStyle.Solid,1); PlotSeries(PricePane,SMA.Series(Close,50),Color.Blue,LineStyle.Solid,2); PlotSeriesOscillator( paneRsi, rsiHma, 50, 0, Color.FromArgb( 50, Color.Red ), tp, Color.DarkGray, ls, 2); PlotSeriesOscillator( paneRsi, rsiHma, 90, 0, Color.FromArgb( 70, Color.Red ), tp, tp, ls, 2); PlotSeries(paneRsi,RSI.Series(SMA.Series(Close,9),9),Color.Violet,ls,2); DrawHorzLine( paneRsi, 90, Color.Blue, ls, 1 ); DrawHorzLine( paneRsi, 50, Color.Red, ls, 1 ); for(int bar = GetTradingLoopStartBar(60); bar < Bars.Count; bar++) { SetBackgroundColor( bar, Color.FromArgb( 10, Color.Cyan ) ); if (IsLastPositionActive) { Position p = LastPosition; double Stop = p.EntryPrice * (1 - paramSL.Value / 100.0d); double Target = p.EntryPrice * (1 + paramPT.Value / 100.0d); bool hmaRsiOver90 = rsiHma[bar] > 90; if( hmaRsiOver90 ) ExitAtMarket(bar + 1, p); else if( !ExitAtStop(bar + 1, p, Stop ) ) ExitAtLimit(bar + 1, p, Target ); } else { bool closeOverSMA = (Close[bar] > ma[bar]); bool hmaUpside = TurnUp(bar, hma4); bool hmaRsiBelow50 = rsiHma[bar] <= 50; bool closeOverOldClose = (Close[bar] > Close[bar-59]); if ( closeOverSMA && hmaUpside && hmaRsiBelow50 && closeOverOldClose ) if( BuyAtMarket(bar + 1) != null ) LastPosition.Priority = -rsiHma[bar]; } } } } }