Login Page - Create Account

Support Board


Date/Time: Thu, 06 Mar 2025 13:14:53 +0000



Post From: Study only Accurate/Visible after Full Calculation ?

[2022-01-29 09:09:58]
SelimEker - Posts: 13
Hi everyone !

I'm a newbie, as it is just this week that I started working with SC. I have built a Custom Study that is supposed to highlight certain legs bar highs (or lows) after a Swingpoint. My study is accurate whenever i do a Recalculation, but if i run the (Standard) Replay it starts highlighting wrong parts. As for the other replay types or using "live" data, it doesn't do anything.

I think the issue is how I get the data "into" the study but I cant figure how to make it work. (I have tried sc.GetChartBaseData but can't make it work aswell)...

Can you point what I am doing wrong ?

I would greatly appreciate it.

Here is the code:

// This must be exactly "sierrachart.h" to ensure you are referencing the correct header file.
#include "sierrachart.h"

// Change the text within the quote marks to what you want to name your group of custom studies.
SCDLLName("DPB")


int DownLegCounter = 1;
int UpLegCounter = 1;


float SwingLatestHigh = 0;
float SwingLatestLow = 99999;

float LowestLongPrice = 0;
float HighestShortPrice = 0;



SCSFExport scsf_DPB(SCStudyInterfaceRef sc)
{

  // XXXXXXXXXXXXXXXXXXXXX sc.GraphName = "DPB"; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ---> Removed since i called the function twice

  SCSubgraphRef Subgraph_LONG = sc.Subgraph[0];
  SCSubgraphRef Subgraph_SHORT = sc.Subgraph[1];



  

  if (sc.SetDefaults)
  {
    sc.GraphName = "Double Pull Back";
    sc.StudyDescription = "Double Pull Back";
    sc.GraphRegion = 0;

    Subgraph_LONG.Name = "LONG";
    Subgraph_LONG.DrawStyle = DRAWSTYLE_STAIR_STEP;
    Subgraph_LONG.PrimaryColor = RGB(0, 64, 128);
    Subgraph_LONG.LineWidth = 2;
    Subgraph_LONG.DrawZeros = false;

    Subgraph_SHORT.Name = "SHORT";
    Subgraph_SHORT.DrawStyle = DRAWSTYLE_STAIR_STEP;
    Subgraph_SHORT.PrimaryColor = RGB(128, 0, 0);
    Subgraph_SHORT.LineWidth = 2;
    Subgraph_SHORT.DrawZeros = false;


    sc.AutoLoop = 1;

    return;
  }



    float high = sc.High[sc.Index];
    float highOld = sc.High[sc.Index - 1];
    float highOld2 = sc.High[sc.Index - 2];
    float highOld3 = sc.High[sc.Index - 3];
    float highOld4 = sc.High[sc.Index - 4];


    float low = sc.Low[sc.Index];
    float lowOld = sc.Low[sc.Index - 1];
    float lowOld2 = sc.Low[sc.Index - 2];
    float lowOld3 = sc.Low[sc.Index - 3];
    float lowOld4 = sc.Low[sc.Index - 4];


And to spare you with all the conditions:


if (highOld > high && highOld > highOld2 && SwingLatestHigh >= highOld) // Clear Peaks Lower than Last Swing -> New Leg
    {
      DownLegCounter = DownLegCounter + 1;
      SwingLatestHigh = highOld;
    }


//Drawing of Highlighted Highs

if (high < highOld && DownLegCounter == 2)
    {
      Subgraph_LONG[sc.Index] = high;
      LowestLongPrice = high;
    }
    else if (high == LowestLongPrice && DownLegCounter == 2)
    {
      Subgraph_LONG[sc.Index] = high;
    }
    else
    {
      Subgraph_LONG[sc.Index] = 0;
    }


Date Time Of Last Edit: 2022-01-30 09:53:50