"if (LastPosition == null)" stopped working. The systems work only until the first trade.
Sample from example code:
Sample from example code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.ChartWPF; using System.Drawing; using System.Collections.Generic; namespace WealthScript5 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { cmo = new CMO(bars.Close, 14); PlotIndicator(cmo); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (LastPosition == null) { WriteToDebugLog(bars.DateTimes[idx].ToShortDateString()); if (cmo.CrossesOver(cmo.OversoldLevel, idx)) PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } else { Position p = LastPosition; //exit after 3 days if (idx + 1 - p.EntryBar >= 3) ClosePosition(p, OrderType.Market); } } //declare private variables below private CMO cmo; } }
Rename
Yes, this is a breaking change in Build 7 (4/20/2021)
https://www.wealth-lab.com/Software/ChangeLog
* Changed LastPosition to return the last Position, whether it's open or closed. Added LastOpenPosition to return the last open Position.
https://www.wealth-lab.com/Software/ChangeLog
* Changed LastPosition to return the last Position, whether it's open or closed. Added LastOpenPosition to return the last open Position.
Understood thanks
Your Response
Post
Edit Post
Login is required