Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 04:03:42 +0000



[Programming Help] - ASCIL DOM Study change Label value and ladder location on each tic

View Count: 676

[2018-12-11 17:59:41]
User153286 - Posts: 44
I created a study that is outputting data to the Label column. It outputs the current traded price. The value does change but not its location in the DOM ladder. I am trying to get the location of the output to change on each tic. Is it possible to do on each tic? My environment is set up for tic data processing. Here is my example code....

#include "sierrachart.h"
SCDLLName("Custom Study DLL")
/*==========================================================================*/
SCSFExport scsf_DepthOfMarketData(SCStudyInterfaceRef sc) //scsf_DOMAccess
{
   SCSubgraphRef MyGraph= sc.Subgraph[0];

  if (sc.SetDefaults)
     sc.GraphName = "DOM Label example ";
     sc.StudyDescription = "DOM Label example ";
     sc.GraphRegion = 0;
     sc.AutoLoop = 0; // true
    sc.UsesMarketDepthData = 1; // access DOM data

    MyGraph.Name       = "MyGraph";
    MyGraph.PrimaryColor   = RGB(255,0,0);
    MyGraph.DrawStyle     = DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY;
    MyGraph.LineLabel     = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_DOM_LABELS_COLUMN | LL_DISPLAY_CUSTOM_VALUE_AT_Y;

    return;
  }

  // Do data processing
    int aindex = sc.ArraySize-1; //current bar index
//    MyGraph.Data[aindex] = 123;
    MyGraph.Data[aindex] = sc.Close[aindex]; //current bar value
    MyGraph.Arrays[0][aindex] = sc.Close[aindex];
}
Date Time Of Last Edit: 2018-12-11 18:00:18
[2018-12-12 06:39:47]
User153286 - Posts: 44
UPDATE - I figured out my issue which turned out to be 2 fold
1.) I was plotting Close/Last but thinking Bid/Ask so it was working just fine but....
2.) I had the Data value to plot and Location to plot at mixed up which I only noticed after I started working on it again

Here is working code: (big trees come from little acorns)

Remember You need to have the "Label Column" in the DOM Trade->Customize Chart/Trade DOM Columns



#include "sierrachart.h"
SCDLLName("Custom Study DLL")
/*==========================================================================*/
SCSFExport scsf_DepthOfMarketData(SCStudyInterfaceRef sc) //scsf_DOMAccess
{
   SCSubgraphRef MyGraph= sc.Subgraph[0];

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

     sc.GraphName = "DOM Label example ";
     sc.StudyDescription = "DOM Label example ";
     sc.GraphRegion = 0; // overlays on main graph
     sc.AutoLoop = 0; // do not understand this and the docs suck on this subject
    sc.UsesMarketDepthData = 1; // access DOM data

    MyGraph.Name     = "MyGraph";
    MyGraph.PrimaryColor   = RGB(255,0,0);
// the following are in the help docs and are the magic that make it work, sorta smells like a hack, but it works!
    MyGraph.DrawStyle  = DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY;
    MyGraph.LineLabel   = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_DOM_LABELS_COLUMN | LL_DISPLAY_CUSTOM_VALUE_AT_Y;

    return;
  }

  // Do data processing


    int aindex = sc.ArraySize-1; // most current bar if you will

    float bidprice = sc.Bid;
    float thevalue = (float) sc.GetBidMarketDepthStackPullValueAtPrice(bidprice);

// again buried in the docs and is how to get the data and location defined on/in ladder
    MyGraph.Data[aindex] = thevalue; // value must be a number and displays with 2 decimals
    MyGraph.Arrays[0][aindex] = bidprice; // ladder location or price

//debug
//    SCString Buffer;
//    Buffer.Format("bidprice=%f thevalue=%f",bidprice, thevalue);
//    sc.AddMessageToLog(Buffer,1);


}

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

Login

Login Page - Create Account