public EMMinus(DataSeries source, int period, string description) public static EMMinus Series(DataSeries source, int period) public static double Value(int bar, DataSeries source, int period)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { /* Enter short when EMMinus turns up and start a trailing stop when it crosses 19 */ bool TStopOn = false; ChartPane EMPane = CreatePane( 35, true, true ); DataSeries emm = EMMinus.Series( Close, 40 ); PlotSeries( EMPane, emm, Color.Red, WealthLab.LineStyle.Solid, 1 ); PlotStops(); for(int bar = emm.FirstValidValue; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if( CrossOver( bar, emm, 19 ) ) TStopOn = true; if( p.MAEAsOfBarPercent( bar-1 ) < -8 ) CoverAtStop( bar, p, p.EntryPrice*1.08, "Stop Loss @ 8%" ); else if( p.MFEAsOfBarPercent( bar-1 ) > 5 ) CoverAtStop( bar, p, p.EntryPrice, "Breakeven @ 5%" ); if( TStopOn == true ) CoverAtTrailingStop( bar+0, p, High[bar-3]+0.1, "Trailing Stop" ); } else { // Looks like a bear trend has formed if( ( emm[bar-1] < 0.01 ) & TurnUp( bar, emm ) ) { if( ShortAtMarket( bar+1, "Bear" ) != null ) TStopOn = false; } } } } } }