Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 22:29:28 +0000



[Programming Help] - Volume by Price - Valleys and Peak data not on spreadsheet

View Count: 3002

[2018-06-21 09:32:51]
User623552 - Posts: 69
Hi,

I've noticed with the volume by price study the Valley and Peak data is not output to the spreadsheet
I use the volume valleys as levels of support and resistance, and would like to incoporate them into an automated strategy

How can I get the volume valley data into the spreadsheet in order to use it as part of an automated trade ?

Thanks
[2018-06-22 17:50:01]
Sierra Chart Engineering - Posts: 104368
This is not supported when using the Spreadsheet study but if you are using ACSIL you can access this data with this function:
sc.GetStudyPeakValleyLine()

So you could create an ACSIL study to access the data and then output it to study Subgraphs, which would then be visible on the spreadsheet.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2018-06-22 17:50:48
[2020-10-28 12:26:36]
User355030 - Posts: 163
@sce can you provide the ACSIL .cpp file for accessing the peaks/valleys in order for me to access the data in the spreadsheet?
[2020-10-29 04:03:02]
Sierra Chart Engineering - Posts: 104368
We do not have any examples for this, but refer to this function:
sc.GetStudyPeakValleyLine()

And refer to:
sc.SetSheetCellAsDouble()
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2020-10-29 18:23:53]
User355030 - Posts: 163
I used the function and cannot get it to actually grab a peak or valley from the referenced study.. I believe the function needs to be visited by the engineer team to ensure it works.

@SCE
[2020-10-29 20:42:41]
Sierra Chart Engineering - Posts: 104368
The function definitively works properly. For an example to use this function, refer to the scsf_GetStudyPeakValleyLineExample function in the /ACS_Source/studies2.cpp file in the Sierra_Chart installation folder.

Also Peak and Valley lines cannot be obtained for a Volume by Price study which uses Visible Bars for the Volume Graph Period Type Input.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2020-10-29 20:43:10
[2020-10-30 13:21:34]
User355030 - Posts: 163
@SCE I am using the example that you reference, but it looks like the issue is "Peak and Valley lines cannot be obtained for a Volume by Price study which uses Visible Bars for the Volume Graph Period Type Input." The VBP study uses visible bars.... so which study gives the same data?
[2020-10-30 15:05:32]
John - SC Support - Posts: 36284
It's not the VbP bars are visible. It's stating that the Peak and Valley lines cannot be obtained when the Volume Graph Period Type is set to Visible Bars.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2020-10-30 16:03:29]
User355030 - Posts: 163
MY Volume Graph Period Type is set to "multiple profiles based on Bar Count" and still cannot get it to work... @SCE
[2020-10-30 16:26:26]
BreadWinner'sAssoc. - Posts: 7
I've been trying to use this as well. The first Peak Valley lines shows on my chart, but I don't know how to get the peak valley values into an array that I can in order to use a for loop to index through them. I haven't had any luck using a for loop. I've added the code I've used which got a peak valley line to draw on my chart. SC Support, I apologize for asking such a trivial question, but I have gone through the documentation and example study code. I'm probably overlooking a simple solution. Any guidance would be very much appreciated!

    sc.AutoLoop = 0;

    sc.Input[0].SetStudyID(1);
    sc.Input[0].Name = "Peak Valley Test";
    sc.Subgraph[0].Name = "Line1";
    sc.Subgraph[0].PrimaryColor = RGB(0, 255, 0);
    sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
    sc.Subgraph[1].Name = "Line2";
    sc.Subgraph[1].PrimaryColor = RGB(255, 255, 0);
    sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE;

    return;
  }


  float PeakValleyLinePrice = 0;
  int PeakValleyType = 0;
  int StartIndex = 0;
  int PeakValleyExtensionChartColumnEndIndex = 0;

  if (sc.GetStudyPeakValleyLine(sc.ChartNumber, sc.Input[0].GetStudyID(), PeakValleyLinePrice, PeakValleyType, StartIndex, PeakValleyExtensionChartColumnEndIndex, -1, 0))
  {

    sc.Subgraph[0][sc.Index] = sc.GetStudyPeakValleyLine(sc.ChartNumber, sc.Input[0].GetStudyID(), PeakValleyLinePrice, PeakValleyType, StartIndex, PeakValleyExtensionChartColumnEndIndex, -1, 0);
  }
  sc.Subgraph[1][sc.Index] = PeakValleyLinePrice;

