Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 21:11:44 +0000



Compile error 2098

View Count: 744

[2020-05-06 12:41:20]
ertrader - Posts: 645
Hi Support....my custom study no longer compiles in 2098. It shows errors with SCDateTime and looks like the same error for each time it is set. I've looked at the documentation but it is unclear what needs to change. Can you please help?

ACSIL Interface Members - Variables and Arrays: sc.BaseDateTimeIn[]

-- Starting remote build of Custom Studies Source files: AutoTradeOrderFlowV3.cpp. 64-bit -- 08:33:38
Allow time for the server to compile the files and build the DLL.

The remote build did not succeed. Result:

AutoTradeOrderFlowV3.cpp: In function 'void scsf_AutoTradeOrderFlowV3(SCStudyInterfaceRef)':
AutoTradeOrderFlowV3.cpp:1284:73: error: ambiguous overload for 'operator-' (operand types are 'SCDateTime' and 'double')
SCDateTime CurrentPeriodStartDateTime = sc.BaseDateTimeIn[Index] - 1*DAYS + 1*SECONDS;
^
AutoTradeOrderFlowV3.cpp:1284:73: note: candidate: operator-(double, double) <built-in>
In file included from scstructures.h:98:0,
from sierrachart.h:19,
from AutoTradeOrderFlowV3.cpp:1:
scdatetime.h:1476:19: note: candidate: SCDateTime SCDateTime::operator-(const SCDateTime&) const
inline SCDateTime SCDateTime::operator -(const SCDateTime& DateTime) const
^
AutoTradeOrderFlowV3.cpp:1302:58: error: ambiguous overload for 'operator+' (operand types are 'SCDateTime' and 'double')
RollingStartDateTime = sc.BaseDateTimeIn[Index] + (sc.SecondsPerBar - 1) * SECONDS;
^
AutoTradeOrderFlowV3.cpp:1302:58: note: candidate: operator+(double, double) <built-in>
In file included from scstructures.h:98:0,
from sierrachart.h:19,
from AutoTradeOrderFlowV3.cpp:1:
scdatetime.h:1482:19: note: candidate: SCDateTime SCDateTime::operator+(const SCDateTime&) const
inline SCDateTime SCDateTime::operator +(const SCDateTime& DateTime) const
^
AutoTradeOrderFlowV3.cpp:1310:60: error: ambiguous overload for 'operator-' (operand types are 'SCDateTime' and 'double')
RollingStartDateTime = sc.BaseDateTimeIn[Index+1] - 1*SECONDS;
^
AutoTradeOrderFlowV3.cpp:1310:60: note: candidate: operator-(double, double) <built-in>
In file included from scstructures.h:98:0,
from sierrachart.h:19,
from AutoTradeOrderFlowV3.cpp:1:
scdatetime.h:1476:19: note: candidate: SCDateTime SCDateTime::operator-(const SCDateTime&) const
inline SCDateTime SCDateTime::operator -(const SCDateTime& DateTime) const
^
AutoTradeOrderFlowV3.cpp: In function 'void GetIndexForStartofDayPeriodForDaysBack(SCStudyInterfaceRef, SCDateTime, int, bool, int, int&)':
AutoTradeOrderFlowV3.cpp:1808:63: error: ambiguous overload for 'operator-' (operand types are 'const SCDateTime' and 'double')
SCDateTime PriorPeriodStartDateTime = InitialStartDateTime - DaysBack * DAYS;
^
AutoTradeOrderFlowV3.cpp:1808:63: note: candidate: operator-(double, double) <built-in>
In file included from scstructures.h:98:0,
from sierrachart.h:19,
from AutoTradeOrderFlowV3.cpp:1:
scdatetime.h:1476:19: note: candidate: SCDateTime SCDateTime::operator-(const SCDateTime&) const
inline SCDateTime SCDateTime::operator -(const SCDateTime& DateTime) const
^
AutoTradeOrderFlowV3.cpp:1809:65: error: ambiguous overload for 'operator+' (operand types are 'SCDateTime' and 'double')
SCDateTime PriorPeriodEndDateTime = PriorPeriodStartDateTime + 1 * DAYS - 1 * SECONDS;
^
AutoTradeOrderFlowV3.cpp:1809:65: note: candidate: operator+(double, double) <built-in>
In file included from scstructures.h:98:0,
from sierrachart.h:19,
from AutoTradeOrderFlowV3.cpp:1:
scdatetime.h:1482:19: note: candidate: SCDateTime SCDateTime::operator+(const SCDateTime&) const
inline SCDateTime SCDateTime::operator +(const SCDateTime& DateTime) const
^

