The following code creates a handful of trades with "ExitText" as Exit Signal. When you run it on the DOW 30 for 08/15/2020 to 09/02/2020 with 19,9% of equity, you will get trades including RTX, XOM, or PFE, which left the DOW 30 on 08/28/2020. If a trade with these symbols is open on 08/28/2020, the trade is closed automatically (not by the regular ClosePosition), visible by the missing "ExitText" in the Exit Signal column in "Positions".
Trying to sort the positions by clicking on "Exit Signal" results in the error message:
InvalidOperationException: Failed to compare two elements in the array.
and the closing of WealthLab (if not using "Continue").
Example code:
Trying to sort the positions by clicking on "Exit Signal" results in the error message:
InvalidOperationException: Failed to compare two elements in the array.
and the closing of WealthLab (if not using "Continue").
Example code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { public MyStrategy() : base() { } public override void Initialize(BarHistory bars) { StartIndex = 0; } public override void Execute(BarHistory bars, int idx) { int index = idx; Position foundPosition0 = FindOpenPosition(0); bool condition0; if (foundPosition0 == null) { condition0 = false; { condition0 = true; } if (condition0) { _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0); } } else { condition0 = false; { condition0 = true; } if (condition0) { ClosePosition(foundPosition0, OrderType.Market, 0, "ExitText"); } } } private Transaction _transaction; } }
Rename
Thanks, we'll get this fixed for Build 6.
Thank you. Problem is fixed with Build 6.
Your Response
Post
Edit Post
Login is required