Registered User Joined: 3/10/2005 Posts: 28
|
I am in hopes someone can help me with some code. I'm a bit of a hack coder, so please bear with me. I'm simply trying to chart the cumulative percent change of visible bars - from left of screen to last bar. While the code sort of works, it doesn't always display when the chart is opened, doesn't expand to a new zoom, and never displays when changing time frames away from a daily time frame.
I know at least part of my problem (if not all of it) is the use of TotalBars variable. I've set it to 5000 because that's the setting for 'max daily bars to read' in the data manager utility for the entire program. Obviously, I'm not reading that many bars on a weekly or monthly time frame. But I couldn't figure out any other means to determine when to begin plotting. Ideas?
Thanks -Rob
'# RECALC_ON_ZOOM_SCROLL
'# Symbol = UserInput.String = "DXY0"
'# TotalBars = UserInput.Integer = 5000
Static altPrice As WBI.CommonBlocks.RealCodeIndicator
Static BeginningOfVisiblePriceBars As Integer = TotalBars - ActiveChart.BarsVisible
Static Offset As Integer = 0
If isFirstBar Then
altPrice = PriceData(Symbol)
End If
If CurrentIndex > BeginningOfVisiblePriceBars Then
Plot = ((altPrice.Value - altPrice.Value(Offset)) / altPrice.Value(Offset) * 100)
Offset += 1
Else
Plot = Single.Nan
End If
|