Profile Picture

Accessing bar datetime from custom indicator

Posted By Steve2008 7 Years Ago
Message
Posted Saturday November 13 2010
Is there a way for a custom indicator that implements SeriesCalculatorBaseWithValues to know what the datetime is of the bar it is processing?

Edited: Saturday November 13 2010 by Steve2008
Posted Saturday November 13 2010
Have your indicator implement the ISystemAccess interface, and you will get passed the SystemData instance in the Initialize method. Then you can use the CurrentDate property to figure out the current date, or Bars[Symbol].Current.BarStartTime or Bars[Symbol].PartialItem.BarStartTime for the start time of the most recent bar, or the partial bar.

This will mean your indicator won't work outside of a system, so you won't be able to just drag it onto a chart.

Thanks,
Daniel
Posted Sunday November 14 2010
Thanks.

Related question: If Bars.MaxLookBack is set, are old values of indicators garbage collected or do they stay in memory?


Edited: Sunday November 14 2010 by Steve2008
Posted Sunday November 14 2010
Bars.MaxLookBack doesn't apply to indicators, so the values will stay in memory. There's a section in the documentation that talks about what you can do to reduce memory usage.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems