Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 04:13:52 +0000



Bid Ask Volume Ratio

View Count: 2295

[2013-06-19 15:12:58]
User28682 - Posts: 233
I would like to have this study update only when the bar completes, NOT intrabar.

Bid Ask Volume Ratio

Could you show me how to change the code for this? or make the change?

Thank you Tom


[2013-06-19 18:28:24]
Sierra Chart Engineering - Posts: 104368
In Sierra Chart, all studies are continuously updated unless they are programmed to ignore the last bar in the chart. This is possible. Here is the code for this study which has this code added:


SCSFExport scsf_BidAskVolumeRatio(SCStudyInterfaceRef sc)
{
  SCSubgraphRef VolRatioAvg = sc.Subgraph[0];
  SCSubgraphRef ZeroLine = sc.Subgraph[1];

  SCFloatArrayRef ExtraArrayRatio = sc.Subgraph[0].Arrays[0];

  SCInputRef InMALength = sc.Input[0];
  SCInputRef InMAType = sc.Input[1];

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

    sc.GraphName = "Bid Ask Volume Ratio";

    sc.StudyDescription = "Bid Ask Volume Ratio";
    
    sc.AutoLoop = 1;

    //During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 0;

    VolRatioAvg.Name = "Vol Ratio Avg";
    VolRatioAvg.DrawStyle = DRAWSTYLE_LINE;
    VolRatioAvg.PrimaryColor = RGB(0,255,0);
    VolRatioAvg.DrawZeros = false;

    ZeroLine.Name = "Zero Line";
    ZeroLine.DrawStyle = DRAWSTYLE_LINE;
    ZeroLine.PrimaryColor = RGB(255,0,255);
    ZeroLine.DrawZeros = true;
    
    InMALength.Name = "Length";
    InMALength.SetInt(14);
    InMALength.SetIntLimits(1,MAX_STUDY_LENGTH);


    InMAType.Name= "Moving Average Type";
    InMAType.SetMovAvgType(MOVAVGTYPE_EXPONENTIAL);
    
    return;
  }

  if(sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED)
    return;

  // Do data processing

  float UpVol = sc.AskVolume[sc.Index];
  float DownVol = sc.BidVolume[sc.Index];

  float TotalVol = UpVol + DownVol;
  if (TotalVol > 0)
    ExtraArrayRatio[sc.Index] = 100.0f * (UpVol - DownVol) / TotalVol;
  else
    ExtraArrayRatio[sc.Index] = 0.0f;
  
  sc.MovingAverage(ExtraArrayRatio, VolRatioAvg, InMAType.GetMovAvgType(), InMALength.GetInt());
}

To compile this study into a DLL file which can then be used, refer to this page:
https://www.sierrachart.com/index.php?l=doc/doc_BuildCustomStudiesDLL.html

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2013-06-19 21:12:33]
User28682 - Posts: 233
Hi

Thanks, so are you saying the code you sent me includes what is needed to make the bar update only at its close? Then I just need to compile the code into a DLL, or something simpler?

Thanks

Tom
[2013-06-19 21:13:52]
Sierra Chart Engineering - Posts: 104368
Yes it does include what is needed to have it only update on close.

You do need to compile it into a DLL using the instructions linked to.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2013-06-19 22:20:09]
User28682 - Posts: 233
Thanks! I think I actually got it to work. :-)

Tom
[2013-06-19 22:32:13]
User28682 - Posts: 233
If one inserts the volume study, you can see a text volume counter on the bottom of the study. Is there one for Ticks(the number of ticks)? I would want to see how many ticks are occurring.

Thanks

Tom

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

Login

Login Page - Create Account