- ago
However, I want to use the following option:

CODE:
IndicatorBase indicatorOpenHourSecondSymbol =new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Open), -1), HistoryScale.Minute60), 0);


It doesn't give any errors when I run it, but when I output it, I don't get the value on the screen, while on the main character I can output it.
0
381
Solved
16 Replies

Reply

Bookmark

Sort
Cone8
 ( 25.44% )
- ago
#1
You're using -1 for an offset, that's peeking. It will cause that last value to be Double.NaN
1
- ago
#2
Cone, hello!

On the main character, Offset works fine.

I have to set it to get a visual coincidence of the boundaries of the day and the indicator. I understand perfectly well that this is peeping and I go for it consciously.

I put Offset 0 and it didn't change the situation. Still not a number on the chart.
0
Cone8
 ( 25.44% )
- ago
#3
What's the full example that we can run?
Same ascii data?
0
- ago
#4
Cone, hello!

The data is the same. The main symbol is SPFB.RTS_1MIN_20050803.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript2 {    public class MyStrategy : UserStrategyBase    {       public override void Initialize(BarHistory bars)       {          externalSymbol = GetHistory(bars, "RI.RVI_1MIN_150505");                    IndicatorBase indicatorOpenHourSecondSymbol =new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Open), -1), HistoryScale.Minute60), 0);          IndicatorBase indicatorHighHourSecondSymbol = new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.High), -1), HistoryScale.Minute60), 0);          IndicatorBase indicatorLowHourSecondSymbol = new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Low), -1), HistoryScale.Minute60), 0);          IndicatorBase indicatorCloseHourSecondSymbol = new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Close), -1), HistoryScale.Minute60), 0);                PlotIndicatorBands(indicatorHighHourSecondSymbol, indicatorLowHourSecondSymbol, WLColor.LightGray, 0, 20, false, "RVIPane");          PlotIndicatorCloud(indicatorOpenHourSecondSymbol, indicatorCloseHourSecondSymbol, WLColor.Brown, WLColor.LightGreen, 2, LineStyle.Solid, 25, false, "RVIPane");       }       public override void Execute(BarHistory bars, int idx)       { }       BarHistory externalSymbol;    } }
0
- ago
#5
Tested in new update, getting the same error.
0
Cone8
 ( 25.44% )
- ago
#6
We've spent many, many hours on your problem here, and we still wish we knew why this only happens for you. 🤔
0
- ago
#7
Cone, hello!

You didn't waste your time. The main issue has been fixed. Now only the problem described in Post #51 remains.

Can you really run this code and display this indicator?
0
- ago
#8
The trait of many users to pack different questions into one topic seems natural but we can try and avoid further confusion. I've just spun off the discussion from that Post #51. Just for reference, the source thread was: https://www.wealth-lab.com/Discussion/ScaledInd-not-applied-to-external-symbol-9582
0
- ago
#9
Hello Eugene!

The error still persists. Have you made any progress in fixing it?
0
- ago
#10
Hello Denis,

No error for us as Cone said, nothing to fix.
0
- ago
#11
Cone, hi!