-- End of Build -- 08:33:42
Date Time Of Last Edit: 2020-05-06 12:46:23
[2020-05-06 13:54:56]
Ackin - Posts: 1865
Hi, look:
Required SCDateTime Changes for ACSIL | Post: 209951

I hope this helped you
[2020-05-06 15:10:39]
ertrader - Posts: 645
Yes.. .thank you!
[2020-05-06 15:47:50]
ertrader - Posts: 645
I'm still getting compile errors after changing.


AutoTradeOrderFlowV3.cpp: In function 'void scsf_AutoTradeOrderFlowV3(SCStudyInterfaceRef)':
AutoTradeOrderFlowV3.cpp:1304:57: error: ambiguous overload for 'operator+' (operand types are 'SCDateTime' and 'double')
RollingStartDateTime = sc.BaseDateTimeIn[Index] + (sc.SecondsPerBar - 1) * SCDateTime::SECONDS(1);
^
-----------------------
Here is the relevant code. Any ideas on how to updates? So confusing!
-------------------------

SCDateTime RollingStartDateTime = 0;

if (sc.AreTimeSpecificBars() && sc.SecondsPerBar != 0)
{

RollingStartDateTime = sc.BaseDateTimeIn[Index] + (sc.SecondsPerBar - 1) * SCDateTime::SECONDS(1);                
RollingStartDateTime -= TimePeriodLength.GetInt() * SCDateTime::MINUTES(1);                
}

---------------------
This is the old code
----------------------
SCDateTime RollingStartDateTime = 0;

if (sc.AreTimeSpecificBars() && sc.SecondsPerBar != 0)
{
RollingStartDateTime = sc.BaseDateTimeIn[Index] + (sc.SecondsPerBar - 1) * SECONDS;
          
RollingStartDateTime -= TimePeriodLength.GetInt() * MINUTES;
            
}
Date Time Of Last Edit: 2020-05-06 15:57:21
[2020-05-06 16:02:57]
Ackin - Posts: 1865
Any ideas on how to updates? So confusing!

if (sc.AreTimeSpecificBars() && sc.SecondsPerBar != 0)
{
  RollingStartDateTime = sc.BaseDateTimeIn[Index] + SCDateTime::SECONDS(sc.SecondsPerBar - 1);
  RollingStartDateTime.SubtractMinutes(TimePeriodLength.GetInt());
}

Date Time Of Last Edit: 2020-05-06 16:04:58
[2020-05-06 16:07:58]
Ackin - Posts: 1865
Any other compile errors?
[2020-05-06 16:20:48]
ertrader - Posts: 645
You rock! This section is the last area I believe. These two lines fail:
SCDateTime PriorPeriodStartDateTime = InitialStartDateTime - DaysBack * DAYS;
SCDateTime PriorPeriodEndDateTime = PriorPeriodStartDateTime + 1 * DAYS - 1 * SECONDS;

It seems SC documentation needs several updates on this topic. Without your help, frankly I would not have been able to update. Thank you!


--------------------------
Here is the complete function
-----------------------------

