Hello,
why does the error message come when I press Run Backtest.
The error occurs from the second attempt. The first time everything works normally.
I have 2 times buy at market. And use the index as a switch.
Greetings
Hans
why does the error message come when I press Run Backtest.
The error occurs from the second attempt. The first time everything works normally.
I have 2 times buy at market. And use the index as a switch.
Greetings
Hans
Rename
We cannot determine it from that image.
Hit the "Open as C# Code" button and post the result.
Hit the "Open as C# Code" button and post the result.
What I noticed now is that when I change a parameter and then do a backtest, the error message comes up.
After opening the strategy and immediately performing the backtest, everything works.
After opening the strategy and immediately performing the backtest, everything works.
1. What parameter are you changing, precisely?
2. How exactly do you change it, in C# code or in Blocks?
Post the C# code of the failing strategy.
2. How exactly do you change it, in C# code or in Blocks?
Post the C# code of the failing strategy.
When posting code, please copy and paste the text out of the editor, not screen shots. Much appreciated!
You can use the Code button above to create a format block, and paste the code between the two blocks.
You can use the Code button above to create a format block, and paste the code between the two blocks.
I have now done the coding after the error message. It was changed the parameters of ConsecDown from 2 to 3 Value.
I have tested this now on another Stategien whether also here the same error message appears.
I have tested this now on another Stategien whether also here the same error message appears.
When posting code, please copy and paste the text out of the editor, not screen shots. Much appreciated!
You can use the Code button above to create a format block, and paste the code between the two blocks.
You can use the Code button above to create a format block, and paste the code between the two blocks.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript4 { public class MyStrategy : UserStrategyBase { public MyStrategy() : base() { AddParameter("Value Consec Down", ParameterType.Double, 3, 1, 5, 1); AddParameter("Value StochD", ParameterType.Double, 53, 5, 60, 1); AddParameter("Period", ParameterType.Int32, 132, 1, 200, 1); AddParameter("How many Bars?", ParameterType.Int32, 3, 1, 10, 1); AddParameter("Value Exit 1", ParameterType.Double, 2, 1, 5, 1); AddParameter("Bar Range Close Low", ParameterType.Int32, 3, 1, 25, 1); AddParameter("ATR 1 Period", ParameterType.Int32, 46, 1, 50, 1); AddParameter("is Percentage", ParameterType.Double, 0.4, 0, 5, 0.1); AddParameter("ATR2 ", ParameterType.Int32, 24, 1, 50, 1); AddParameter("How many Bars ago", ParameterType.Int32, 2, 1, 30, 1); AddParameter("Period2", ParameterType.Int32, 132, 1, 200, 1); AddParameter("How many Bars? 2", ParameterType.Int32, 2, 1, 10, 1); StartIndex = 132; } public override void Initialize(BarHistory bars) { indicator = new ConsecDown(bars.Close,1); PlotIndicator(indicator,new WLColor(0,0,0)); _startIndexList.Add(indicator); indicator2 = new StochD(bars,1,2); PlotIndicator(indicator2,new WLColor(0,0,255)); _startIndexList.Add(indicator2); weight = new RSI(bars.Close,5); PlotIndicator(weight,new WLColor(255,0,0)); _startIndexList.Add(weight); externalSymbol = GetHistory(bars, "SPY"); indicator1 = externalSymbol.Close; indicator22 = new SMA(externalSymbol.Close,Parameters[2].AsInt); PlotIndicator(indicator22,new WLColor(0,128,0),default,default,"SPYPane"); _startIndexList.Add(indicator22); indicator3 = new ConsecUp(bars.Close,1); PlotIndicator(indicator3,new WLColor(255,165,0)); _startIndexList.Add(indicator3); ind = bars.Close; weight2 = new RSI(bars.Close,6); PlotIndicator(weight2,new WLColor(128,128,0)); _startIndexList.Add(weight2); indicator12 = new ATR(bars,Parameters[6].AsInt); PlotIndicator(indicator12,new WLColor(128,0,128)); _startIndexList.Add(indicator12); indicator23 = new ATR(bars,Parameters[8].AsInt); PlotIndicator(indicator23,new WLColor(0,255,255)); _startIndexList.Add(indicator23); externalSymbol2 = GetHistory(bars, "SPY"); indicator13 = externalSymbol2.Close; indicator24 = new SMA(externalSymbol2.Close,Parameters[10].AsInt); _startIndexList.Add(indicator24); foreach(IndicatorBase ib in _startIndexList) if (ib.FirstValidIndex > StartIndex) StartIndex = ib.FirstValidIndex; } public override void Execute(BarHistory bars, int idx) { int index = idx; Position foundPosition0 = FindOpenPosition(0); bool condition0; if (foundPosition0 == null) { condition0 = false; { if (indicator[index] >= Parameters[0].AsDouble) { if (indicator2[index] < Parameters[1].AsDouble) { { if (index - 1 >= 0 && indicator1[index] > indicator22[index - 1]) { condition0 = true; } } } } } if (condition0) { Backtester.CancelationCode = 1; _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0, "Buy At Market (1)"); _transaction.Weight = weight[index] * -1; } } else { condition0 = false; { condition0 = true; } if (condition0) { Backtester.CancelationCode = 1; if (idx - foundPosition0.EntryBar + 1 >= Parameters[3].AsInt) { ClosePosition(foundPosition0, OrderType.Market, 0,"Sell after 3 bars"); } } condition0 = false; { if (indicator3[index] >= Parameters[4].AsDouble) { condition0 = true; } } if (condition0) { Backtester.CancelationCode = 1; ClosePosition(foundPosition0, OrderType.Market, 0, "Sell At Market (1)"); } } Position foundPosition1 = FindOpenPosition(1); bool condition1; if (foundPosition1 == null) { condition1 = false; { if (ind[index] == ind.GetLowest(index, Parameters[5].AsInt)) { { if (index - Parameters[9].AsInt >= 0 && (indicator12[index] < indicator23[index - Parameters[9].AsInt] * (1.0 - (Parameters[7].AsDouble / 100.0)))) { if (index - 1 >= 0 && indicator13[index] < indicator24[index - 1]) { condition1 = true; } } } } } if (condition1) { Backtester.CancelationCode = 2; _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 1, "Buy At Market (2)"); _transaction.Weight = weight[index] * -1; } } else { condition1 = false; { condition1 = true; } if (condition1) { Backtester.CancelationCode = 2; if (idx - foundPosition1.EntryBar + 1 >= Parameters[11].AsInt) { ClosePosition(foundPosition1, OrderType.Market, 0,"Sell after 2 bars"); } } } } public override void NewWFOInterval(BarHistory bars) { indicator = new ConsecDown(bars.Close,1); indicator = new ConsecDown(bars.Close,1); indicator2 = new StochD(bars,1,2); indicator2 = new StochD(bars,1,2); weight = new RSI(bars.Close,5); weight = new RSI(bars.Close,5); externalSymbol = GetHistory(bars, "SPY"); indicator1 = externalSymbol.Close; indicator22 = new SMA(externalSymbol.Close,Parameters[2].AsInt); externalSymbol = GetHistory(bars, "SPY"); indicator1 = externalSymbol.Close; indicator22 = new SMA(externalSymbol.Close,Parameters[2].AsInt); indicator3 = new ConsecUp(bars.Close,1); indicator3 = new ConsecUp(bars.Close,1); ind = bars.Close; ind = bars.Close; weight2 = new RSI(bars.Close,6); weight2 = new RSI(bars.Close,6); indicator12 = new ATR(bars,Parameters[6].AsInt); indicator23 = new ATR(bars,Parameters[8].AsInt); indicator12 = new ATR(bars,Parameters[6].AsInt); indicator23 = new ATR(bars,Parameters[8].AsInt); externalSymbol2 = GetHistory(bars, "SPY"); indicator13 = externalSymbol2.Close; indicator24 = new SMA(externalSymbol2.Close,Parameters[10].AsInt); externalSymbol2 = GetHistory(bars, "SPY"); indicator13 = externalSymbol2.Close; indicator24 = new SMA(externalSymbol2.Close,Parameters[10].AsInt); } private IndicatorBase indicator; private IndicatorBase indicator2; private IndicatorBase weight; private TimeSeries indicator1; private IndicatorBase indicator22; private BarHistory externalSymbol; private IndicatorBase indicator3; private TimeSeries ind; private IndicatorBase weight2; private IndicatorBase indicator12; private IndicatorBase indicator23; private TimeSeries indicator13; private IndicatorBase indicator24; private BarHistory externalSymbol2; private Transaction _transaction; private List<IndicatorBase> _startIndexList = new List<IndicatorBase>(); } }
Allow me to edit that for you to put in the CODE tags I mentioned above.
I changed the Consec Down parameter several times and am not getting an error running the Strategy. Can you export the Strategy that is failing and email it to us at support@wealth-lab.com? The export will produce an XML file that you can attach to the email.
I also noticed that in the code strategy the error message does not appear. I will send you the XML file.
Yesterday I had changed the parameters in the block dozens of times where nothing happened. Thought already fits now again and suddenly the error message was there again after a change.
I believe that this is related to the blocks with the index SPY. Is used in both Buy at Market. With different defaults.
Yesterday I had changed the parameters in the block dozens of times where nothing happened. Thought already fits now again and suddenly the error message was there again after a change.
I believe that this is related to the blocks with the index SPY. Is used in both Buy at Market. With different defaults.
We were able to determine the issue and fixed this for Build 50. You'll need to click the optimize button again on the Sell after N Bars exits (both of them) and then save the Strategy again. Let us know how it goes after Build 50 is released.
Your Response
Post
Edit Post
Login is required