Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 17:36:23 +0000



Study Angle Reset

View Count: 1144

[2017-05-17 21:18:03]
Neo - Posts: 198
Currently, the Study Angle continues on from the last trading day. So when a gap is present( which is most of the time), it adds a large skew to the start of the current day.

Is it possible to add an input to reset at the start of a new session?
imageSPY [M] 1 Min #5 2017-05-17 17_00_04.184.png / V - Attached On 2017-05-17 21:16:14 UTC - Size: 49.47 KB - 335 views
[2017-05-17 22:03:01]
Sierra Chart Engineering - Posts: 104368
This is not something we have any time for.

If you want to pay a developer to do this, we can refer you to someone.
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
[2017-05-17 22:09:01]
Neo - Posts: 198
I understand and have no issues paying. Please let me know the developer you are referring to.
[2017-05-19 06:08:26]
Sierra Chart Engineering - Posts: 104368
It probably would be easiest for us to add a new Input to support this. Rather than referring and explaining to the other programmer how to do this.
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
[2017-05-19 09:49:52]
Neo - Posts: 198
Ok. Let me know how you want to proceed.
[2017-05-19 15:47:04]
Sierra Chart Engineering - Posts: 104368
This will be out in the next release.
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
[2017-06-12 23:35:55]
Neo - Posts: 198
What is the logic for adding an input to "skip Calculation at Start of Trading Day", Instead of a "Reset at Start of Trading day"?

"Skip Calculation at Start of Trading Day is not the right solution"- If for example the study angle is based on an input length of 10, it's still going to look back at values from the previous trading day, thus skewing the data for today( especially when there's a gap down at the open).
[2017-06-13 00:14:33]
Sierra Chart Engineering - Posts: 104368
Refer to the documentation for the meaning of that Input.

We cannot spend further time on this. If it does not do what you want, you will need to implement this yourself or hire a programmer.
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
[2017-06-14 08:03:00]
Neo - Posts: 198
My trouble with your implementation is that it only skips the calculation at the start of the session, and will still look back at data from the previous day. So a gap day creates a big skew, especially when looking at the cumulative result( See image below- Green vs Yellow( my version)

I have taken your advice and implemented the changes myself. The only trouble is the performance is poor. Could you make any comments on how I could improve this?


#include "sierrachart.h"

SCDLLName("StudyAngleReset");


SCSFExport scsf_StudyAngle(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Angle = sc.Subgraph[0];
  SCSubgraphRef ZeroLine = sc.Subgraph[1];
  
  SCInputRef InInputData = sc.Input[0];
  SCInputRef InLength = sc.Input[1];
  SCInputRef InValuePerPoint = sc.Input[2];
  SCInputRef ResetAtSessionStart = sc.Input[3];
  
  if (sc.SetDefaults)
  {
    // xx
    
    sc.GraphName = "Study Angle";
    sc.AutoLoop = 1;
    
    // xx
    sc.FreeDLL = 0;
    
    Angle.Name = "Angle";
    Angle.DrawStyle = DRAWSTYLE_LINE;
    Angle.PrimaryColor = RGB(0,255,0);
    Angle.DrawZeros= false;
    
    ZeroLine.Name = "Zero Line";
    ZeroLine.DrawStyle = DRAWSTYLE_LINE;
    ZeroLine.PrimaryColor = RGB(255,0,255);
    ZeroLine.DrawZeros= true;
    
    InInputData.Name = "Input Data";
    InInputData.SetInputDataIndex(0);
    
    InLength.Name = "Length";
    InLength.SetInt(10);
    InLength.SetIntLimits(1,MAX_STUDY_LENGTH);
    
    InValuePerPoint.Name = "Value Per Point";
    InValuePerPoint.SetFloat(1.0f);

    ResetAtSessionStart.Name = "Reset at Start of Trading Day";
    ResetAtSessionStart.SetYesNo(0);
    
    return;
  }
  
  int Length = InLength.GetInt();
  
  sc.DataStartIndex = Length;
  
  if (InValuePerPoint.GetFloat() == 0.0f)
    InValuePerPoint.SetFloat(0.01f);
  
  SCDateTime NextSessionStart = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.DataStartIndex - 1]) + 1*DAYS;

  if (sc.DataStartIndex == 0)
  {
    Angle[0] = 0;
  }
  
  for (int Index = max(sc.DataStartIndex, 1); Index < sc.ArraySize; Index++)
  {
    if (ResetAtSessionStart.GetYesNo() != 0)
    {
      SCDateTime IndexDateTime = sc.BaseDateTimeIn[Index];
      SCDateTime LengthDateTime = sc.BaseDateTimeIn[Index - Length];

      if (IndexDateTime >= NextSessionStart || (LengthDateTime < NextSessionStart - 1 * DAYS || LengthDateTime >= NextSessionStart))
      {
        Angle[Index] = 0;

        NextSessionStart = sc.GetTradingDayStartDateTimeOfBar(IndexDateTime) + 1*DAYS;
      }
      else
      {
        SCFloatArrayRef InData = sc.BaseData[InInputData.GetInputDataIndex()];

        float BackValue = InData[Index - Length];
        float CurrentValue = InData[Index];

        float PointChange = (CurrentValue - BackValue) / InValuePerPoint.GetFloat();

        Angle[Index] = (float)(atan2((double)PointChange, (double)Length) * 180.0 / M_PI);
      }
    }
    else
    {

          SCFloatArrayRef InData = sc.BaseData[InInputData.GetInputDataIndex()];

          float BackValue = InData[Index - Length];
          float CurrentValue = InData[Index];

          float PointChange = (CurrentValue - BackValue) / InValuePerPoint.GetFloat();

          Angle[Index] = (float)(atan2((double)PointChange, (double)Length) * 180.0 / M_PI);

    }
  }  
}

Date Time Of Last Edit: 2017-06-14 08:11:50
imagestudyanglereset.png / V - Attached On 2017-06-14 08:11:29 UTC - Size: 119.59 KB - 290 views
Attachment Deleted.
Attachment Deleted.
[2017-06-14 19:13:35]
Sierra Chart Engineering - Posts: 104368
You should never be using code like this with automatic looping:
for (int Index = max(sc.DataStartIndex, 1); Index < sc.ArraySize; Index++)

It also does not make sense to be using sc.DataStartIndex in a for loop.

Refer to this page:
http://www.sierrachart.com/index.php?page=doc/ACS_ArraysAndLooping.html

We made a change to the study to accomplish what you want. This will be out in the next release.
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