[2020-10-30 18:43:49]
User355030 - Posts: 163
@user342579 the code you posted errors when building
[2020-10-30 18:51:30]
Ackin - Posts: 1865
User355030)
multiple profiles based on Bar Count

Just a question ... there will always be a different number of lines, does it matter?
[2020-10-30 18:53:57]
User355030 - Posts: 163
Here is my code, builds but cant get the lines on chart

// The top of every source code file must include this line
#include "sierrachart.h"

// For reference, refer to this page:
// Advanced Custom Study Interface and Language (ACSIL)
#include "sierrachart.h"

// For reference, refer to this page:
// Advanced Custom Study Interface and Language (ACSIL)

// This line is required. Change the text within the quote
// marks to what you want to name your group of custom studies.
SCDLLName("VBP Valley Lines KI")

//This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require.
SCSFExport scsf_GetStudyPeakValleyLineExample(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "GetStudyPeakValleyLine Example";
    sc.Subgraph[0].Name = "VBPVALLEYKI";
    sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;

    sc.AutoLoop = 0;

    sc.Input[0].SetStudyID(1);

    sc.Input[0].Name = "Peak Valley Test";

    sc.Subgraph[0].Name = "Line1";

    sc.Subgraph[0].PrimaryColor = RGB(0, 255, 0);

    sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;

    sc.Subgraph[1].Name = "Line2";

    sc.Subgraph[1].PrimaryColor = RGB(255, 255, 0);

    sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE;

    return;
  }


  // Do data processing
  float PeakValleyLinePrice= 0;
  int PeakValleyType = 0;
  int StartIndex = 0;
  int PeakValleyExtensionChartColumnEndIndex = 0;

  // get the first Peak/Valley line from the last volume by price profile
  if (sc.GetStudyPeakValleyLine(sc.ChartNumber, sc.Input[0].GetStudyID(), PeakValleyLinePrice, PeakValleyType, StartIndex, PeakValleyExtensionChartColumnEndIndex, -1, 0))
  {
    // Peak/Valley line found
    int Test = 1;
  }
}
[2020-10-30 19:34:13]
BreadWinner'sAssoc. - Posts: 7
@User355030 I didn't post my complete code. Here is the complete code if you want to compile and test it :)
Make sure you set the region to 1 to overlay the main price graph.





SCSFExport scsf_PeakValley(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {

    sc.GraphName = "PeakValley Test";

    sc.AutoLoop = 0;

    sc.Input[0].SetStudyID(1);
    sc.Input[0].Name = "Volume by Price Study";
    sc.Subgraph[0].Name = "Line1";
    sc.Subgraph[0].PrimaryColor = RGB(0, 255, 0);
    sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE_FROM_END_OF_CHART_LEFT_TO_RIGHT;
    sc.Subgraph[1].Name = "Line2";
    sc.Subgraph[1].PrimaryColor = RGB(255, 255, 0);
    sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE_FROM_END_OF_CHART_LEFT_TO_RIGHT;

    return;
  }



  float PeakValleyLinePrice = 0;
  int PeakValleyType = 0;
  int StartIndex = 0;
  int PeakValleyExtensionChartColumnEndIndex = 0;


  if (sc.GetStudyPeakValleyLine(sc.ChartNumber, sc.Input[0].GetStudyID(), PeakValleyLinePrice, PeakValleyType, StartIndex, PeakValleyExtensionChartColumnEndIndex, -1, 0))
  {

    sc.Subgraph[0][sc.Index] = sc.GetStudyPeakValleyLine(sc.ChartNumber, sc.Input[0].GetStudyID(), PeakValleyLinePrice, PeakValleyType, StartIndex, PeakValleyExtensionChartColumnEndIndex, -1, 0);
  }
  sc.Subgraph[1][sc.Index] = PeakValleyLinePrice;
}

