Login Page - Create Account

Support Board


Date/Time: Sun, 28 Apr 2024 17:39:49 +0000



Error wth remote build

View Count: 622

[2019-07-29 21:46:59]
User148625 - Posts: 2
Hi I am a new trail user and I am trying to customize and existing study. "scsf_HighLowForTimePeriodExtendedLines(SCStudyInterfaceRef sc)"


I have all the relevant code and I belive the appropriate header(s). When attempting to build without any of my code I get this:



In file included from sierrachart.h:15:0,
from Test2.cpp:3:
Test2.cpp: In function 'void scsf_OR(SCStudyInterfaceRef)':
scstructures.h:121:28: error: expected unqualified-id before string constant
#define SCDLLEXPORT extern "C" __declspec(dllexport)

^
scstructures.h:124:20: note: in expansion of macro 'SCDLLEXPORT'
#define SCSFExport SCDLLEXPORT void SCDLLCALL // Use SCSFExport when defining a study function

^
Test2.cpp:82:3: note: in expansion of macro 'SCSFExport'
SCSFExport scsf_HighLowForTimePeriodExtendedLines(SCStudyInterfaceRef sc)


Thanks for your help
[2019-07-30 02:32:59]
Sierra Chart Engineering - Posts: 104368
Post the entire source code file here for us to look at. Something is not formatted properly at the top.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-07-30 10:05:03]
User148625 - Posts: 2
THanks! Here is the code


//#include <scstudyfunctions.h>
#include "sierrachart.h"



// For reference, refer to this page:
// Advanced Custom Study Interface and Language (ACSIL)

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

//This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require.


