Getting an instance of PowerLanguage.Bar

Questions about MultiCharts .NET and user contributed studies.
User avatar
orad
Posts: 121
Joined: 14 Nov 2012
Has thanked: 50 times
Been thanked: 20 times

Getting an instance of PowerLanguage.Bar

Postby orad » 03 Feb 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:

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
};
}
}
Thanks,
orad

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

Re: Getting an instance of PowerLanguage.Bar

Postby Henry MultiСharts » 04 Feb 2015

Hello orad,

There is no way to do that.

User avatar
orad
Posts: 121
Joined: 14 Nov 2012
Has thanked: 50 times
Been thanked: 20 times

Re: Getting an instance of PowerLanguage.Bar

Postby orad » 04 Feb 2015

OK, few questions:

- Where are PowerLanguage.Bar objects used in MultiCharts? Only used internally?

- If I want to create an instance of it myself from the data available in the study, then how can I get UpVolume, DownVolume and UnchangedVolume? These properties are not available in study's Bars but Bars has information about Ticks instead. I commented out these in my code above because I was not sure if they were the same.

I think Volume is different from Ticks in that Volume is the number of shares/contracts traded but Ticks are the number of trades taken place where each can consist of one or more shares/contracts. I'm not sure if this description is true only for stocks or if it also applies to contracts.

Thanks for your help!

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Getting an instance of PowerLanguage.Bar

Postby JoshM » 07 Feb 2015

I think Volume is different from Ticks in that Volume is the number of shares/contracts traded but Ticks are the number of trades taken place where each can consist of one or more shares/contracts.
Yes, but it also depends on the symbol's time frame.

For Ticks:
With Build Volume On is set to Tick Count:

The value of 1 will be returned for 1-tick charts,
The total number of ticks in the current bar will be returned for multi-tick, volume, and time-based charts.

With Build Volume On is set to Trade Volume:

The volume of the current tick will be returned for 1-tick charts,
The total volume of the current bar will be returned for multi-tick, volume, and time-based charts.
Source: Ticks - Wiki.

For Volume:
Returns the volume of the current bar. For tick and volume-based charts, and time-based charts with resolutions of 24 hours or less:

The volume traded on Up ticks will be returned if Build Volume On is set to Trade Volume,
The number of Up ticks in the current bar will be returned if Build Volume On is set to Tick Count.

For time-based charts with resolutions of 1 day or more:

The total volume traded will be returned if Build Volume On is set to Trade Volume,
The total number of ticks in the current bar will be returned if Build Volume On is set to Tick Count.
Source: Volume - Wiki.

(I don't know about your other questions, sorry).

User avatar
orad
Posts: 121
Joined: 14 Nov 2012
Has thanked: 50 times
Been thanked: 20 times

Re: Getting an instance of PowerLanguage.Bar

Postby orad » 08 Feb 2015

Thanks JoshM, it was helpful. I also found this article about tick charts very helpful that describes volumes and ticks:

http://emini-watch.com/emini-trading/tick-charts/

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

Re: Getting an instance of PowerLanguage.Bar

Postby Henry MultiСharts » 09 Feb 2015

- Where are PowerLanguage.Bar objects used in MultiCharts? Only used internally?
PowerLanguage.Bar[] is provided by the DataLoader. It is filled when tick resolution is plotted.


Return to “MultiCharts .NET”