[2020-10-30 21:59:12]
User355030 - Posts: 163
I used your code, compiled it successfully, and still can't get the study to grab the peak and valley values.... @user342579
[2020-10-30 22:35:04]
BreadWinner'sAssoc. - Posts: 7
User355030,

With the code I supplied above I can only get the first peak or valley to show up on my main price graph. I've been struggling with this for quite some time. The reason I want to access these numbers is so I can have one chart with multiple VbP profiles and just reference the lines on my other charts to reduce the amount of processing required. Currently my only way around this is to add the same VbP to every chart that I want the peaks and valleys overlaid. BUT, this provides an inefficient way to do this because each chart will have to recalculate each VbP study. I am trying to find a way to access all the price levels in the VbP and append them to an array. Then I should be able to go through each index within that array with a for loop and looking for a boolean answer as to weather x price level is a peak or valley then append it to a separate array. If it is not a peak or valley then proceed to the next index and evaluate until there are no more price levels in the original array acquired from the sc.GetStudyPeakValletLine function.


@Akin, Do you have any words of advice to send me in the right direction to accomplish what I would like to do. Also, I posted a similar request on your forum. I have lots of experience with languages other than C++, for example, I have done lots of work with C#, .Net, VBA, Python, R, SAS, and limited experience with MATLAB during college. I feel like C++ is a much more simplified language than most, but at the same time very powerful. I'm still trying to adjust to this language.

I greatly appreciate any words of advice.
[2020-12-08 00:04:53]
User355030 - Posts: 163
@SCE Attached is my .CPP file... It will grab the first valley or peak it finds and that is it. Also, it will not store the value correct, it continues to recalculate (flashes the plotted line in and out )
attachmentTestvalleyki.cpp - Attached On 2020-12-08 00:04:48 UTC - Size: 1.71 KB - 462 views
[2020-12-08 00:34:05]
Ackin - Posts: 1865
@Akin, Do you have any words of advice to send me in the right direction to accomplish what I would like to do. Also, I posted a similar request on your forum. I have lots of experience with languages other than C++, for example, I have done lots of work with C#, .Net, VBA, Python, R, SAS, and limited experience with MATLAB during college. I feel like C++ is a much more simplified language than most, but at the same time very powerful. I'm still trying to adjust to this language.

I greatly appreciate any words of advice.

Apologize....I overlooked this message...I'm not sure if I've already answered you by email or on the czsk forum, but it should be resolved. If you have any questions, please go directly to the study description that shows all of Peak/valley

Study: VbP Peak/Valley Lines (Free 2020)
[2020-12-08 01:26:24]
User355030 - Posts: 163
@ackin “study: VbP Peak/Valley Lines (Free 2020)” is this a study that supports peak and valleys for spreadsheets ?
[2020-12-08 07:55:52]
Ackin - Posts: 1865
@ackin “study: VbP Peak/Valley Lines (Free 2020)” is this a study that supports peak and valleys for spreadsheets ?
Yes (No reports have been reported from anyone that there is a problem)
[2020-12-08 08:00:56]
Ackin - Posts: 1865
I will also improve it with alerts in response to the chart and I received a request in the email to the linking to market depth with this ..... not before Christmas, the wish list is long .... I am currently creating or modifying 2-5 studies daily to the updates on the forum. More is not possible within the scope of my time.
[2020-12-08 14:50:48]
User355030 - Posts: 163
@ackin Where is this study?
[2020-12-08 20:34:09]
Ackin - Posts: 1865
@ackin Where is this study?
https://www.sierrachart.com/UserControlPanel.php?page=StudyStore&SCDLLName=zyp_download_free
[2020-12-09 15:15:02]
User355030 - Posts: 163
@ackin I submited the request for my login information yesterday, how long does it take to get approved?
Date Time Of Last Edit: 2020-12-09 15:15:09
[2020-12-09 18:04:39]
Ackin - Posts: 1865
7 people registered yesterday, 3 of them were rejected due to the non-existent SC account name, I was in contact with everyone.

I don't know about another registration from yesterday. Send me a DM or email.

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

Login

Login Page - Create Account