Login Page - Create Account

Support Board


Date/Time: Fri, 29 Mar 2024 08:31:07 +0000



[User Discussion] - Bar Difference - Doji Only. Study programming help needed

View Count: 1176

[2014-12-28 23:32:18]
User265498 - Posts: 1
Hi, I'm using the Bar Difference study as the basis for a custom study which plots the bar difference ONLY when there is a doji bar on the price chart. All other plots on the Bar Difference study subgraph are kept blank so that I can overlay over a standard Bar Difference study with bar chart up/down coloring enabled so that my Bar Difference subgraph has different colors corresponding to the price chart's up bars, down bars and dojis.

The problem so far is that it wants to make the entire price chart all look like dojis :P And the plots on the actual subgraph don't work either.

The source is below:

#include "sierrachart.h"

SCDLLName("BarRangeDoji")

SCSFExport scsf_BarRangeDoji(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Difference = sc.Subgraph[0];
  SCInputRef InputData1 = sc.Input[0];
  SCInputRef InputData2 = sc.Input[1];
  SCInputRef InputData2Offset = sc.Input[3];

  if (sc.SetDefaults)
  {
    sc.GraphName = "BarRangeDoji";

    sc.GraphRegion = 1;
    sc.ValueFormat = 2;
    sc.AutoLoop = 1;

    Difference.Name = "Difference";
    Difference.DrawStyle = DRAWSTYLE_LINE;
    Difference.PrimaryColor = RGB(0,255,0);
    Difference.DrawZeros = true;

    InputData1.Name = "Input Data 1";
    InputData1.SetInputDataIndex(SC_HIGH);

    InputData2.Name = "Input Data 2";
    InputData2.SetInputDataIndex(SC_LOW);

    InputData2Offset.Name = "Input Data 2 Offset";
    InputData2Offset.SetInt(0);
    InputData2Offset.SetIntLimits(0, 100);

    return;
  }

  if (sc.Index < InputData2Offset.GetInt());
  if (sc.Close[sc.Index] = sc.Open[sc.Index]);
    return;

  Difference[sc.Index] = sc.BaseDataIn[InputData1.GetInputDataIndex()][sc.Index] -
    sc.BaseDataIn[InputData2.GetInputDataIndex()][sc.Index - InputData2Offset.GetInt()];
}


Also, I modified the existing Color Bar Open/Close study and made a custom study that disregards dojis altogether (attached). It might be useful to those of us who like a separate color for dojis, simply set the global or chart graphics settings to color up and down candlestick / bars the same color (your doji color), then add the study (place in "data" folder first) and set the coloring as "Same as base graph" then set your up and down bar colors how you want.


attachmentColor-Doji-bars_source-4.dll - Attached On 2014-12-28 23:27:23 UTC - Size: 11.5 KB - 281 views
[2015-10-29 15:14:46]
KhaosTrader - Posts: 128
prob is this


if (sc.Close[sc.Index] = sc.Open[sc.Index]);


should be


if (sc.Close[sc.Index] == sc.Open[sc.Index]);


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

Login

Login Page - Create Account