Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 06:41:34 +0000



Post From: GetStudyPeakValleyLineExample help

[2022-06-11 18:31:19]
User601489 - Posts: 52
Hello,

So I understand that I can't access SG18 and SG19 from the VbP study without using another study to reference it. So I'm looking at the GetStudyPeakValleyLineExample function in Studies2.cpp and I'm a little confused, and also not a great programmer, just some light scripting.

I understand that if the if statement returns true, then Test = 1. But that statement looks for a specific profile in the index and a specific peak/valley.

But what if I don't really care about the profile index and just want the peaks and valleys? I'm only really looking to create alerts based on price crossing over any peak/valley in the entire chart. How would I modify the function to do that?



SCSFExport scsf_GetStudyPeakValleyLineExample(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "GetStudyPeakValleyLine Example";

    sc.AutoLoop = 0;

    sc.Input[0].SetStudyID(1);
    sc.Input[0].Name = "Volume by Price Study";

    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;
  }
}