Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 09:07:24 +0000



[Programming Help] - Example for sc.VolumeAtPriceForStudy

View Count: 927

[2021-02-13 21:45:43]
Nicolas Hervé - Posts: 14
Hi!

So, sc.VolumeAtPriceForStudy is the Volume at Price Data for the study instance itself.
And it is read/write.

Does this mean we can create a study that will write random data (for instance feeled from bar data or from some part of .scid file(s)) ?
Would it also be possible to visualize those stored data as horizontal bars on the y axis like it is for the VolumeAtPrice study ?

Can you provide sample code or hint for using the sc.VolumeAtPriceForStudy.


From: ACSIL Interface Members - Variables and Arrays: sc.VolumeAtPriceForStudy

sc.VolumeAtPriceForStudy
Type: Read/write custom data array object pointer of type c_VAPContainer.

The sc.VolumeAtPriceForStudy variable is the same as sc.VolumeAtPriceForBars except it is the volume at price data for the study itself instead of the main price graph of the chart. Normally this is not applicable and contains no data but it is used for special purposes.

There is no further documentation available at this time.

Which special purpose for example.


P.S.: I just created new thread to continue on my last question on
memory allocation of UseTool
[2021-02-13 23:19:18]
Nicolas Hervé - Posts: 14
I tried this:



#include "sierrachart.h"

SCDLLName("Volume By Price For Study Demo")

SCSFExport scsf_VolumeByPriceForStudyDemo(SCStudyInterfaceRef sc) {

if(sc.SetDefaults) {
sc.GraphName = "Volume by Price For Study Demo.";
sc.StudyDescription = "This study creates arbitrary Volume by Price Data to demonstrate "
"the use of sc.VolumeByPriceForStudy() function.";

sc.GraphRegion = 0;
sc.AutoLoop = 0;
sc.MaintainVolumeAtPriceData = 1;
}


c_VAPContainer * c_VAP_for_study;

c_VAP_for_study = sc.VolumeAtPriceForStudy;



s_VolumeAtPriceV2 vap = s_VolumeAtPriceV2 (
100, // Volume
60, // BidVolume
40, // AskVolume
10 // NumberOfTrades
);


c_VAP_for_study -> AddVolumeAtPrice (
3920 * 4, // PriceInTicks (this will be 3920.00 points for ES
0, // BarIndex (try to use always BarIndex 0 for VolumeByPriceForStudy
vap
);


}




But get those compilation error, which I don't know how to fix.
-- Starting remote build of Custom Studies Source files: VolumeAtPriceForStudyDemo.cpp. 64-bit -- 00:11:21

Allow time for the server to compile the files and build the DLL.

The remote build did not succeed. Result:

In file included from scstructures.h:104,
from sierrachart.h:22,
from VolumeAtPriceForStudyDemo.cpp:1:
VAPContainer.h: In instantiation of 'void c_VAPContainerBase<t_VolumeAtPrice>::Clear() [with t_VolumeAtPrice = s_VolumeAtPriceV2]':
VolumeAtPriceForStudyDemo.cpp:31:29: required from here
VAPContainer.h:390:2: error: cannot bind non-const lvalue reference of type 'c_VAPContainerBase<s_VolumeAtPriceV2>&' to an rvalue of type 'c_VAPContainerBase<s_VolumeAtPriceV2>'
390 | Swap(c_VAPContainerBase<t_VolumeAtPrice>(m_InitialAllocationElements));
| ^~~~
VAPContainer.h:462:23: note: initializing argument 1 of 'void c_VAPContainerBase<t_VolumeAtPrice>::Swap(c_VAPContainerBase<t_VolumeAtPrice>&) [with t_VolumeAtPrice = s_VolumeAtPriceV2]'
462 | ( c_VAPContainerBase& r_That
| ~~~~~~~~~~~~~~~~~~~~^~~~~~

-- End of Build -- 00:11:24

[2021-03-14 22:59:52]
Nicolas Hervé - Posts: 14
Hi still need help with the use of sc.VolumeAtPriceForStudy
What I want to do with it is to draw my own VolumeAtPrice bars, based on external data (load/store VbP from/to file).

Regards
[2021-03-16 12:43:56]
User310645 - Posts: 49
I don't really understand why (or if there would be issues) but if you change the template definition of the Clear() method at line 387 in ACS_Source\VAPContainer.h to cast the new temp object first it resolves the reference conversion error and allows it to compile for me. YMMV.


template<typename t_VolumeAtPrice>
inline void c_VAPContainerBase<t_VolumeAtPrice>::Clear()
{
  // Swapping with a new temporary object will effectively destroy and
  // re-initialize this object.
Swap(reinterpret_cast< c_VAPContainerBase<t_VolumeAtPrice>&>(c_VAPContainerBase<t_VolumeAtPrice>(m_InitialAllocationElements)));
}

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account