This code snippet:
produces the wrong results. It should show
Instead the line in chart looks more like
CODE:
public override void Initialize(BarHistory bars) { // calculate: Close - SMA(TR(Bars), 2) var tr = new TR(bars); var sma = new SMA(tr, 2); var result = new MathIndOpInd(bars, new TimeSeriesIndicatorWrapper(bars.Close), MathOperation.Subtract, sma); PlotTimeSeries(result, "Close-SMA(TR(bars),2))", "Price"); }
produces the wrong results. It should show
CODE:This is a line very close to the prices.
Close - SMA(TR(Bars), 2)
Instead the line in chart looks more like
CODE:A line close to zero.
Close - SMA(Close, 2)
Rename
The online description of MathIndOpInd says:
What does this mean?
Which cases are covered?
Why is it so?
QUOTE:
MathIndOpInd cannot be nested.
What does this mean?
Which cases are covered?
Why is it so?
BTW: MathIndOpValue has a similar Problem. Let me know if you need a (not)working example.
Transformer indicators are meant primarily for operations in Block Strategies, and there exists the limitation:
Indicator parameters cannot be "indicators of indicators", e.g., SMA(TR, 2).
The Blocks U.I. imposes this limitation by only allowing you to select PriceComponents (Open, High, .. AverageHL, etc) as argurments for the indicator parameters.
In a C# coded strategy just perform the simple TimeSeries math operation:
Indicator parameters cannot be "indicators of indicators", e.g., SMA(TR, 2).
The Blocks U.I. imposes this limitation by only allowing you to select PriceComponents (Open, High, .. AverageHL, etc) as argurments for the indicator parameters.
In a C# coded strategy just perform the simple TimeSeries math operation:
CODE:
TR tr = new TR(bars); SMA sma = new SMA(tr, 2); TimeSeries result = bars.Close - sma; PlotTimeSeries(result, "Close-SMA(TR(bars),2))", "Price");
Re: limitation: we may need to stress this point in the help a bit more.
Already ahead of you.
Re: MathIndOpInd cannot be nested.
I just realized that my answer in Post #4 is wrong [now], because Build 58 gave the ability to nest Transformer Indicators. The nesting not allowed in Transformer indicators is the "Indicator of an Indicator" type.
However, if you really want to replace the simple math operation above with the Transformer style, you can using the SmoothedInd or IndOnIndTransformer for the SMA(TR) and that result could be applied to MathIndOpInd, etc.
I just realized that my answer in Post #4 is wrong [now], because Build 58 gave the ability to nest Transformer Indicators. The nesting not allowed in Transformer indicators is the "Indicator of an Indicator" type.
However, if you really want to replace the simple math operation above with the Transformer style, you can using the SmoothedInd or IndOnIndTransformer for the SMA(TR) and that result could be applied to MathIndOpInd, etc.
Your Response
Post
Edit Post
Login is required