Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 22:22:36 +0000



Post From: Unable to use drawing tool on custom chart with Bars displayed as main price

[2013-09-04 02:38:20]
maxpi - Posts: 175
This code builds some 100 tick bars when applied to a 1T chart. I can draw a line on the produced bars but I cannot draw a linear regression channel.

#include "sierrachart.h"

/*==========================================================================*/
SCDLLName("Custom Study DLL")
SCSFExport scsf_RxSubgraphBars(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Open         =sc.Subgraph[0];
  SCSubgraphRef High         =sc.Subgraph[1];
  SCSubgraphRef Low         =sc.Subgraph[2];
  SCSubgraphRef Last         =sc.Subgraph[3];
  
  if (sc.SetDefaults)
  {
    // Set the defaults
    
    sc.GraphName ="ForumCodeForBars";
    
    // This member indicates that this is a custom chart study.
    //  This can only be set when SetDefaults is true.
    sc.IsCustomChart       =1;    
    sc.DisplayAsMainPriceGraph  =1;
    sc.GraphRegion         =0;    
    sc.GraphDrawType       =GDT_CANDLESTICK;
    sc.ValueFormat         =VALUEFORMAT_INHERITED;
    sc.DrawZeros         =0;    
    sc.FreeDLL           =1;
    sc.AutoLoop         =0;
    sc.StandardChartHeader     =1;
    
    // Subgraphs

    Open.Name ="Open";
    Open.DrawStyle =DRAWSTYLE_LINE;

    High.Name ="High";
    High.DrawStyle =DRAWSTYLE_LINE;

    Low.Name ="Low";
    Low.DrawStyle =DRAWSTYLE_LINE;

    Last.Name ="Last";
    Last.DrawStyle =DRAWSTYLE_LINE;
    
    return;
  }
  
  for(int i =0; i<sc.ArraySize; i++)
  {
    if(i % 100 ==0)
    {
      sc.AddElements(1);
      sc.DateTimeOut[sc.OutArraySize -1] =sc.BaseDateTimeIn;
      High[sc.OutArraySize -1]      =0;
      Low[sc.OutArraySize -1]       =999999;
      Open[sc.OutArraySize -1]       =sc.Open;
      
      if(sc.High >High[sc.OutArraySize -1])
      {
        High[sc.OutArraySize -1] =sc.High;
      }
      
      if(sc.Low <Low[sc.OutArraySize -1])
      {
        Low[sc.OutArraySize -1] =sc.Low;
      }
    }
    Last[sc.OutArraySize -1] =sc.Close;
    i++;
  }
}