void GetIndexForStartofDayPeriodForDaysBack
( SCStudyInterfaceRef sc
, const SCDateTime InitialStartDateTime
, const int NumDaysToInclude
, const bool ExcludeWeekends
, const int MinimumRequiredTimePeriodInDayAsPercent
, int& r_InitialBarIndex
)
{
  
  int DaysBack = 0;

  for (int DaysCount = 1; DaysCount < NumDaysToInclude; ++DaysCount)
  {
    for (int Iterations = 10; Iterations > 0; --Iterations)
    {
      DaysBack++;

      SCDateTime PriorPeriodStartDateTime = InitialStartDateTime - DaysBack * DAYS;
      SCDateTime PriorPeriodEndDateTime = PriorPeriodStartDateTime + 1 * DAYS - 1 * SECONDS;

      const SCDateTime TradingDayDate = sc.GetTradingDayDate(PriorPeriodStartDateTime);

      r_InitialBarIndex = sc.GetNearestMatchForSCDateTime(sc.ChartNumber, PriorPeriodStartDateTime);

      if (ExcludeWeekends && TradingDayDate.IsWeekend())
        continue;

      const int PriorPeriodLastIndex = sc.GetNearestMatchForSCDateTime(sc.ChartNumber, PriorPeriodEndDateTime);

      const double ActualTimeSpan
        = sc.CalculateTimeSpanAcrossChartBars
          ( r_InitialBarIndex
          , PriorPeriodLastIndex
          );

      //If there is a sufficient amount of data in this time period
      if (ActualTimeSpan > 1*DAYS * (MinimumRequiredTimePeriodInDayAsPercent * 0.01))
        break;
    }
  }
}
Date Time Of Last Edit: 2020-05-06 16:25:44
[2020-05-06 16:32:47]
Ackin - Posts: 1865

SCDateTime PriorPeriodStartDateTime=InitialStartDateTime-SCDateTime::DAYS(DaysBack);
SCDateTime PriorPeriodEndDateTime=PriorPeriodStartDateTime+SCDateTime::DAYS(1)-SCDateTime::SECONDS(1);

[2020-05-06 16:41:50]
ertrader - Posts: 645
Yes, those two were the last...compiles now
[2020-05-06 16:57:49]
Ackin - Posts: 1865
You will maybe have a problem with this line:

if (ActualTimeSpan > 1*DAYS * (MinimumRequiredTimePeriodInDayAsPercent * 0.01))
*note

I'm not sure there.. I would probably use SCDateTime::DAYS(MinimumRequiredTimePeriodInDayAsPercent * 0.01) or command InitialStartDateTime.SubtractDays()




//referenced in the header file scdatetime.h what is it



inline SCDateTime& SCDateTime::SubtractDays(int Days)
{
  m_dt -= Days*DAYS;
  return *this;
}


Good luck ;)


*note
This part is weird .... I don't know why the developer refers to percentages. I would put a fixed time unit there ... but it doesn't matter ...
Date Time Of Last Edit: 2020-05-06 17:03:19
[2020-05-06 17:29:54]
ertrader - Posts: 645
Thank you.. I saw that too but was not sure how best to update it. Oddly, it compiles without an error
[2020-05-11 12:11:26]
Sierra Chart Engineering - Posts: 104368
We have done some updates to the documentation here related to the changes for SCDateTime:
Working with the SCDateTime Variables and Values

More updates are needed.

Regarding post #10, here is an example of how to do this:
      const SCDateTime ActualTimeSpan(sc.CalculateTimeSpanAcrossChartBars
      (r_InitialBarIndex, PriorPeriodLastIndex));

      //If there is a sufficient amount of data in this time period
      if (ActualTimeSpan > SCDateTime::SECONDS_Fraction(MinimumRequiredTimePeriodInDayAsPercent * 0.01 * SECONDS_PER_DAY))
      {
        break;
      }

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
Date Time Of Last Edit: 2020-05-11 12:11:52

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

Login

Login Page - Create Account