Login Page - Create Account

Support Board


Date/Time: Mon, 10 Mar 2025 06:48:43 +0000



[Programming Help] - ACSIL Support For Non-Extended Line

View Count: 846

[2022-03-05 15:13:17]
mm3599 - Posts: 13
Hi -

I want to build a custom indicator that will allow n number of non-extended lines each with unique start/stop times (bars).
Is there a way to do this? I don't see any ASCIL members/attributes that might support this.

Thanks,
Mark
[2022-03-05 20:36:07]
Sierra Chart Engineering - Posts: 104368
You can actually use this ACSIL function:
ACSIL Interface Members - Functions: sc.AddLineUntilFutureIntersectionEx()

And then use this structure member to control where the line ends:
EndBarIndex

Or you could use ACSIL tools:
Using Drawing Tools From an Advanced Custom Study
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
[2022-03-14 02:46:19]
mm3599 - Posts: 13
Hello -

This is not rendering. Any idea what I have wrong?

Thanks,
Mark


SCDLLName("Reversal_Writer")

// return the type of drawstyle depending upon the timeframe
// IntraDay - 0
// Daily - 1
// Weekly - 2
// Monthly - 3
// Quarterly - 4
// Yearly - 5);

// LINESTYLE_SOLID
//LINESTYLE_DASH - weekly
//LINESTYLE_DOT - daily
//LINESTYLE_DASHDOT monthly
//LINESTYLE_DASHDOTDOT quarterly
// LINESTYLE_DASH - yearly


short GetDrawStyle(int reversal_timeframe_index, SCStudyGraphRef sc) {
  
  if (reversal_timeframe_index == 1) {
    return LINESTYLE_DOT;
  }
  else if (reversal_timeframe_index == 2) {
    return LINESTYLE_DASH;  
  }
  else if (reversal_timeframe_index == 3) {  
    return LINESTYLE_DASHDOT;  
  }
  else if (reversal_timeframe_index == 4) {
    return LINESTYLE_DASHDOTDOT;  
  }
  else if (reversal_timeframe_index == 5) {
    return LINESTYLE_DASH;  
  }
  else {
    return LINESTYLE_DOT;
  }
  
}

// return the color of the line
// ("Major;Minor;Double");

uint32_t GetColour(int reversal_type_index, bool bullish, SCStudyGraphRef sc) {
    
  
  if (reversal_type_index == 0 && bullish == 1) {
    return RGB (0, 255, 0);    
  }
  else if (reversal_type_index == 1 && bullish==1) {
    return RGB (128, 255, 128);
  }
  else if (reversal_type_index == 0 && bullish==0) {
    return RGB (255, 0, 255);  
  }
  else if (reversal_type_index == 1 && bullish==0) {
    return RGB (255, 128, 255);  
  }
  else if (reversal_type_index == 2) {
    return RGB (255, 128, 0);  
  }
  else {
    return RGB (255, 255, 255);  
  }
  
}





