Using getVolumeProfile method

Login or Register

Please login or register in order to view and post in the Forum.

2 posts / 0 new
Last post
Robert Maierle
Last seen: 5 months 3 weeks ago
Joined: 04/15/2018 - 09:34
Using getVolumeProfile method

In the calc function, I have declared an array as follows:

RTARRAYI VP(barVolumeProfile);

Later on, I am attempting to extract data from the volume profile of that bar via the getVolumeProfile method as an example:

for (int i = iStartBar; i <= OP.count; i++)
{
SignalArray[i] = VP.getVolumeProfile(i, 1, ???);
}

Question is what that third argument is supposed to be in the getVolumeProfile method? I come from a python background but not c++ so this might be a super simple question to be answered, but maybe showing an example of accessing the VOLPROFILE class via the getVolumeProfile method would be very helpful

0
cpayne
Last seen: 1 year 1 month ago
Joined: 03/30/2009 - 00:00
RTARRAYI VAP_Array(barVolumeProfile)

Declare an array of type RTARRAYI and send in barVolumeProfile as seen below and VAP_Array will populate with the volume at price array. Call getVisibleBars to get the start and end visible bars and then loop through those. Call VAP_Array.getVolumeProfile sending in the bar number (i) and the priceOffset (prices from high of bar) to get the VAP information which is declared as VOLPROFILE. You can then inspect the volume information within VAP like VAP.totalVolume and VAP.price. Call getDrawPosition sending in the bar number (i) and the price to grab the location of each price within each bar (horizontal = pnt.h and vertical = pnt.v). Let me know if you have any problem with that.


int i, start, end;
RTARRAYI VAP_Array(barVolumeProfile);
VOLPROFILE VAP;
PNT pnt;


getVisibleBars(&start, &end);
for(i = start; i <= end; i++)
{
priceOffset = 0;
while ( VAP_Array.getVolumeProfile(i, priceOffset, VAP) == RTX_OK ) {
// VAP.totalVolume;
getDrawPosition(i, VAP.price, &pnt);
priceOffset++;
}
}

Using the PNT class to draw text is the way to go. You'll need to control the size of the text using the FONT class...

FONT myFont = {HELVETICA, 10, PLAIN};

and sending that font to the function....

setFont(myFont);

You can decide what to draw and how big to draw it by grabbing the width of the bar and the height of each price.

You get the bar width with...

getPixelsPerBar()


and you get the height of each price with...


getPixelsPerPrice()