Getting an instance of PowerLanguage.Bar
Posted: Feb 03 2015
Is there any available method I can get an instance of PowerLanguage.Bar for the current bar in the Study? I want to use it as a snapshot of the bar price data at a point in time so that I can use it later in my calculations. Currently I'm using the following extension method which is not perfect:
Thanks,
orad
Code: Select all
public static class BarExtensionMethods
{
public static PowerLanguage.Bar GetBar(this CStudyControl study, int bb)
{
return new Bar
{
Time = study.Bars.Time[bb],
Open = study.Bars.Open[bb],
High = study.Bars.High[bb],
Low = study.Bars.Low[bb],
Close = study.Bars.Close[bb],
UpVolume = 0, //Bars.UpTicks[bb],
DownVolume = 0, //Bars.DownTicks[bb],
UnchangedVolume = 0, //Bars.Ticks[bb],
TotalVolume = (float)study.Bars.Volume[bb],
OpenInterest = (float)study.Bars.OpenInt[bb],
State = study.Bars.Status,
TickTradedSide = ETickTradedSide.Undefined,
EndOfSession = study.Bars.LastBarInSession,
TickID = study.Bars.TickIDValue
};
}
}
orad