public static void SaveClosedTrades(this WealthScript obj, string path, bool savePositionType = false)public void SaveClosedTrades( string path, bool savePositionType = false )
SymbolName,EntryDate,EntryPrice,EntrySignal,ExitDate,ExitPrice,ExitSignal,The value of Indicator of choice at EntryDate
using System; using System.Text; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { for(int bar = 45; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if ( CrossUnder( bar, RSI.Series( Close, 14 ), 70 ) ) SellAtMarket( bar+1, Position.AllPositions, "exit" ); } else { if ( CrossOver( bar, RSI.Series( Close, 14 ), 50 ) ) if( BuyAtMarket( bar+1, "RSI" ) != null ) // Store indicator data in the position's tag property LastPosition.Tag = Bars.FormatValue( RSI.Series( Close, 14 )[bar] ); } } // Specify destination file string path = @"C:\temp\Trades.csv"; // Call SaveClosedTrades, passing the destination file this.SaveClosedTrades( path ); } } }
using System; using System.Text; using WealthLab; using WealthLab.Indicators; using Community.Components; // SaveClosedTrades here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // Create an instance of the Utility class and pass WealthScript as "this" Utility u = new Utility( this ); for(int bar = 45; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if ( CrossUnder( bar, RSI.Series( Close, 14 ), 70 ) ) SellAtMarket( bar+1, Position.AllPositions, "exit" ); } else { if ( CrossOver( bar, RSI.Series( Close, 14 ), 50 ) ) if( BuyAtMarket( bar+1, "RSI" ) != null ) // Store indicator data in the position's tag property LastPosition.Tag = Bars.FormatValue( RSI.Series( Close, 14 )[bar] ); } } // Specify destination file string path = @"C:\temp\Trades.csv"; // Call SaveClosedTrades, passing the destination file u.SaveClosedTrades( path ); } } }