The code still doesn’t work, I set Offset to 0. The result is in the screenshot:


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 override void Initialize(BarHistory bars)       {          externalSymbol = GetHistory(bars, "RI.RVI_1MIN_150505");          //BarHistory CompressedBars = BarHistoryCompressor.ToDaily(externalSymbol);          //BarHistory UnCompressedBars= BarHistorySynchronizer.Synchronize(CompressedBars,bars);                    //PlotBarHistory(UnCompressedBars, "RVIPane");                    //IndicatorBase indicatorOpenHour =new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Open), -1),          //HistoryScale.Minute60), 0);                              IndicatorBase indicatorOpenHourSecondSymbol =new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Open), 0), HistoryScale.Minute60), 0);          IndicatorBase indicatorHighHourSecondSymbol = new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.High), 0), HistoryScale.Minute60), 0);          IndicatorBase indicatorLowHourSecondSymbol = new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Low), 0), HistoryScale.Minute60), 0);          IndicatorBase indicatorCloseHourSecondSymbol = new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Close), 0), HistoryScale.Minute60), 0);                    PlotIndicatorBands(indicatorHighHourSecondSymbol, indicatorLowHourSecondSymbol, WLColor.LightGray, 0, 20, false, "RVIPane");          PlotIndicatorCloud(indicatorOpenHourSecondSymbol, indicatorCloseHourSecondSymbol, WLColor.Brown, WLColor.LightGreen, 2, LineStyle.Solid, 25, false, "RVIPane");       }       public override void Execute(BarHistory bars, int idx)       { }       BarHistory externalSymbol;    } }

0
- ago
#12
Denis, double.NaN (not a number) cannot be charted. At some step your nested indicators return a NaN. If you unwrap them and plot individually that might help your troubleshooting.
0
- ago
#13
Eugene, hello!

I don't understand how exactly to unwrap the following line:

CODE:
IndicatorBase indicatorOpenHourSecondSymbol =new OffsetInd(externalSymbol, new ScaledInd(externalSymbol, new OffsetInd(externalSymbol, new TimeSeriesIndicatorWrapper(externalSymbol.Open), 0), HistoryScale.Minute60), 0);


No matter what step I make an error at, I can’t throw out any of the steps, otherwise I won’t get the indicator I want to see.
0
- ago
#14
Eugene, hello!

Any updates on the issue?
0
- ago
#15
@Eugene... I'm finding unexpected behavior from TimeSeriesIndicatorWrapper for bars sourced from an external symbol. Please see comments in the following code...

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using System.Linq; namespace WealthScript1 {    public class MyStrategy : UserStrategyBase    {       public MyStrategy()       {       }       //create indicators and other objects here, this is executed prior to the main trading loop       public override void Initialize(BarHistory bars)       {          // decompose part of the original statement          var externalSymbol = GetHistory(bars, "QQQ");          PlotTimeSeries(externalSymbol.Close, "Ext Sym Open", "Ext Sym Open"); // plot is OK                    // wrap the external symbol's Open.          var tsWrap = new TimeSeriesIndicatorWrapper(externalSymbol.Open);          PlotIndicator(tsWrap, paneTag: "tsWrap"); // plot is OK                    // apparently, this is the culprit...          var offTsWrap = new OffsetInd(externalSymbol, tsWrap, 0);          PlotIndicator(offTsWrap);   // all NaN                    // pardon the use of LINQ, its just easier          var allNaN = offTsWrap.Values.All(v => double.IsNaN(v));          WriteToDebugLog($"allNaN = {allNaN}");                    // this is the original statement with substitutions from above          // Of the matter, it doesn't work because of the aforementioned issue (see offTsWrap)          IndicatorBase indicatorOpenHourSecondSymbol = new OffsetInd(externalSymbol,             new ScaledInd(externalSymbol, offTsWrap, HistoryScale.Minute60), 0);          PlotIndicator(indicatorOpenHourSecondSymbol);   // all NaN as expected          // Check if TimeSeriesIndicatorWrapper for bars.Open causes a problem          var barsOpenWrap = new TimeSeriesIndicatorWrapper(bars.Open);          PlotIndicator(tsWrap, paneTag: "barsOpenWrap"); // plot is OK          // offset it and plot it - no problem          var offBarsOpenWrap = new OffsetInd(bars, barsOpenWrap, 0);          PlotIndicator(offBarsOpenWrap, paneTag: "Bars Open Wrap"); // plot is OK       }       //execute the strategy rules here, this is executed once for each bar in the backtest history       public override void Execute(BarHistory bars, int idx)       {       }       //declare private variables below    } }
1
Glitch8
 ( 11.81% )
- ago
#16
Appreciate the commented example of the issue! I resolved it for Build 62, there was a small bug in OffsetInd.
2
Best Answer

Reply

Bookmark

Sort