/*============================================================================*/
SCSFExport scsf_Reversals(SCStudyGraphRef sc)
{
  SCSubgraphRef Subgraph_ExtensionLineProperties = sc.Subgraph[SC_SUBGRAPHS_AVAILABLE - 1];
  SCInputRef Input_ReversalOne_TimeFrame = sc.Input[0];
  SCInputRef Input_ReversalOne_Type = sc.Input[1];
  SCInputRef Input_ReversalOne_Start = sc.Input[2];
  SCInputRef Input_ReversalOne_End = sc.Input[3];
  SCInputRef Input_ReversalOne_Value = sc.Input[4];
  SCInputRef Input_ReversalOne_IsElected = sc.Input[5];
  SCInputRef Input_Reversal_IsBullish = sc.Input[6];
  
  // Configuration
  if (sc.SetDefaults)
  {
    sc.GraphName = "Reversal Writer"; // study name shown in Chart Studies window

    sc.StudyDescription = "Create reversals of any type and timeframe";

    sc.AutoLoop = 1; // true

    sc.GraphRegion = 0; // zero based chart region number

    // 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;
    
    ///////////////////////////////////////////////
    
    Input_Reversal_IsBullish.Name = "Bullish Reversals";
    Input_Reversal_IsBullish.SetYesNo(0);
    
    Input_ReversalOne_TimeFrame.Name = "Reversal 1 TFs";
    Input_ReversalOne_TimeFrame.SetCustomInputStrings("IntraDay;Daily;Weekly;Monthly;Quarterly;Yearly");
    Input_ReversalOne_TimeFrame.SetCustomInputIndex(3);      
    
    Input_ReversalOne_Type.Name = "Reversal Type";
    Input_ReversalOne_Type.SetCustomInputStrings("Major;Minor;Double");
    Input_ReversalOne_Type.SetCustomInputIndex(1);      
        
    Input_ReversalOne_Start.Name = "Start Timestamp";
    Input_ReversalOne_Start.SetDateTime(0);
    
    Input_ReversalOne_End.Name = "End Timestamp";
    Input_ReversalOne_End.SetDateTime(0);
    
    Input_ReversalOne_Value.Name = "Reversal Price";
    Input_ReversalOne_Value.SetFloat(0.0f);
    
    Input_ReversalOne_IsElected.Name = "Elected Reversal";
    Input_ReversalOne_IsElected.SetYesNo(0);
    
  
    
    return;
  }
  
// Data processing

  sc.DataStartIndex = 0;


  int LineID = 10;    
  
  
  n_ACSIL::s_LineUntilFutureIntersection ReversalLine1;
  int ChartStartIndex = sc.GetContainingIndexForSCDateTime(1, Input_ReversalOne_Start.GetDateTime());
  int ChartEndIndex = sc.GetContainingIndexForSCDateTime(1, Input_ReversalOne_End.GetDateTime());   
  ReversalLine1.StartBarIndex = ChartStartIndex; // need bar index
  ReversalLine1.EndBarIndex = ChartEndIndex; //need bar index
  ReversalLine1.LineIDForBar = LineID;  
  ReversalLine1.LineValue = Input_ReversalOne_Value.GetFloat();
  ReversalLine1.LineColor = GetColour(Input_ReversalOne_Type.GetIndex(), Input_Reversal_IsBullish.GetYesNo(), sc);
  ReversalLine1.LineStyle = GetDrawStyle(Input_ReversalOne_TimeFrame.GetIndex(), sc);
  
  if (Input_ReversalOne_TimeFrame.GetIndex()==5) {
    ReversalLine1.LineWidth = 2;
  }
  else {
    ReversalLine1.LineWidth = 1;
  }

  sc.AddLineUntilFutureIntersectionEx(ReversalLine1);
  LineID++;
  
}

[2022-03-14 10:25:26]
User907968 - Posts: 838
Does it actually build? As, if this is the entirety of the code, then you are missing the required include directive from the top of the file.

#include "sierrachart.h"

Also, did you actually want to hardcode the chart numbers into these statements?


int ChartStartIndex = sc.GetContainingIndexForSCDateTime(1, Input_ReversalOne_Start.GetDateTime());
int ChartEndIndex = sc.GetContainingIndexForSCDateTime(1, Input_ReversalOne_End.GetDateTime());

Maybe change for below?


int ChartStartIndex = sc.GetContainingIndexForSCDateTime(sc.ChartNumber, Input_ReversalOne_Start.GetDateTime());
int ChartEndIndex = sc.GetContainingIndexForSCDateTime(sc.ChartNumber, Input_ReversalOne_End.GetDateTime());

I made these changes and built the study, it renders as expected.
Date Time Of Last Edit: 2022-03-14 10:26:41
[2022-03-15 02:39:14]
mm3599 - Posts: 13
Yes it did compile - I didn't c/p the include in the source code.

Your suggestion worked.

Thanks for your help.

Mark

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

Login

Login Page - Create Account