- ago
With build 9, the backtest with SwingLo indicator no longer works.
Code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; using WealthLab.Community; namespace WealthScript1 { public class MyStrategy : UserStrategyBase {     public MyStrategy() : base() { } public override void Initialize(BarHistory bars) {       indicator1 = bars.Close;       indicator2 = new SwingLo(bars.Close,13,3.50,5,1.50,0.00,true,false,false,false);       PlotIndicator(indicator2,Color.FromArgb(255,0,0,0));          StartIndex = 0; } public override void Execute(BarHistory bars, int idx) {          int index = idx;          Position foundPosition0 = FindOpenPosition(0);          bool condition0;          if (foundPosition0 == null)          {             condition0 = false;             {                if (index - 0 >= 0 && indicator1[index] <= indicator2[index - 0])                {                   condition0 = true;                }             }             if (condition0)             {                _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0, "Buy At Market (1)");             }          }          else          {             condition0 = false;             {                condition0 = true;             }             if (condition0)             {                if (idx - foundPosition0.EntryBar + 1 >= 3)                {                   ClosePosition(foundPosition0, OrderType.Market, 0,"Sell after 3 bars");                }             }          } }    private TimeSeries indicator1;    private IndicatorBase indicator2;       private Transaction _transaction; } }
0
1,082
Solved
6 Replies

Reply

Bookmark

Sort
- ago
#1
This is a duplicate topic. Please repost and clarify what "no longer works" exactly:

https://www.wealth-lab.com/Discussion/SwingLo-SwingHi-SwingHiLo-indicators-5982
0
- ago
#2
You're right, this code and the QuickRef example no longer plot with this error
QUOTE:
"Specified argument was out of the range of valid values. (Parameter 'Index out of Range: ( SwingLo(Low,13,3.50,13,3.50,0.00,False,False,False,False), 10) ')"

I think the reason is some changes made to handling the numeric up/down values.

We'll look into fixing it soon, thanks.
0
- ago
#3
I think the topic title is a bit misleading. If I drop SwingLo, SwingHi or SwingHiLo with default parameters onto a chart it works in build 9. Changing the parameters in some way may make it disappear but it's the code problem, not Wealth-Lab's.
0
- ago
#4
The title is unfortunate. " Backtests with SwingLo indicator no longer work with build 9 " is better.
The indicator on a chart is working properly.
But I would also like to use this indicator in back tests.
0
- ago
#5
Issue confirmed. We'll look into it. Thanks.
0
- ago
#6
Please look forward to build 10 with a fix.
0
Best Answer

Reply

Bookmark

Sort