- ago
Hi,

I'm confirming Signal and Open Postion is the same

Output two TXT files, [PreExecute] and [Execute]

PreExecute_WL7_20010105.txt show Date 20010105 have ten symbols in buy list.

but into Backteset Results - Position tap sort by Entry Date

first Open Position on 2001/1/9, Why ?

I watch the SZ000039 symbol no signal on 2001/1/5 next bar

and missing a lot of signals from compare the two TXT files.

Chart:


Barcktest Results Position:


Code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; namespace WealthScript1 { public class Qs : UserStrategyBase {       static List<BarHistory> Buys = new List<BarHistory>();       double StdVal;       int idx;       TimeSeries _Std;       SMA _rSMA;       private TimeSeries opL;     //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars)       {          StartIndex = 100;          _rSMA = new SMA(bars.Close, StartIndex);          bars.Cache["_rSMA"] = _rSMA;          opL = new TimeSeries(bars.DateTimes); } public override void PreExecute(DateTime dt, List<BarHistory> participants) {          foreach (BarHistory bh in participants)          {             _Std = (SMA)bh.Cache["_rSMA"];             idx = GetCurrentIndex(bh);             StdVal = _Std[idx];             bh.UserData = Math.Round(StdVal, 3);          }          participants.Sort((a, b) => a.UserDataAsDouble.CompareTo(b.UserDataAsDouble)); //Lowest --> Highest          Buys.Clear();          for (int n = 0; n <= participants.Count - 1; n++)          {             if (Buys.Count == 10) break;             if ((participants[n].UserDataAsDouble).ToString() != "NaN")                Buys.Add(participants[n]);          }          FileStream fs = new FileStream(@"C:\Users\Administrator\Desktop\WL7_out\QS\WL7_" + dt.ToString("yyyyMMdd") + ".txt", FileMode.Create);          StreamWriter sw = new StreamWriter(fs);          sw.Write(" In Buy = ");          foreach (BarHistory _strB in Buys)          {             sw.Write("," + _strB.Symbol);          }          sw.Flush();          sw.Close();          fs.Close(); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) {          bool inBuyList = Buys.Contains(bars);          var BuyListPctEquity = CurrentEquity * 0.05 / bars.Close[idx - 1];          opL[idx] = OpenPositionsAllSymbols.Where(t => t.EntryTransactionType.ToString() == "Buy").Count();          opL[idx] += Backtester.Orders.Where(l => l.PositionType == PositionType.Long && l.IsEntry).Count();          FileStream fs = new FileStream(@"C:\Users\Administrator\Desktop\WL7_out\QS\P\WL7_Position_" + bars.GetDate(idx).ToString("yyyyMMdd") + ".txt", FileMode.Create);          StreamWriter sw = new StreamWriter(fs);          List<Position> positions = GetPositionsAllSymbols(true);          sw.Write(" Open = ");          foreach (Position pos in positions)          {             if (pos.PositionType.ToString() == "Long")                sw.Write("," + pos.Symbol);          }          sw.Flush();          sw.Close();          fs.Close();                    if (inBuyList && opL[idx] <= 19)          {             if (!HasOpenPosition(bars, PositionType.Long))             {                PlaceTrade(bars, TransactionType.Buy, OrderType.Market).Quantity = BuyListPctEquity;             }          }          else if(!inBuyList)          {             if (HasOpenPosition(bars, PositionType.Long))                ClosePosition(LastPosition, OrderType.Market);          } } } }


Strategy Setting:
0
1,247
Solved
13 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.32% )
- ago
#1
Instruments that have negative prices don't exist. You can't trade them in real life or in a simulation either.

===== Edit: =====
Granted, we may have to rethink reality after last year when for a short time they were paying you to take crude oil deliveries... and then there are the negative yields in Europe...
1
Best Answer
- ago
#2
@Cone

Hi,

I'll revise the dataset.

problems remain unsolved.

PreExecute_WL7_20000107.txt file

has ten symbols (SH600808,SZ000898,SH600688,SH600115,SH600685,SH600871,SH600876,SH600874,SZ000513,SH600860) in buy list.

no signal are displayed on the next trading day 2000 / 1 / 10

signal are displayed on 2000/1/11

Execute_WL7_Position_20000110.txt file is empty.



Backtest Results - Positions ( Sort by Entry Date)

and bars held unnormal.



strategy logic is checked several times.

Where is problem ?

Thx
0
- ago
#3
[Update]

Backtest Results - Positions ( Sort by Entry Date)

0
Cone8
 ( 6.32% )
- ago
#4
One thing I noticed was the message in the Strategy Settings that the "DataSet is linked to a Data Provider that does not natively support this Scale."

The Scale is Daily. What Data Provider are you using that doesn't support the Daily scale?
1
- ago
#5
Apparently, topic starter is using ASCII.
0
- ago
#6
@Cone @Eugene

Hi,

Is using ASCII.

The first time I checked, there were symbols bars count = 0

then delete these symbols

I double check dataset in Data Manager.

Sort ascending by bars count.



still shows doesn't support the Daily scale in Strategy Settings.

QUOTE:

The Scale is Daily. What Data Provider are you using that doesn't support the Daily scale?


How to check the problem ?

Thx.
0
- ago
#7
This issue is supposed to be fixed in build 26. I checked and you're running outdated builds 8 (!!!) and 21. Because they are not supported please upgrade both computers to the latest version.
1
- ago
#8
@Eugene

Hi,

Where can i upgrade to latest version?

reinstall ?



Thx.
0
- ago
#9
Yes, simply download the new installer from Software > Download.

After upgrading the other PC please also check the Home Page tool inside WL7 for any outdated extensions it may have and download their upgraded installers from this page:
https://www.wealth-lab.com/Extension
0
- ago
#10
QUOTE:
ConeA
Sep 30, 2021, 03:24 AM - 12 days ago
#1
Instruments that have negative prices don't exist. You can't trade them in real life or in a simulation either.

===== Edit: =====
Granted, we may have to rethink reality after last year when for a short time they were paying you to take crude oil deliveries... and then there are the negative yields in Europe...
1 Best Answer


What about spreads (I'm guessing you can set up custom tickers for spreads, e.g. TM - 3*HMC)?
0
Cone8
 ( 6.32% )
- ago
#11
Wealth-Lab does not support negative prices. It will take a popular feature request to change that.
0
fred99998
 ( 20.34% )
- ago
#12
QUOTE:
Wealth-Lab does not support negative prices.


Then you won't be able to test strategies on some backadjusted futures.
In futures markets that spend a large time in backwardation, the back-adjustment process can cause historical prices to be pushed into negative territory.
0
Cone8
 ( 6.32% )
- ago
#13
That's right.
There are about a half-dozen methods you can use to back-adjust futures, and I wouldn't use any of them for backtesting. Use the continuous contract for the non-adjusted, real prices and a meta data file to trigger rollovers. Close and re-open positions on the rollover, just like you'd have to do for real trading.
1

Reply

Bookmark

Sort