From API doc for Backtester.Orders, this "returns a List that contains Transaction instances that represent the orders, or signals, that need to be placed for the Strategy at the next market session.". I noticed that this returns all possible signals regardless of the value for "Max Entry Signals". To repro use the following OneNight strategy and set a small number for Max Entry Signals and check the debug output, it's not the same as the produced signals for the next day on the Signals tab.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using finantic.Indicators; namespace WealthScript7 { public class MyStrategy : UserStrategyBase { MP movingPercentile; public override void Initialize(BarHistory bars) { TR tr = new TR(bars); movingPercentile = new MP(tr, lookback: 100, percentile:75); } public override void Execute(BarHistory bars, int idx) { foreach (var pos in OpenPositions) ClosePosition(pos, OrderType.Market); double mpfactor = 0.7; double limit = bars.Close[idx] - movingPercentile[idx] * mpfactor; PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, limit); } public override void BacktestComplete() { base.BacktestComplete(); foreach(Transaction t in Backtester.Orders) { WriteToDebugLog($"{t.Symbol}"); } } } }
Rename
True, the maximum signal processing occurs after this point in the backtest run. I'm not sure I'd call it a bug but it's good to know the sequence here. Is there something you specially wanted to do in code with the maximum signals under consideration?
Thanks Glitch. I have a utility method I call in BacktestComplete to export signals of each day to a file and use that as historical backup and also use it to match positions on my broker account with my own script (something related to this https://www.wealth-lab.com/Discussion/Add-Trading-Preference-to-exit-position-based-on-executed-order-size-12192).
Is there a way to only return exactly the same signal list as on the Signals tab?
Is there a way to only return exactly the same signal list as on the Signals tab?
Your Response
Post
Edit Post
Login is required