Page 1 of 1

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

Posted: Dec 01 2014
by Ram
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?

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

Posted: Dec 02 2014
by Henry MultiŠ”harts
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.

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

Posted: Dec 02 2014
by Ram
@Henry,

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

Thanks again.
Best,
R.

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

Posted: Dec 02 2014
by Henry MultiŠ”harts
You can use Bars.FullSymbolData.Count for that.

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

Posted: Dec 02 2014
by Ram
Thanks much!!!
You can use Bars.FullSymbolData.Count for that.