SCSFExport scsf_OR(SCStudyInterfaceRef sc)
{
  SCSubgraphRef HighOfDay = sc.Subgraph[0];
  SCSubgraphRef LowOfDay = sc.Subgraph[1];

  SCInputRef Input_StartTime = sc.Input[0];
  SCInputRef Input_EndTime = sc.Input[1];
  SCInputRef Input_NumberDaysToCalculate = sc.Input[2];
  SCInputRef Input_UseLineStopTime = sc.Input[3];
  SCInputRef Input_Version = sc.Input[4];
  SCInputRef Input_LineStopTimeInput = sc.Input[5];
  SCInputRef Input_DisplayHighLowIncrementally = sc.Input[6];

  SCInputRef Input_InputDataHigh = sc.Input[7];
  SCInputRef Input_InputDataLow = sc.Input[8];
  SCInputRef Input_FridayEveningExtendsIntoSunday = sc.Input[9];

  if (sc.SetDefaults)
  {
    sc.GraphName      = "High/Low for Time Period - Extended";
    sc.GraphRegion      = 0;
    sc.AutoLoop        = 0;
    
    HighOfDay.Name = "High";
    HighOfDay.DrawStyle = DRAWSTYLE_STAIR_STEP;
    HighOfDay.PrimaryColor = RGB(0,255,0);
    HighOfDay. DrawZeros = false;
    
    LowOfDay.Name = "Low";
    LowOfDay.DrawStyle = DRAWSTYLE_STAIR_STEP;
    LowOfDay.PrimaryColor = RGB(255,0,255);
    LowOfDay.DrawZeros = false;

    Input_StartTime.Name = "Start Time";
    Input_StartTime.SetTime(0);

    Input_EndTime.Name = "End Time";
    Input_EndTime.SetTime(SECONDS_PER_DAY - 1);
  
    Input_NumberDaysToCalculate.Name= "Number Of Days To Calculate";
    Input_NumberDaysToCalculate.SetInt(120);

    Input_UseLineStopTime.Name = "Use Line Stop Time";
    Input_UseLineStopTime.SetYesNo(false);

    Input_LineStopTimeInput.Name = "Line Stop Time";
    Input_LineStopTimeInput.SetTime(SECONDS_PER_DAY - 1);

    Input_DisplayHighLowIncrementally.Name = "Display High Low Incrementally";
    Input_DisplayHighLowIncrementally.SetYesNo( true);

    Input_InputDataHigh.Name = "Input Data High";
    Input_InputDataHigh.SetInputDataIndex(SC_HIGH);

    Input_InputDataLow.Name = "Input Data Low";
    Input_InputDataLow.SetInputDataIndex(SC_LOW);

    Input_FridayEveningExtendsIntoSunday.Name = "Friday Evening Extends Into Sunday";
    Input_FridayEveningExtendsIntoSunday.SetYesNo(false);

    Input_Version.SetInt(2);

    return;
  }
    
    SCSFExport scsf_HighLowForTimePeriodExtendedLines(SCStudyInterfaceRef sc)
{
  SCSubgraphRef HighOfDay = sc.Subgraph[0];
  SCSubgraphRef LowOfDay = sc.Subgraph[1];

  SCInputRef Input_StartTime = sc.Input[0];
  SCInputRef Input_EndTime = sc.Input[1];
  SCInputRef Input_NumberDaysToCalculate = sc.Input[2];
  SCInputRef Input_UseLineStopTime = sc.Input[3];
  SCInputRef Input_Version = sc.Input[4];
  SCInputRef Input_LineStopTimeInput = sc.Input[5];
  SCInputRef Input_DisplayHighLowIncrementally = sc.Input[6];

  SCInputRef Input_InputDataHigh = sc.Input[7];
  SCInputRef Input_InputDataLow = sc.Input[8];
  SCInputRef Input_FridayEveningExtendsIntoSunday = sc.Input[9];

  if (sc.SetDefaults)
  {
    sc.GraphName      = "High/Low for Time Period - Extended";
    sc.GraphRegion      = 0;
    sc.AutoLoop        = 0;
    
    HighOfDay.Name = "High";
    HighOfDay.DrawStyle = DRAWSTYLE_STAIR_STEP;
    HighOfDay.PrimaryColor = RGB(0,255,0);
    HighOfDay. DrawZeros = false;
    
    LowOfDay.Name = "Low";
    LowOfDay.DrawStyle = DRAWSTYLE_STAIR_STEP;
    LowOfDay.PrimaryColor = RGB(255,0,255);
    LowOfDay.DrawZeros = false;

    Input_StartTime.Name = "Start Time";
    Input_StartTime.SetTime(0);

    Input_EndTime.Name = "End Time";
    Input_EndTime.SetTime(SECONDS_PER_DAY - 1);
  
    Input_NumberDaysToCalculate.Name= "Number Of Days To Calculate";
    Input_NumberDaysToCalculate.SetInt(120);

    Input_UseLineStopTime.Name = "Use Line Stop Time";
    Input_UseLineStopTime.SetYesNo(false);

    Input_LineStopTimeInput.Name = "Line Stop Time";
    Input_LineStopTimeInput.SetTime(SECONDS_PER_DAY - 1);

    Input_DisplayHighLowIncrementally.Name = "Display High Low Incrementally";
    Input_DisplayHighLowIncrementally.SetYesNo( true);

    Input_InputDataHigh.Name = "Input Data High";
    Input_InputDataHigh.SetInputDataIndex(SC_HIGH);

    Input_InputDataLow.Name = "Input Data Low";
    Input_InputDataLow.SetInputDataIndex(SC_LOW);

    Input_FridayEveningExtendsIntoSunday.Name = "Friday Evening Extends Into Sunday";
    Input_FridayEveningExtendsIntoSunday.SetYesNo(false);

    Input_Version.SetInt(2);

    return;
  }

  if (Input_Version.GetInt() == 1)
  {

    Input_InputDataHigh.SetInputDataIndex(SC_HIGH);
    Input_InputDataLow.SetInputDataIndex(SC_LOW);

    Input_Version.SetInt(2);
  }

  if (Input_NumberDaysToCalculate.GetInt() <= 0)
    Input_NumberDaysToCalculate.SetInt(10000);

  Input_StartTime.GetDateTime();
  Input_EndTime.GetDateTime();


  if (Input_StartTime.GetTime() <= Input_EndTime.GetTime()
    
    && (Input_StartTime.GetTime() < sc.StartTimeOfDay && Input_EndTime.GetTime() > sc.StartTimeOfDay)
    )
  {
    Input_StartTime.SetTime(sc.StartTimeOfDay);

    //Check if the start time is now greater than or equal to the end time in which case move the end time forward by 30 minutes from the start time.
    if (Input_StartTime.GetTime() >= Input_EndTime.GetTime())
    {
      Input_EndTime.SetTime(Input_StartTime.GetTime() + 30 * 60);
    }
  }
  
  float & HighOfPeriod = sc.GetPersistentFloat(1);
  float & LowOfPeriod = sc.GetPersistentFloat(2);

  SCDateTime DaysToCalculateStartDateTime = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.ArraySize - 1]) - (Input_NumberDaysToCalculate.GetInt() - 1);

  // Loop through chart bars starting at the Update Start Index
  for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; Index++ )
  {

    SCDateTime CurrentBarDateTime = sc.BaseDateTimeIn[Index];

    SCDateTime PreviousBarDateTime = sc.BaseDateTimeIn[max(0, Index - 1)];

    SCDateTime StartDateTimeOfCurrentIndex = sc.GetTradingDayStartDateTimeOfBar(CurrentBarDateTime);
    SCDateTime StartDateTimeOfPreviousIndex = sc.GetTradingDayStartDateTimeOfBar(PreviousBarDateTime);

    bool NeedReset = StartDateTimeOfCurrentIndex != StartDateTimeOfPreviousIndex
      || Index == 0;

    if (sc.BaseDateTimeIn[Index] < DaysToCalculateStartDateTime)
      continue;

    SCDateTime StartDateTime ;
    SCDateTime EndDateTime ;

    StartDateTime = CurrentBarDateTime.GetDate();
    EndDateTime = CurrentBarDateTime.GetDate();

    StartDateTime.SetTime(Input_StartTime.GetTime());
    EndDateTime.SetTime(Input_EndTime.GetTime());

    bool TimesAreReversed = false;
    if (Input_StartTime.GetTime() > Input_EndTime.GetTime())
    {
      TimesAreReversed = true;
      if (CurrentBarDateTime.GetTimeInSeconds() < Input_StartTime.GetTime())
      {
        StartDateTime -= DAYS;
      }
      else
      {
        EndDateTime += DAYS;
      }
    }

    if(TimesAreReversed && Input_FridayEveningExtendsIntoSunday.GetYesNo())
    {
      SCDateTime TradingDayDate(sc.GetTradingDayDate(CurrentBarDateTime));
      int DayOfWeek = TradingDayDate.GetDayOfWeek();
      if (DayOfWeek == MONDAY)//DayOfWeek == SUNDAY ||
      {
        StartDateTime -= 2 * DAYS;
        NeedReset = false;
      }

    }

    //reset
    if (NeedReset)
    {
      HighOfPeriod = -FLT_MAX;
      LowOfPeriod = FLT_MAX;    
    }


    bool OutsideTimeRange = true;
    if (CurrentBarDateTime >= StartDateTime && CurrentBarDateTime <= EndDateTime)
    {
      OutsideTimeRange = false;

      if (HighOfPeriod < sc.BaseData[Input_InputDataHigh.GetInputDataIndex()][Index])
        HighOfPeriod = sc.BaseData[Input_InputDataHigh.GetInputDataIndex()][Index];

      if (LowOfPeriod > sc.BaseData[Input_InputDataLow.GetInputDataIndex()][Index])
        LowOfPeriod = sc.BaseData[Input_InputDataLow.GetInputDataIndex()][Index];
    }


    SCDateTime NoDrawEndDateTime;
    if (Input_UseLineStopTime.GetYesNo())
    {
      NoDrawEndDateTime.SetDateTime(EndDateTime.GetDate() , Input_LineStopTimeInput.GetTime());

      if (CurrentBarDateTime >= NoDrawEndDateTime)
      {
        HighOfPeriod = -FLT_MAX;
        LowOfPeriod = FLT_MAX;
      }
    }

    // Set/update all values for current day
    int BackIndex = Index;
    while(true && HighOfPeriod != -FLT_MAX)
    {
      if(BackIndex < 0)
        break;

      SCDateTime IndexDateTime = sc.BaseDateTimeIn[BackIndex];

      if(!OutsideTimeRange && IndexDateTime < StartDateTime)
        break;

      HighOfDay[BackIndex] = HighOfPeriod;
      LowOfDay[BackIndex] = LowOfPeriod;


      if (OutsideTimeRange || Input_DisplayHighLowIncrementally.GetYesNo())
        break;

      BackIndex--;

      if(sc.UpdateStartIndex != 0)
        sc.EarliestUpdateSubgraphDataArrayIndex = BackIndex;
    }
  }

}
[2019-07-31 04:59:27]
Sierra Chart Engineering - Posts: 104368
You cannot put this function within a function:
scsf_HighLowForTimePeriodExtendedLines

That just does not work right at all. You have to understand the proper structure of a function, and what it is you intend to do.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

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

Login

Login Page - Create Account