I'm losing it :( need some basic explanation pls..  [SOLVED]

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

I'm losing it :( need some basic explanation pls..

Postby Ram » 01 Dec 2014

Hi,

can someone pls explain me why do i get this:

when running this i get the correct value (240 in this case):

Code: Select all

Protected Overrides Sub CalcBar()

If Bars.LastBarOnChart Then
dim BarsCount as Integer

BarsCount = Bars.CurrentBar

Output.WriteLine("BarsCount: " & BarsCount.ToString)
End if

End Sub
now, if i add this line HighestHigh = Bars.High.Highest(BarsCount):

Code: Select all

Protected Overrides Sub CalcBar()

If Bars.LastBarOnChart Then
dim BarsCount as Integer

BarsCount = Bars.CurrentBar
HighestHigh = Bars.High.Highest(BarsCount)

Output.WriteLine("BarsCount: " & BarsCount.ToString)
End if

End Sub
now i get 85 instead of 240.. why is that?

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

Re: I'm losing it :( need some basic explanation pls..

Postby Henry MultiСharts » 02 Dec 2014

Hello Ram,

In the first case the MaxBarsBack = 0. CurrentBar = all bars on the chart.
In the second case the MaxBarsBack is constantly increasing. That is why the amount of bars for study calculation (CurrentBar) is constantly decreasing.

Ram
Posts: 90
Joined: 25 Nov 2014
Has thanked: 17 times
Been thanked: 5 times

Re: I'm losing it :( need some basic explanation pls..

Postby Ram » 02 Dec 2014

@Henry,

Thank you for your explanation, if so how can i know the total bars count before CalcBar event?

Thanks again.
Best,
R.

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

Re: I'm losing it :( need some basic explanation pls..  [SOLVED]

Postby Henry MultiСharts » 02 Dec 2014

You can use Bars.FullSymbolData.Count for that.

Ram
Posts: 90
Joined: 25 Nov 2014
Has thanked: 17 times
Been thanked: 5 times

Re: I'm losing it :( need some basic explanation pls..

Postby Ram » 02 Dec 2014

Thanks much!!!
You can use Bars.FullSymbolData.Count for that.


Return to “MultiCharts .NET”