Position SplitPosition(Position position, double percentToRetain);
Position s = SplitPosition( LastPosition, 49.99 );
using System; using System.Drawing; using WealthLab; using WealthLab.Indicators; using WealthLab.Rules.Candlesticks;namespace WealthLab.Strategies { public class ShootingStarStrategy3 : WealthScript { protected override void Execute() { bool[] ShootingStar; CandlePattern.BearishShootingStar(this, "ShootingStar", true, out ShootingStar); double limit2 = 0; double limit4 = 0; bool canSplit = false; bool limit2hit = false; bool limit4hit = false; for(int bar = 25; bar < Bars.Count; bar++) { if( ActivePositions.Count > 0 ) { if( bar < Bars.Count-1 ) { limit2hit = Lowbar+1 < limit2; limit4hit = Lowbar+1 < limit4; } if( !CoverAtStop( bar+1, Position.AllPositions, RiskStopLevel, "Stop" ) ) { if( canSplit ) { if( limit2hit ) { Position s = SplitPosition( LastPosition, 49.99 ); if( s!= null ) canSplit = false; CoverAtLimit( bar+1, s, limit2, "R/R 2" ); } } else if( limit4hit ) CoverAtLimit( bar+1, LastActivePosition, limit4, "R/R 4" ); } } else { if( ShootingStarbar ) { int ssBar = bar; double ssPrice = Highbar; bool cond1 = ( (ssPrice > HighssBar-1) & (HighssBar-1 > HighssBar-2) ); bool cond2 = ( (ssPrice > HighssBar-1) & (ssPrice > HighssBar-3) ); bool cond3 = ( (ssPrice > HighssBar-2) & (ssPrice > HighssBar-3) ); RiskStopLevel = ssPrice + Bars.SymbolInfo.Tick * 3; if( cond1 || cond2 || cond3 ) { if( ShortAtMarket(bar + 1) != null ) { Position p = LastPosition; double ep = p.EntryPrice; double er = RiskStopLevel; limit2 = ep - Math.Abs( er - ep ) * 2; limit4 = ep - Math.Abs( er - ep ) * 4; canSplit = true; } } } } } } } }