DataSet have only two symbols.
Have added symbol 3 to list, why not buy symbol 3 ?
Debug Log : DATE = yyyy/MM/dd ADD SYMBOL = 3
Have added symbol 3 to list, why not buy symbol 3 ?
Debug Log : DATE = yyyy/MM/dd ADD SYMBOL = 3
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript1 { public class A28_strategy : UserStrategyBase { List<BarHistory> Buys = new List<BarHistory>(); TimeSeries _Ts_SMA; BarHistory Treasury_Index; double _TE_val; public A28_strategy() { AddParameter(" Window ", ParameterTypes.Int32, 5, 5, 60, 1); } public override void Initialize(BarHistory bars) { StartIndex = Parameters[0].AsInt; _Ts_SMA = SMA.Series(bars.Close, 10); bars.Cache["Data"] = _Ts_SMA; PlotTimeSeries(_Ts_SMA, "SMA", "Pane"); } public override void PreExecute(DateTime dt, List<BarHistory> participants) { if (participants.Count != 2) return; foreach (BarHistory bh in participants) { TimeSeries _TE = (TimeSeries)bh.Cache["Data"]; int idx = GetCurrentIndex(bh); _TE_val = _TE[idx]; bh.UserData = _TE_val; } participants.Sort((a, b) => -a.UserDataAsDouble.CompareTo(b.UserDataAsDouble)); Buys.Clear(); for (int n = 0; n < 1; n++) { if (n >= participants.Count) break; WriteToDebugLog(" DATE = " + dt.ToString("yyyy/MM/dd") + " ADD SYMBOL = " + participants[n].Symbol); Buys.Add(participants[n]); } } public override void Execute(BarHistory bars, int idx) { bool _BuyList = Buys.Contains(bars); if (_BuyList) { WriteToDebugLog(" BUY LIST SYMBOL = " + bars.Symbol); if (!HasOpenPosition(bars, PositionType.Long)) PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } else if (!_BuyList) { if (HasOpenPosition(bars, PositionType.Long)) ClosePosition(LastPosition, OrderType.Market); } } } }
Rename
Re: "Where is the problem ?" topic title. For your future record, try summarizing the issue you're having without the non-descriptive words like question, issue, problem, urgent etc. As a wise man's question contains half the answer, it would help you and other users leverage the forum search to find answers.
QUOTE:
why not buy symbol 3 ?
Because there's not enough capital to buy it (price too large, position size too small)?
This processes only one symbol, is this intentional?
CODE:
for (int n = 0; n < 1; n++)
QUOTE:
This processes only one symbol, is this intentional?
Yes, only one add to List
and have printed DATE = yyyy/MM/dd ADD SYMBOL = 3 in Debug Log.
How many NSF trades does the system take?
QUOTE:
Because there's not enough capital to buy it (price too large, position size too small)?
And NSF?
QUOTE:
And NSF?
Try opening the strategy again after you add a new symbol to the DataSet. Or, to force a data reload, click the text at the bottom of the Strategy window that says "N symbols loaded".
QUOTE:
Try opening the strategy again after you add a new symbol to the DataSet. Or, to force a data reload, click the text at the bottom of the Strategy window that says "N symbols loaded".
Yes, click that "2 symbols loaded". It will cause WL7 to reload the data the next time you run the backtest. If you added a new symbol to the DataSet, it will then say "3 symbols loaded."
i’m having a hard time understanding what you’re trying to communicate with the screen shot?
QUOTE:
i’m having a hard time understanding what you’re trying to communicate with the screen shot?
I missed a photo.
Added a new symbol to the dataset than opening strategy again.
Your two accounts changhengyiu and changhengyiu1 seem to be running outdated builds of Wealth-Lab i.e. 8 (!) and 12. Before anything else, please update both installations to build 15 and also all extensions that they may be using to the latest builds. This should also fix the Contribution visualizer error (https://www.wealth-lab.com/Discussion/Error-populating-Contribution-visualizer-in-build-15-6617) which I noticed on your other screenshot in Post #12.
Your Response
Post
Edit Post
Login is required