- ago
Hello everyone!
Would anyone know why I am getting this error in the Initialize below?

QUOTE:
System.InvalidOperationException
HResult=0x80131509
Message=Invalid date sequencing: 02/01/2023 17:00 to 02/01/2023 17:00
Source=WealthLab.Core
StackTrace:
at WealthLab.Core.TimeSeriesBase.DetermineScale()
at WealthLab.Core.TimeSeriesSynchronizer.Synchronize(TimeSeries source, TimeSeriesBase master, Nullable`1 preFillNans, MarketDetails market)
at Biblioteca.Magic.Initialize(BarHistory bars) at D:\csharp-projects\weatlh-lab-2024\Weatlh-lab-2024\Biblioteca\Strat.cs:linha 141
at WealthLab.Backtest.UserStrategyExecutor.CalculateAttr(List`1 symbols)



141 line:

CODE:
rsiClose20 = TimeSeriesSynchronizer.Synchronize( RSI.Series(higherScaleBarsCompressed.Close, 20), bars.Open );



CODE:
public override void Initialize(BarHistory bars) { // Sync the indicators from other scales? //* Create temporary series, plot charts, access parameters, etc. averageScaleBars = BarHistorySynchronizer.Synchronize( BarHistoryCompressor.ToHour(bars, 1), bars.Open ); if (Parameters[1].AsInt == 1) { PlotAverageBars(); } //* 100-period EMA for M15 trendEMA = EMA.Series(bars.Close, 100); PlotTimeSeriesLine(trendEMA, $"EMA(Close, {100})", "Price"); //* Trading hours americanMarketHours = MarketHours.Series( bars.Close, MarketGroups.America_USD_CAD, 1 ); europeanMarketHours = MarketHours.Series( bars.Close, MarketGroups.Europe_EUR_GBP_CHF, 1 ); asianMarketHours = MarketHours.Series( bars.Close, MarketGroups.Asia_AUD_JPY_NZD, 1 ); // Plot trading hours if (Parameters[0].AsInt == 1) { PlotMarketHours(); } //* Plot MACD for M15 macd = EMA.Series(bars.Close, 12) - EMA.Series(bars.Close, 26); macdSignalLine = EMA.Series(macd, 9); macdHistogram = macd - macdSignalLine; if (Parameters[4].AsInt == 1) { var shortPeriod = 12; var longPeriod = 26; var signalPeriod = 9; PlotMACD(bars, shortPeriod, longPeriod, signalPeriod); } //* RSI Close 20 on H4 var higherScaleBarsCompressed = BarHistoryCompressor.ToHour(bars, 4); higherScaleBars = BarHistorySynchronizer.Synchronize( higherScaleBarsCompressed, bars.Open ); // Between 45 and 55 is ranged. Higher than 55 is uptrend. Lower than 45 is downtrend. rsiClose20 = TimeSeriesSynchronizer.Synchronize( RSI.Series(higherScaleBarsCompressed.Close, 20), bars.Open ); if (Parameters[5].AsInt == 1) { PlotTimeSeriesLine(rsiClose20, "RSI(Close, 20) H4", "RSI", WLColor.Blue); } //* TrendScore on H4 // The trend is uptrend when the TrendScore is equal to 10. The trend is downtrend when the TrendScore is equal to -10. trendScore = TimeSeriesSynchronizer.Synchronize( TrendScore.Series(higherScaleBarsCompressed), bars.Open ); if (Parameters[6].AsInt == 1) { PlotTimeSeriesLine(trendScore, "TrendScore H4", "TrendScore", WLColor.Blue); } //* Draw stop and target lines PlotStopsAndLimits(4); }
0
431
Solved
9 Replies

Closed

Bookmark

Sort
- ago
#1
Probably because of somewhat defective intraday ASCII, see this:

Error Parsing ASCII Data: Invalid date sequencing

It's an open issue at the moment.
0
- ago
#2
QUOTE:
Message=Invalid date sequencing: 02/01/2023 17:00 to 02/01/2023 17:00

If the data is ASCII, you can open the file in a text editor and fix the bad data manually.
0
- ago
#3
Strange... the data seems okay to me.

*I emailed the csv file in question to support@wealth-lab.com.



CODE:
20230102,16:58:00,1.06559,1.06571,1.06553,1.06557,91.5199997723103 20230102,16:59:00,1.06558,1.06579,1.06544,1.06545,492.96999720484 20230102,17:00:00,1.06545,1.06579,1.06539,1.06574,285.049997650087 20230102,17:01:00,1.06574,1.0658,1.06574,1.06577,31.4899998158216 20230102,17:02:00,1.06577,1.06593,1.06577,1.06593,44.8699998557568 20230102,17:03:00,1.06594,1.06611,1.06593,1.06608,151.279999352992 20230102,17:04:00,1.06608,1.0661,1.06601,1.06608,90.0999992489815 20230102,17:05:00,1.06608,1.06618,1.06597,1.06609,234.559998825192 20230102,17:06:00,1.06614,1.06619,1.06586,1.06595,380.989998556674 20230102,17:07:00,1.06592,1.06608,1.0659,1.06596,184.499996967614 20230102,17:08:00,1.06595,1.06604,1.06582,1.06589,209.219998173416 20230102,17:09:00,1.06589,1.06605,1.06589,1.06605,39.6399999186397 20230102,17:10:00,1.06605,1.06612,1.06605,1.06605,24.2999999597669 20230102,17:11:00,1.06605,1.06605,1.06599,1.06599,19.119999602437 20230102,17:12:00,1.06599,1.06602,1.06585,1.06588,116.749999500811 20230102,17:13:00,1.06587,1.06591,1.06585,1.0659,56.7999994009733 20230102,17:14:00,1.06591,1.06594,1.06591,1.06594,23.7399995997548 20230102,17:15:00,1.06596,1.066,1.06583,1.06593,106.099999621511 20230102,17:16:00,1.06592,1.06595,1.0658,1.06591,85.0199988335371 20230102,17:17:00,1.0659,1.06591,1.06586,1.06589,12.4199999570847 20230102,17:18:00,1.06585,1.06588,1.06584,1.06584,15.3799998983741 20230102,17:19:00,1.06584,1.0659,1.06584,1.06586,12.5699999034405 20230102,17:20:00,1.06587,1.06592,1.06585,1.06587,23.7099997848272 20230102,17:21:00,1.06587,1.06611,1.06585,1.06599,92.3200005069375 20230102,17:22:00,1.06599,1.06605,1.06595,1.06595,221.759999394417 20230102,17:23:00,1.06594,1.06605,1.06591,1.06597,119.360000364482 20230102,17:24:00,1.066,1.06608,1.06595,1.06595,242.469998590648 20230102,17:25:00,1.06601,1.06601,1.06596,1.06596,62.3600003421307 20230102,17:26:00,1.06597,1.06604,1.06595,1.06598,80.4199999049306 20230102,17:27:00,1.06602,1.06603,1.06596,1.06597,39.5999997854233 20230102,17:28:00,1.06597,1.06602,1.06589,1.06595,140.399999022484 20230102,17:29:00,1.06603,1.06604,1.06589,1.06591,136.79999768734 20230102,17:30:00,1.06597,1.06601,1.06588,1.06599,224.179999351501 20230102,17:31:00,1.06595,1.06602,1.06586,1.06592,224.789997920394 20230102,17:32:00,1.06588,1.066,1.06588,1.06592,50.399999499321 20230102,17:33:00,1.06596,1.06596,1.06589,1.06594,59.8400003910065 20230102,17:34:00,1.06592,1.06597,1.06592,1.06596,39.6000001430511 20230102,17:35:00,1.06595,1.06596,1.06594,1.06594,27 20230102,17:36:00,1.06594,1.06595,1.06592,1.06594,31.5000003576279 20230102,17:37:00,1.06604,1.06607,1.0659,1.06597,90.3299992009997 20230102,17:38:00,1.06596,1.06609,1.06591,1.06599,32.8699997365475 20230102,17:39:00,1.06597,1.06598,1.06596,1.06597,5.5599998831749 20230102,17:40:00,1.06597,1.06604,1.06595,1.06601,28.1999998092651 20230102,17:41:00,1.06598,1.06605,1.06598,1.06603,52.9899994805455 20230102,17:42:00,1.06602,1.06603,1.066,1.06602,107.959999419749 20230102,17:43:00,1.06602,1.06602,1.066,1.066,53.1000003814697 20230102,17:44:00,1.06602,1.06602,1.06599,1.066,16.1999999284744 20230102,17:45:00,1.06601,1.06602,1.066,1.06601,24.3000000715256 20230102,17:46:00,1.06602,1.06602,1.06598,1.06601,24.4799997806549 20230102,17:47:00,1.066,1.06601,1.06595,1.06598,90.1000000238419 20230102,17:48:00,1.06598,1.06604,1.06594,1.06596,75.099999897182 20230102,17:49:00,1.06597,1.06601,1.06595,1.066,68.5199999734759 20230102,17:50:00,1.066,1.066,1.06596,1.06596,9 20230102,17:51:00,1.06595,1.06608,1.06593,1.06594,63.4599998891354 20230102,17:52:00,1.06594,1.06603,1.0659,1.06598,208.829999491572 20230102,17:53:00,1.06598,1.066,1.06596,1.06598,58.5 20230102,17:54:00,1.06597,1.06602,1.0659,1.06597,70.7599997445941 20230102,17:55:00,1.06596,1.06597,1.06595,1.06596,49.5 20230102,17:56:00,1.06597,1.06598,1.06586,1.06593,295.600000321865 20230102,17:57:00,1.06592,1.06594,1.06589,1.06589,126 20230102,17:58:00,1.0659,1.06601,1.06584,1.06598,184.759999386966 20230102,17:59:00,1.06598,1.06608,1.06587,1.06599,328.95999905467 20230102,18:00:00,1.06601,1.06604,1.06598,1.06602,379.34999986738 20230102,18:01:00,1.06601,1.06604,1.06599,1.06602,199.800000429153 20230102,18:02:00,1.06601,1.06601,1.06599,1.06601,13.9599999040365 20230102,18:03:00,1.066,1.066,1.06599,1.06599,5.1700000166893 20230102,18:04:00,1.06606,1.06606,1.066,1.06601,8.99999988079071 20230102,18:05:00,1.066,1.06605,1.06592,1.06594,51.0400002598763




0
Glitch8
 ( 9.28% )
- ago
#4
Can you post the COMPLETE Strategy? I can't get it working with only your Initialize method.
0
- ago
#5
Here is a code that is resulting in the same error. I am inspecting the variables at the moment and manually performing the calculation to understand what is wrong.

CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace Biblioteca { internal class MultiScale : UserStrategyBase { TimeSeries rsiClose20; TimeSeries trendScore; public MultiScale() { } public override void Initialize(BarHistory bars) { var compClose_H4 = TimeSeriesCompressor.ToMinute(bars.Close, 45, bars.Market); var rsiClose20_H4 = RSI.Series(compClose_H4, 20); rsiClose20 = TimeSeriesSynchronizer.Synchronize(rsiClose20_H4, bars); PlotTimeSeriesLine(rsiClose20, "RSI(Close, 20) H4", "RSI", WLColor.Blue); } public override void PreExecute(DateTime dt, List<BarHistory> participants) { } public override void Execute(BarHistory bars, int idx) { } public override void PostExecute(DateTime dt, List<BarHistory> participants) { } public override void AssignAutoStopTargetPrices( Transaction t, double basisPrice, double executionPrice ) { } public override void Cleanup(BarHistory bars) { } public override void BacktestComplete() { } } }


I believe it has something to do with Market:MarketDetails. Here is the start of the DateTimes vector after TimeSeriesCompressor.ToMinute. At a certain point, the date starts to repeat.

QUOTE:
"18/12/2023 00:45:00"
"18/12/2023 02:00:00"
"18/12/2023 03:30:00"
"18/12/2023 05:00:00"
"18/12/2023 06:30:00"
"18/12/2023 08:00:00"
"18/12/2023 09:30:00"
"18/12/2023 10:15:00"
"18/12/2023 11:00:00"
"18/12/2023 11:45:00"
"18/12/2023 12:30:00"
"18/12/2023 13:15:00"
"18/12/2023 14:00:00"
"18/12/2023 14:45:00"
"18/12/2023 15:30:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"
"18/12/2023 16:00:00"


Thats's the market :
QUOTE:
{*V2,Currencies,Eastern Standard Time,Sun+Weekdays,EURUSD,4,0,Forex,USD,09:30:00,16:00:00,Sun,17:15:00,23:59:59,Mon,00:00:00,23:59:00,Tue,00:00:00,23:59:00,Wed,00:00:00,23:59:00,Thu,00:00:00,23:59:00,Fri,00:00:00,17:00:00,,}


0
- ago
#6
And that's it... Problem solved. The market being used "Currencies" would have to be 00:00:00, 23:59:00 instead of 09:30:00, 16:00:00. I created a copy of the market and edited it. Everything's okay now ;]
0
Best Answer
Cone8
 ( 5.88% )
- ago
#7
This is something we can probably improve for the ASCII Provider -
Assign the Market to an ASCII DataSet in the ASCII Configuration.
1
Cone8
 ( 5.88% )
- ago
#8
And it's done for Build 87!

You can now assign a Market to your ASCII (and MetaStock) DataSets. It's one of the last steps in the setup Wizard.

For existing DataSets, right click, Configure..., and click Next until you get to this Wizard page that let's you assign the Market.

1
- ago
#9
Amazing! WL is truly a wonderful tool.
0

Closed

Bookmark

Sort