KAMA indicator is not functioning and produces following error
"Initialize Exception (VYM) Line 21 - The type initializer for '
' threw an exception.
at WealthLab.AdvancedSmoothers.KAMA.Populate()
at WealthLab.AdvancedSmoothers.KAMA..ctor(TimeSeries source, Int32 er, Int32 fast, Int32 slow)
at WealthScript8.MyStrategy.Initialize(BarHistory bars) in :line 21
at WealthLab.Backtest.UserStrategyExecutor.FillStub(List`1 symbols)"
"Initialize Exception (VYM) Line 21 - The type initializer for '
' threw an exception.
at WealthLab.AdvancedSmoothers.KAMA.Populate()
at WealthLab.AdvancedSmoothers.KAMA..ctor(TimeSeries source, Int32 er, Int32 fast, Int32 slow)
at WealthScript8.MyStrategy.Initialize(BarHistory bars) in :line 21
at WealthLab.Backtest.UserStrategyExecutor.FillStub(List`1 symbols)"
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; using WealthLab.AdvancedSmoothers; namespace WealthScript8 { public class MyStrategy : UserStrategyBase { public MyStrategy() : base() { } public override void Initialize(BarHistory bars) { indicator = new KAMA(bars.Close,10,2,30); PlotIndicator(indicator,Color.FromArgb(255,0,0,0)); indicator2 = new KAMA(bars.Close,10,2,30); StartIndex = 10; } public override void Execute(BarHistory bars, int idx) { int index = idx; Position foundPosition0 = FindOpenPosition(0); bool condition0; if (foundPosition0 == null) { condition0 = false; { if (indicator.CrossesUnder(0.00, index)) { condition0 = true; } } if (condition0) { _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0, "Buy At Market (1)"); } } else { condition0 = false; { if (indicator2.CrossesOver(0.00, index)) { condition0 = true; } } if (condition0) { ClosePosition(foundPosition0, OrderType.Market, 0, "Sell At Market (1)"); } } } private IndicatorBase indicator; private IndicatorBase indicator2; private Transaction _transaction; } }
Rename
Should't backtesting start at bar 30 rather than 10 given the KAMA slow period is 30?
CODE:
//StartIndex = 10; StartIndex = 30;
I'm not seeing the exception with your code, or with KAMA in general. What version of Advanced Smoothers are you using (check the Help, About box)?
I can reproduce it in production build (but StartIndex apparently isn't the culprit here).
Using Advanced Smoothers build 2. Problem showed up after updating everything to the latest
Simply put, something went wrong during build. Fixed in Advanced Smoothers build 3, to be released together with WL7 build 18. Sorry for the inconvenience.
Your Response
Post
Edit Post
Login is required