Study based on same instrument/different data series problem

Questions about MultiCharts .NET and user contributed studies.
Ram
Posts: 90
Joined: 25 Nov 2014
Has thanked: 17 times
Been thanked: 5 times

Study based on same instrument/different data series problem

Postby Ram » 03 May 2015

I have a chart with 3 instrument of the same symbol (Trade, Ask & Bid):
Image

My study (supposed) to calculate ATR for each data instrument in the same study:

Code: Select all

' Methods
Public Sub New(ByVal ctx As Object)
MyBase.New(ctx)
Me.AtrLength = 5
End Sub

' Properties
<Input()> Public Property AtrLength As Integer

' Fields
Private ATR_ASK As VariableSeries(Of Double)
Private ATR_TRADE As VariableSeries(Of Double)
Private ATR_BID As VariableSeries(Of Double)

Private Plt_Ask As IPlotObject
Private Plt_Trade As IPlotObject
Private Plt_Bid As IPlotObject


Protected Overrides Sub CalcBar()
Me.ATR_ASK.Value = Me.AverageTrueRange(Me.AtrLength)
Me.ATR_TRADE.Value = Me.AverageTrueRange(Me.AtrLength)
Me.ATR_BID.Value = Me.AverageTrueRange(Me.AtrLength)

Me.Plt_Ask.Set(0, Me.ATR_ASK.Value)
Me.Plt_Trade.Set(0, Me.ATR_TRADE.Value)
Me.Plt_Bid.Set(0, Me.ATR_BID.Value)
End Sub

Protected Overrides Sub Create()
Me.ATR_TRADE= New VariableSeries(Of Double)(Me, 1)
Me.ATR_ASK = New VariableSeries(Of Double)(Me, 2)
Me.ATR_BID = New VariableSeries(Of Double)(Me, 3)

Me.Plt_Ask = MyBase.AddPlot(New PlotAttributes("ATR ASK", EPlotShapes.Line, Color.Green, Color.Empty, 0, 0, True))
Me.Plt_Trade= MyBase.AddPlot(New PlotAttributes("ATR TRADE", EPlotShapes.Line, Color.White, Color.Empty, 0, 0, True))
Me.Plt_Bid = MyBase.AddPlot(New PlotAttributes("ATR BID", EPlotShapes.Line, Color.Blue, Color.Empty, 0, 0, True))
End Sub
However I get the same result for all plots, each is based on the same instrument as define in the Properties of the study ("Base Study On") and it seems that the following code isn't correct/ignored:

Code: Select all

Me.ATR_TRADE= New VariableSeries(Of Double)(Me, 1)
Me.ATR_ASK = New VariableSeries(Of Double)(Me, 2)
Me.ATR_BID = New VariableSeries(Of Double)(Me, 3)
Please advice...

Thank you all in advance!
Best,
R.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Study based on same instrument/different data series pro

Postby Henry MultiСharts » 05 May 2015

Hello Ram,

The variables are created incorrectly, AverageTrueRange is being used incorrectly as well. Variables accept the data stream as the third parameter, AverageTrueRange does the same.


Return to “MultiCharts .NET”