All my strategy has same same error. Could you tell me what is the problem?
11: The type or namespace name 'WealthScript' could not be found (are you missing a using directive or an assembly refer
11: The type or namespace name 'WealthScript' could not be found (are you missing a using directive or an assembly refer
Rename
Please show complete source code of your strategy.
Is this a "good" installation of WL?
Did you try to reinstall in an empty folder?
Is this a "good" installation of WL?
Did you try to reinstall in an empty folder?
Coud you tekk me what does it mean? — Is this a "good" installation of WL?
Compiled at 3/11/2023 17:19:35
11: The type or namespace name 'WealthScript' could not be found (are you missing a using directive or an assembly reference?)
20: 'MaxMinStop.Execute()': no suitable method found to override
13: The type or namespace name 'StrategyParameter' could not be found (are you missing a using directive or an assembly reference?)
17: The name 'CreateParameter' does not exist in the current context
22: The name 'Bars' does not exist in the current context
24: The name 'High' does not exist in the current context
25: The name 'Low' does not exist in the current context
26: The name 'MarketPosition' does not exist in the current context
27: The name 'Bars' does not exist in the current context
28: The name 'Portfolio' does not exist in the current context
32: The name 'MarketPosition' does not exist in the current context
34: The name 'Bars' does not exist in the current context
37: The name 'BuyAtStop' does not exist in the current context
38: The name 'Print' does not exist in the current context
39: The name 'MarketPosition' does not exist in the current context
44: The name 'Bars' does not exist in the current context
47: The name 'ExitAtStop' does not exist in the current context
47: The name 'MarketPosition' does not exist in the current context
48: The name 'Print' does not exist in the current context
49: The name 'MarketPosition' does not exist in the current context
54: The name 'MarketPosition' does not exist in the current context
56: The name 'ExitAtMarket' does not exist in the current context
56: The name 'bar' does not exist in the current context
57: The name 'Print' does not exist in the current context
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 { public class MaxMinStop : WealthScript { private StrategyParameter period; public MaxMinStop() { period = CreateParameter("Period", 3, 1, 10, 1); } protected override void Execute() { int bars = Bars.Count; int sessionBars = bars / (int)period.Value; var highest = Highest.Series(High, sessionBars); var lowest = Lowest.Series(Low, sessionBars); var position = MarketPosition.None; var tickSize = Bars.Info.TickSize; var portfolio = Portfolio; for (int bar = sessionBars; bar < bars; bar++) { if (position == MarketPosition.None) { if (Bars.Close[bar] >= highest[bar - sessionBars]) { var stopPrice = Math.Round(highest[bar - sessionBars] + 1 * tickSize, MidpointRounding.AwayFromZero); var ticket = BuyAtStop(bar + 1, stopPrice, "Buy at Stop"); Print("BUY at " + stopPrice.ToString() + " Stop"); position = MarketPosition.Long; } } else { if (Bars.Close[bar] <= lowest[bar - sessionBars]) { var stopPrice = Math.Round(lowest[bar - sessionBars] - 1 * tickSize, MidpointRounding.AwayFromZero); ExitAtStop(MarketPosition.Long, bar + 1, stopPrice, "Exit at Stop"); Print("SELL at " + stopPrice.ToString() + " Stop"); position = MarketPosition.None; } } } if (position == MarketPosition.Long) { ExitAtMarket(bar + 1, "Exit at Close"); Print("SELL at Close"); } } } }
Compiled at 3/11/2023 17:19:35
11: The type or namespace name 'WealthScript' could not be found (are you missing a using directive or an assembly reference?)
20: 'MaxMinStop.Execute()': no suitable method found to override
13: The type or namespace name 'StrategyParameter' could not be found (are you missing a using directive or an assembly reference?)
17: The name 'CreateParameter' does not exist in the current context
22: The name 'Bars' does not exist in the current context
24: The name 'High' does not exist in the current context
25: The name 'Low' does not exist in the current context
26: The name 'MarketPosition' does not exist in the current context
27: The name 'Bars' does not exist in the current context
28: The name 'Portfolio' does not exist in the current context
32: The name 'MarketPosition' does not exist in the current context
34: The name 'Bars' does not exist in the current context
37: The name 'BuyAtStop' does not exist in the current context
38: The name 'Print' does not exist in the current context
39: The name 'MarketPosition' does not exist in the current context
44: The name 'Bars' does not exist in the current context
47: The name 'ExitAtStop' does not exist in the current context
47: The name 'MarketPosition' does not exist in the current context
48: The name 'Print' does not exist in the current context
49: The name 'MarketPosition' does not exist in the current context
54: The name 'MarketPosition' does not exist in the current context
56: The name 'ExitAtMarket' does not exist in the current context
56: The name 'bar' does not exist in the current context
57: The name 'Print' does not exist in the current context
This looks like a WL6 strategy? They’re not compatible with WL7/8.
What I need to change in this strategy to work in version 8?
Here is a conversion for you:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //constructor public MyStrategy() : base() { AddParameter("Session Bars", ParameterType.Int32, 3, 1, 10, 1); } //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { sessionBars = Parameters[0].AsInt; tickSize = bars.SymbolInfo == null ? 0.01 : bars.SymbolInfo.TickSize; hh = Highest.Series(bars.High, sessionBars); ll = Lowest.Series(bars.Low, sessionBars); PlotIndicator(hh); PlotIndicator(ll); PlotStopsAndLimits(); StartIndex = sessionBars; } //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 (LastOpenPosition == null) { if (bars.Close[idx] >= hh[idx - sessionBars]) { double stopPrice = Math.Round(hh[idx - sessionBars] + 1 * tickSize, MidpointRounding.AwayFromZero); PlaceTrade(bars, TransactionType.Buy, OrderType.Stop, stopPrice, "Buy at Stop"); WriteToDebugLog("Buy at Stop: " + stopPrice); } } else { if (bars.Close[idx] <= ll[idx - sessionBars]) { double stopPrice = Math.Round(ll[idx - sessionBars] - 1 * tickSize, MidpointRounding.AwayFromZero); PlaceTrade(bars, TransactionType.Sell, OrderType.Stop, stopPrice, "Sell at Stop"); WriteToDebugLog("Sell at Stop: " + stopPrice); } } } //declare private variables below private int sessionBars; private Highest hh; private Lowest ll; private double tickSize; } }
It's working.
Thank you so much
Thank you so much
Your Response
Post
Edit Post
Login is required