Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 00:39:45 +0000



Post From: Custom Made Study Cannot Calculate Back in Time

[2023-03-22 15:34:58]
User286186 - Posts: 22
Hello I just coded a study in ACSIL that should display a line.

The problem is that it only start to diplay the line from the moment I upload the study to the chart (as you can see on the screenshot).

I tried to add a sc.DataStartIndex statement but it does not solve the problem.


#include "sierrachart.h"

// KST

SCDLLName("KST")

SCSFExport scsf_KST(SCStudyInterfaceRef sc)
{

  SCInputRef Input_W24 = sc.Input[0];
  SCInputRef Input_W18 = sc.Input[1];
  SCInputRef Input_W12 = sc.Input[2];
  SCInputRef Input_W6 = sc.Input[3];

  SCSubgraphRef Subgraph_KST = sc.Subgraph[0];

  SCGraphData SmROC24Data;
  SCGraphData SmROC18Data;
  SCGraphData SmROC12Data;
  SCGraphData SmROC6Data;

  if (sc.SetDefaults)
  {
    sc.GraphName = "KST COMPOSITE INDICATOR";
    sc.StudyDescription = "CFR. P. 788 OF THE BOOK";
    sc.AutoLoop = 1;
    sc.GraphRegion = 0;

    Input_W24.Name = "Weight for 24-period";
    Input_W24.SetInt(4);

    Input_W18.Name = "Weight for 18-period";
    Input_W18.SetInt(3);

    Input_W12.Name = "Weight for 12-period";
    Input_W12.SetInt(2);

    Input_W6.Name = "Weight for 6-period";
    Input_W6.SetInt(1);

    Subgraph_KST.Name = "KST";
    Subgraph_KST.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_KST.PrimaryColor = RGB(0, 255, 0);
    Subgraph_KST.LineWidth = 1;
    Subgraph_KST.DrawZeros = false;

    return;
  }

  if (sc.IsFullRecalculation)
  {
    return;
  }

    // Using sc.GetStudyArraysFromChartUsingID(int ChartNumber, int StudyID, SCGraphData& GraphData).
    sc.GetStudyArraysFromChartUsingID(sc.ChartNumber, 33, SmROC24Data);
    sc.GetStudyArraysFromChartUsingID(sc.ChartNumber, 28, SmROC18Data);
    sc.GetStudyArraysFromChartUsingID(sc.ChartNumber, 26, SmROC12Data);
    sc.GetStudyArraysFromChartUsingID(sc.ChartNumber, 32, SmROC6Data);

    // Define references to subgraph arrays.
    SCFloatArrayRef SmROC24 = SmROC24Data[0];
    SCFloatArrayRef SmROC18 = SmROC18Data[0];
    SCFloatArrayRef SmROC12 = SmROC12Data[0];
    SCFloatArrayRef SmROC6 = SmROC6Data[0];

    float SmROC24LastValue = SmROC24[SmROC24.GetArraySize() - 1];
    float SmROC18LastValue = SmROC18[SmROC18.GetArraySize() - 1];
    float SmROC12LastValue = SmROC12[SmROC12.GetArraySize() - 1];
    float SmROC6LastValue = SmROC6[SmROC6.GetArraySize() - 1];

    int W24Value = Input_W24.GetInt();
    int W18Value = Input_W18.GetInt();
    int W12Value = Input_W12.GetInt();
    int W6Value = Input_W6.GetInt();

    Subgraph_KST[sc.Index] = (W24Value * SmROC24LastValue) + (W18Value * SmROC18LastValue) + (W12Value * SmROC12LastValue) + (W6Value * SmROC6LastValue);

}

Attachment Deleted.
imageCapture d’écran 2023-03-22 163422.png / V - Attached On 2023-03-22 15:34:35 UTC - Size: 61.02 KB - 75 views