Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 16:08:50 +0000



[Programming Help] - New StoreValue Custom Study

View Count: 725

[2018-10-28 14:05:11]
User612649 - Posts: 40
Hello All,

Could one of you coding wizards help me out with this? I feel like it is almost completed but I do not possess the require skill set to complete. I am trying to create a custom study that will reference another study at a particular time and display that value until the next day at that time where it will then update to the new static value.

Currently, I have a study that is displaying the referenced study/value, but I cannot get the time to corporate, therefore it is consistently updating instead of holding the value at that specific time until the next day at that time where I would it to update.

Please Help.

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

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

/*============================================================================
  Store a value from another study at a specific time.
----------------------------------------------------------------------------*/
SCSFExport scsf_StoreValue(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_HorizontalLine = sc.Subgraph[0];

  SCInputRef InputData = sc.Input[0];

  SCInputRef TriggerTimeValue = sc.Input[1];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Store Value";
    sc.GraphRegion = 0;
    sc.AutoLoop = 1;
    // 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 = 1;
    
    Subgraph_HorizontalLine.Name = "Line";
    Subgraph_HorizontalLine.DrawStyle = DRAWSTYLE_STAIR_STEP;
    Subgraph_HorizontalLine.LineWidth = 1;
    Subgraph_HorizontalLine.PrimaryColor = RGB(0, 255, 0);

    InputData.Name = "Input Data";
    InputData.SetInputDataIndex(SC_LAST);

    TriggerTimeValue.Name = "Trigger Time Value";
    TriggerTimeValue.SetTime(HMS_TIME(12, 00, 0));

    return;
  }
  
  //SCDateTime variable contains a Date and Time value as a double precision floating-point number.
  SCDateTime VarTime; //Locally defined SCDateTime variable.
  VarTime.SetTime(TriggerTimeValue.GetTime()); //Get Trigger Time Value
  
  SCDateTime CurrentDateTime; //Locally defined SCDateTime variable.
  if (sc.IsReplayRunning())
    CurrentDateTime = sc.CurrentDateTimeForReplay;
  else
    CurrentDateTime = sc.CurrentSystemDateTime;
  
  SCDateTime CurrentTime; //Locally defined SCDateTime variable.
  CurrentTime.SetTime(CurrentDateTime.GetTime()); //Get Current Time from DateTime


  if (VarTime == CurrentTime) //If VarTime = CurrentTime, execute
  {
    float finalvalue = Subgraph_HorizontalLine[sc.Index]; //Return Value!!!!!! Why won't you return value in spreadsheet!!!!
    return;
  }

}
Date Time Of Last Edit: 2018-10-28 23:10:15
[2018-10-31 14:37:18]
User612649 - Posts: 40
Hello?

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

Login

Login Page - Create Account