Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 17:29:35 +0000



Post From: Help with Study - but attached working Keltner Channels with Hull MID

[2020-06-19 00:04:27]
Flipper - Posts: 65
You have a few small errors

'SC' was not declared in this scope
SCInputRef HULL_LENGTH = SC.INPUT[0];

ACSIL Interface Members Structure have lower case sc not upper SC like you used. You had them lower case in the first study and for some reason changed it in the second one.
so all your subgraph and input decelerations referenced nothing.

Then you had a syntax error in the all of the band calculations with a missing closing bracket.



// The top of every source code file must include this line
#include "sierrachart.h"


/*****************************************************************************

  This file contains Sierra Chart custom study template functions and example functions.
  
  For reference, please refer to the Advanced Custom Study Interface
  and Language documentation on the Sierra Chart website.
  
*****************************************************************************/

//*****************************************************************************
// 06/22/13. ATRBands Version 1.0. In response to Sierra support forum question
// ATR Bands
// Compiled with MSVS 2010 Pro with SC v990 headers.
// Tested with SC v990
// Support Forum user: StevieD
//******************************************************************************
// BASED ON ABOVE STUDY BUT SIGNIFICANTLY CHANGED

// This line is required. Change the text within the quote
// marks to what you want to name your group of custom studies.
SCDLLName("DTEK DOUBLE HULL MID ATR BANDS")

