Login Page - Create Account

Support Board


Date/Time: Fri, 22 Nov 2024 15:47:34 +0000



[Programming Help] - DailyOHLCSinglePoint Compiling Error

View Count: 247

[2024-09-27 02:51:49]
User688525 - Posts: 257
Hello Sierra Chart,
When attempting to build the DailyOHLCSinglePoint study from Studies8.cpp, the following error is being returned:


Server: https://build.sierrachart.com
The remote build is complete.
The build failed.
highlowatpoint.cpp: In function 'void scsf_DailyOHLCSinglePoint(SCStudyInterfaceRef)':
highlowatpoint.cpp:146:5: error: 'CalculateDailyOHLC' was not declared in this scope
146 | CalculateDailyOHLC(
| ^~~~~~~~~~~~~~~~~~


DailyOHLCSinglePoint:
#include "sierrachart.h"

SCDLLName("Session High/Low")

SCSFExport scsf_DailyOHLCSinglePoint(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_ExtensionLinePropertiesSubgraph = sc.Subgraph[SC_LAST + 1];

  SCInputRef Input_UseThisIntradayChart = sc.Input[0];
  SCInputRef Input_DailyChartNumber = sc.Input[1];
  SCInputRef Input_UseSaturdayData = sc.Input[4];
  SCInputRef Input_NumberOfDaysToCalculate = sc.Input[5];
  SCInputRef Input_UseDaySessionOnly = sc.Input[7];
  SCInputRef Input_DisplayHighLowPriceLabels = sc.Input[8];
  SCInputRef Input_DrawExtensionLines = sc.Input[9];
  SCInputRef Input_UseSundayData = sc.Input[10];

  if (sc.SetDefaults)
  {
    sc.GraphName = "Daily OHLC - Single Point";

    sc.ScaleRangeType = SCALE_SAMEASREGION;
    sc.GraphRegion = 0;
    sc.ValueFormat = VALUEFORMAT_INHERITED;

    sc.AutoLoop = 0;//manual looping

    sc.Subgraph[SC_OPEN].Name = "Open";
    sc.Subgraph[SC_OPEN].DrawStyle = DRAWSTYLE_HIDDEN;
    sc.Subgraph[SC_OPEN].PrimaryColor = RGB(255,128,0);
    sc.Subgraph[SC_OPEN].DrawZeros = false;

    sc.Subgraph[SC_HIGH].Name = "High";
    sc.Subgraph[SC_HIGH].DrawStyle = DRAWSTYLE_TRIANGLE_DOWN;
    sc.Subgraph[SC_HIGH].PrimaryColor = RGB(0,255,0);
    sc.Subgraph[SC_HIGH].LineWidth =5;
    sc.Subgraph[SC_HIGH].DrawZeros = false;

    sc.Subgraph[SC_LOW].Name = "Low";
    sc.Subgraph[SC_LOW].DrawStyle = DRAWSTYLE_TRIANGLE_UP;
    sc.Subgraph[SC_LOW].PrimaryColor = RGB(255,0,0);
    sc.Subgraph[SC_LOW].LineWidth =5;
    sc.Subgraph[SC_LOW].DrawZeros = false;

    sc.Subgraph[SC_LAST].Name = "Close";
    sc.Subgraph[SC_LAST].DrawStyle = DRAWSTYLE_HIDDEN;
    sc.Subgraph[SC_LAST].PrimaryColor = RGB(128,0,255);
    sc.Subgraph[SC_LAST].DrawZeros = false;

    Subgraph_ExtensionLinePropertiesSubgraph.Name = "Extension Line Properties";
    Subgraph_ExtensionLinePropertiesSubgraph.DrawStyle = DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY;
    Subgraph_ExtensionLinePropertiesSubgraph.LineWidth = 1;
    Subgraph_ExtensionLinePropertiesSubgraph.PrimaryColor = RGB (255, 0, 255);
    Subgraph_ExtensionLinePropertiesSubgraph.DrawZeros = false;

    Input_UseThisIntradayChart.Name = "Use this Intraday Chart";
    Input_UseThisIntradayChart.SetYesNo(1);

    Input_DailyChartNumber.Name = "Daily Chart Number";
    Input_DailyChartNumber.SetChartNumber(1);

    Input_UseSaturdayData.Name = "Use Saturday Data";
    Input_UseSaturdayData.SetYesNo(0);

    Input_NumberOfDaysToCalculate.Name = "Number of Days To Calculate";
    Input_NumberOfDaysToCalculate.SetInt(50);
    Input_NumberOfDaysToCalculate.SetIntLimits(1, MAX_STUDY_LENGTH);

    Input_UseDaySessionOnly.Name = "Use Day Session Only";
    Input_UseDaySessionOnly.SetYesNo(0);

    Input_DisplayHighLowPriceLabels.Name = "Display High/Low Price Labels";
    Input_DisplayHighLowPriceLabels.SetYesNo(0);

    Input_DrawExtensionLines.Name = "Draw Extension Lines";
    Input_DrawExtensionLines.SetYesNo(false);

    Input_UseSundayData.Name = "Use Sunday Data";
    Input_UseSundayData.SetYesNo(false);

    return;
  }

  int InUseThisIntradayChart = Input_UseThisIntradayChart.GetYesNo();
  int InDailyChartNumber = Input_DailyChartNumber.GetInt();
  int InUseSaturdayData = Input_UseSaturdayData.GetYesNo();
  int InUseSundayData = Input_UseSundayData.GetYesNo();
  int InNumberOfDaysToCalculate = Input_NumberOfDaysToCalculate.GetInt();
  int InUseDaySessionOnly = Input_UseDaySessionOnly.GetYesNo();
  int DisplayPriceLabels = Input_DisplayHighLowPriceLabels.GetYesNo();
  int InDrawExtensionLines = Input_DrawExtensionLines.GetYesNo();

  float Open = 0.0f, High = 0.0f, Low = 0.0f, Close = 0.0f, Volume = 0.0f;
  int IntradayChartDate = 0;
  int IsValid = 1;


  int& IndexOfMostRecentHigh = sc.GetPersistentInt(1);
  int& IndexOfMostRecentLow = sc.GetPersistentInt(2);
  int& LineNumberOfMostRecentHighValue = sc.GetPersistentInt(3);
  int& LineNumberOfMostRecentLowValue = sc.GetPersistentInt(4);

  // we get chart data only once for speed
  SCGraphData DailyChartData;
  SCDateTimeArray DailyChartDateTime;

  if (!InUseThisIntradayChart)
  {
    sc.GetChartBaseData(InDailyChartNumber, DailyChartData);
    sc.GetChartDateTimeArray(InDailyChartNumber, DailyChartDateTime);
  }

  if (sc.IsFullRecalculation)
  {
    IndexOfMostRecentHigh = -1;
    IndexOfMostRecentLow = -1;
    LineNumberOfMostRecentHighValue = 0;
    LineNumberOfMostRecentLowValue = 0;
  }


  int StartIndex = sc.UpdateStartIndex;
  if (StartIndex != 0)
  {
    SCDateTime TradingDayStartDateTime = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[StartIndex]);
    StartIndex = sc.GetFirstIndexForDate(sc.ChartNumber, TradingDayStartDateTime.GetDate());
  }

  for (int Index = StartIndex; Index < sc.ArraySize; Index++ )
  {

    if (IntradayChartDate != sc.GetTradingDayDate(sc.BaseDateTimeIn[Index]))
    {
      // A new day has been entered, existing text drawings and extension lines need to remain. So remove the reference to those.
      if (IndexOfMostRecentHigh < Index || IndexOfMostRecentLow < Index)
      {
        IndexOfMostRecentHigh = -1;
        IndexOfMostRecentLow = -1;
        LineNumberOfMostRecentHighValue = 0;
        LineNumberOfMostRecentLowValue = 0;
      }

      IntradayChartDate = sc.GetTradingDayDate(sc.BaseDateTimeIn[Index]);

      IsValid =
        CalculateDailyOHLC(
        sc,
        IntradayChartDate,
        0,
        InNumberOfDaysToCalculate,
        InUseSaturdayData,
        InUseThisIntradayChart,
        InDailyChartNumber,
        DailyChartData,
        DailyChartDateTime,
        InUseDaySessionOnly,
        Open,
        High,
        Low,
        Close,
        Volume,
        0,
        InUseSundayData
        );

    }

    if (!IsValid)
      continue;


    if(sc.FormattedEvaluate(Open,sc.BaseGraphValueFormat,EQUAL_OPERATOR,sc.Open[Index], sc.BaseGraphValueFormat))
      sc.Subgraph[SC_OPEN][Index] = Open;
    else
      sc.Subgraph[SC_OPEN][Index] = 0.0;

    if(sc.FormattedEvaluate(High,sc.BaseGraphValueFormat,EQUAL_OPERATOR,sc.High[Index], sc.BaseGraphValueFormat))
    {
      sc.Subgraph[SC_HIGH][Index] = High;
      

      if (DisplayPriceLabels)
      {
        s_UseTool Tool;
        Tool.ChartNumber = sc.ChartNumber;
        Tool.DrawingType = DRAWING_TEXT;
        Tool.Region     = sc.GraphRegion;

        if (LineNumberOfMostRecentHighValue != 0)
          Tool.LineNumber = LineNumberOfMostRecentHighValue;

        Tool.BeginIndex = Index;
        Tool.BeginValue   = High;

        Tool.Text = " ";
        Tool.Text += sc.FormatGraphValue(High, sc.BaseGraphValueFormat);
        Tool.Color = sc.Subgraph[SC_HIGH].PrimaryColor;
        Tool.TextAlignment  = DT_LEFT | DT_VCENTER;

        Tool.AddMethod = UTAM_ADD_OR_ADJUST;

        sc.UseTool(Tool);

        LineNumberOfMostRecentHighValue = Tool.LineNumber;
      }

      if (InDrawExtensionLines)
      {
        if (IndexOfMostRecentHigh != -1)//First delete the existing line
          sc.DeleteLineUntilFutureIntersection(IndexOfMostRecentHigh, 1);

        sc.AddLineUntilFutureIntersection
          ( Index
          , 1
          , High
          , Subgraph_ExtensionLinePropertiesSubgraph.PrimaryColor
          , Subgraph_ExtensionLinePropertiesSubgraph.LineWidth
          , Subgraph_ExtensionLinePropertiesSubgraph.LineStyle
          , (Subgraph_ExtensionLinePropertiesSubgraph.LineLabel & LL_DISPLAY_VALUE) != 0
          , (Subgraph_ExtensionLinePropertiesSubgraph.LineLabel & LL_DISPLAY_NAME) != 0
          , "High"
          );
      }

      IndexOfMostRecentHigh = Index;
    }
    else
      sc.Subgraph[SC_HIGH][Index] = 0.0;


    if(sc.FormattedEvaluate(Low,sc.BaseGraphValueFormat,EQUAL_OPERATOR,sc.Low[Index], sc.BaseGraphValueFormat))
    {
      sc.Subgraph[SC_LOW][Index] = Low;

      if (DisplayPriceLabels)
      {
        s_UseTool Tool;
        Tool.ChartNumber = sc.ChartNumber;
        Tool.DrawingType = DRAWING_TEXT;
        Tool.Region     = sc.GraphRegion;

        if (LineNumberOfMostRecentLowValue != 0)
          Tool.LineNumber = LineNumberOfMostRecentLowValue;

        Tool.BeginIndex = Index;
        Tool.BeginValue   = Low;

        Tool.Text = " ";
        Tool.Text += sc.FormatGraphValue(Low, sc.BaseGraphValueFormat);
        Tool.Color = sc.Subgraph[SC_LOW].PrimaryColor;
        Tool.TextAlignment  = DT_LEFT | DT_VCENTER;

        Tool.AddMethod = UTAM_ADD_OR_ADJUST;

        sc.UseTool(Tool);

        LineNumberOfMostRecentLowValue = Tool.LineNumber;
      }

      if (InDrawExtensionLines)
      {
        if (IndexOfMostRecentLow != -1)//First delete the existing line
          sc.DeleteLineUntilFutureIntersection(IndexOfMostRecentLow, 2);

        sc.AddLineUntilFutureIntersection
          ( Index
          , 2
          , Low
          , Subgraph_ExtensionLinePropertiesSubgraph.PrimaryColor
          , Subgraph_ExtensionLinePropertiesSubgraph.LineWidth
          , Subgraph_ExtensionLinePropertiesSubgraph.LineStyle
          , (Subgraph_ExtensionLinePropertiesSubgraph.LineLabel & LL_DISPLAY_VALUE) != 0
          , (Subgraph_ExtensionLinePropertiesSubgraph.LineLabel & LL_DISPLAY_NAME) != 0
          , "Low"
          );
      }

      IndexOfMostRecentLow = Index;
    }
    else
      sc.Subgraph[SC_LOW][Index] = 0.0;


    if(sc.FormattedEvaluate(Close,sc.BaseGraphValueFormat,EQUAL_OPERATOR,sc.Close[Index], sc.BaseGraphValueFormat))
      sc.Subgraph[SC_LAST][Index] = Close;
    else
      sc.Subgraph[SC_LAST][Index] = 0.0;
  }
}

Is there something I need to change or update?

Thank you
[2024-09-30 18:28:51]
User688525 - Posts: 257
Hello Sierra Chart Engineering,
Can you confirm if this is a problem with Sierra Chart remote compiling?
Date Time Of Last Edit: 2024-10-02 03:03:59
[2024-10-03 16:11:27]
Sierra_Chart Engineering - Posts: 17143
You also need to include this function in your source code:
CalculateDailyOHLC

You can find it in :
\SCStudyFunctions.cpp
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-10-04 06:12:38]
User688525 - Posts: 257
Thank you. All working!

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

Login

Login Page - Create Account