Login Page - Create Account

Support Board


Date/Time: Mon, 24 Feb 2025 17:59:34 +0000



Post From: Study: Max of a Range or Percentage of the Max of a Range

[2021-03-10 07:45:52]
Flipper_2 - Posts: 57
If I understand you correctly you want a rolling max? Is it of prices or of a study?

This will do prices but if you want a study wouldn't be hard to change,




#include "sierrachart.h"

SCDLLName("HL Distance")


SCSFExport scsf_HLDist(SCStudyInterfaceRef sc)
{

  SCSubgraphRef HHLLRange = sc.Subgraph[0];

  SCInputRef HHLLPeriod = sc.Input[1];


  // Section 1 - Set the configuration variables and defaults
  if (sc.SetDefaults)
  {
    sc.GraphName = "HL Distance";

    // During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart. When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 0;
    sc.AutoLoop = 1; //Automatic looping is enabled.


    HHLLRange.Name = "HH_LL_Range";
    HHLLRange.DrawStyle = DRAWSTYLE_BAR;
    HHLLRange.PrimaryColor = RGB(0, 206, 206);
    HHLLRange.LineWidth = 2;
  
    HHLLPeriod.Name = "Period for HH - LL calculation";
    HHLLPeriod.SetInt(40);


    return;
  }



  HHLLRange[sc.Index] = ((sc.GetHighest(sc.BaseDataIn[SC_HIGH], HHLLPeriod.GetInt()) - sc.GetLowest(sc.BaseDataIn[SC_LOW], HHLLPeriod.GetInt())) / sc.BaseDataIn[SC_LAST][sc.Index]) * 100;



}