SCSFExport scsf_DTEK_V3_HULL_DOUBLE_KELTNER_BANDS(SCStudyGraphRef sc)
{
  // Section 1 - Set the configuration variables
  SCSubgraphRef Hull_AVG = sc.Subgraph[0];
  SCSubgraphRef ATR_CALC_VALUE = sc.Subgraph[1];
  SCSubgraphRef BAND_A_UPPER = sc.Subgraph[2];
  SCSubgraphRef BAND_A_LOWER = sc.Subgraph[3];
  SCSubgraphRef BAND_B_UPPER = sc.Subgraph[4];
  SCSubgraphRef BAND_B_LOWER = sc.Subgraph[5];

  SCInputRef HULL_PRICE = sc.Input[0];
  SCInputRef HULL_LENGTH = sc.Input[1];
  SCInputRef ATR_AVG_TYPE = sc.Input[2];
  SCInputRef ATR_BAND_A_MULT = sc.Input[3];
  SCInputRef ATR_BAND_B_MULT = sc.Input[4];


  if (sc.SetDefaults)
  {
    // Set the configuration and defaults

    sc.GraphName = "HULL_WITH_DOUBLE_ATR_BANDS";
    sc.StudyDescription = "HULL_WITH_DOUBLE_ATR_BANDS";


    // 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;

    sc.GraphRegion = 0;
    sc.ValueFormat = VALUEFORMAT_INHERITED;

    Hull_AVG.Name = "HULL MID AVG";
    Hull_AVG.PrimaryColor = COLOR_GREEN;
    Hull_AVG.DrawStyle = DRAWSTYLE_LINE;
    Hull_AVG.LineWidth = 2;

    // Named but ignored. For tool value window only.
    // This study draws on the main price graph, not a region.
    // Unless ATR value is similar to price scale, chart will distort, as it should.
    ATR_CALC_VALUE.Name = "ATR Value";
    ATR_CALC_VALUE.DrawStyle = DRAWSTYLE_IGNORE;

    BAND_A_UPPER.Name = "OUTER BAND A UPPER";
    BAND_A_UPPER.PrimaryColor = RGB(255, 165, 0);
    BAND_A_UPPER.DrawStyle = DRAWSTYLE_LINE;
    //sc.Subgraph[2].LineStyle = LINESTYLE_DASH;
    BAND_A_UPPER.LineWidth = 1;

    BAND_A_LOWER.Name = "OUTER BAND A LOWER";
    BAND_A_LOWER.PrimaryColor = RGB(169, 169, 169);
    BAND_A_LOWER.DrawStyle = DRAWSTYLE_LINE;
    //sc.Subgraph[3].LineStyle = LINESTYLE_DASH;
    BAND_A_LOWER.LineWidth = 1;

    BAND_B_UPPER.Name = "INNER BAND B UPPER";
    BAND_B_UPPER.PrimaryColor = RGB(169, 169, 169);
    BAND_B_UPPER.DrawStyle = DRAWSTYLE_LINE;
    //sc.Subgraph[4].LineStyle = LINESTYLE_DASH;
    BAND_B_UPPER.LineWidth = 1;

    BAND_B_LOWER.Name = "INNER BAND B LOWER";
    BAND_B_LOWER.PrimaryColor = RGB(205, 92, 92);
    BAND_B_LOWER.DrawStyle = DRAWSTYLE_LINE;
    //sc.Subgraph[5].LineStyle = LINESTYLE_DASH;
    BAND_B_LOWER.LineWidth = 1;

    //INPUTS
    HULL_PRICE.Name = "HULL PRICE TYPE";
    HULL_PRICE.SetInputDataIndex(SC_LAST);

    HULL_LENGTH.Name = "HULL AVG Length";
    HULL_LENGTH.SetInt(30);
    HULL_LENGTH.SetIntLimits(1, 600);
    HULL_LENGTH.SetDescription("MA Length.<br>\
                  Displays as the Mid-Band and used to calculate ATR value.");

    ATR_AVG_TYPE.Name = "ATR CALCULATION AVERAGE TYPE";
    ATR_AVG_TYPE.SetMovAvgType(MOVAVGTYPE_WEIGHTED);
    ATR_AVG_TYPE.SetDescription("AVG TYPE USED TO COMPUTE ATR.<br>\
                  Can be diffent than average type");

    //sc.Input[2].Name = "ATR LOOKBACK CALC LENGTH";
    //sc.Input[2].setInt(30);
    //sc.Input[2].SetIntLimits(1,50);
    //sc.Input[2].SetDescription("AVG TYPE USED TO COMPUTE ATR. <br>\
                  Can differ from Hull Length if desired <br\
                  I always find this useful to separate ATR calc Length from MID");

    ATR_BAND_A_MULT.Name = "OUTER BANDS Multiplier";
    ATR_BAND_A_MULT.SetFloat(2.0);
    ATR_BAND_A_MULT.SetFloatLimits(0.1f, 10.0f);
    ATR_BAND_A_MULT.SetDescription("OUTER Band MULT - example 2.0 is HULL AVG +- 2.0 * ATR <br>\
                    rounded to neares tick size");

    ATR_BAND_B_MULT.Name = "INNER BANDS Multiplier";
    ATR_BAND_B_MULT.SetFloat(1.5);
    ATR_BAND_B_MULT.SetFloatLimits(0.1f, 10.0f);
    ATR_BAND_B_MULT.SetDescription("INNER Band MULT - example 1.5 is MID +- 1.5 * ATR <br>\
                    rounded to neares tick size");

    sc.AutoLoop = 1; // true

    return;
  }

  // Section 2 - Do data processing

  sc.DataStartIndex = HULL_LENGTH.GetInt();

  sc.HullMovingAverage(sc.BaseData[HULL_PRICE.GetInputDataIndex()], Hull_AVG, HULL_LENGTH.GetInt());
  //sc.MovingAverage(sc.BaseDataIn[SC_LAST],sc.Subgraph[0],sc.Input[1].GetMovAvgType(),sc.Input[0].GetInt());

  sc.ATR(sc.BaseDataIn, ATR_CALC_VALUE, HULL_LENGTH.GetInt(), ATR_AVG_TYPE.GetMovAvgType());

  //OUTBAND UPPER BAND
  BAND_A_UPPER[sc.Index] = sc.RoundToTickSize((Hull_AVG[sc.Index] + ATR_CALC_VALUE[sc.Index] * ATR_BAND_A_MULT.GetFloat()), sc.TickSize);
  //OUTBERBAND UPLOWER BAND
  BAND_A_LOWER[sc.Index] = sc.RoundToTickSize((Hull_AVG[sc.Index] - ATR_CALC_VALUE[sc.Index] * ATR_BAND_A_MULT.GetFloat()), sc.TickSize);
  //INNERBAND UPPER BAND
  BAND_B_UPPER[sc.Index] = sc.RoundToTickSize((Hull_AVG[sc.Index] + ATR_CALC_VALUE[sc.Index] * ATR_BAND_B_MULT.GetFloat()), sc.TickSize);
  //INNERBAND LOWER BAND
  BAND_B_LOWER[sc.Index] = sc.RoundToTickSize((Hull_AVG[sc.Index] - ATR_CALC_VALUE[sc.Index] * ATR_BAND_B_MULT.GetFloat()), sc.TickSize);

}