Login Page - Create Account

Support Board


Date/Time: Mon, 10 Mar 2025 07:19:39 +0000



Post From: ACSIL Support For Non-Extended Line

[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++;
  
}