Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 19:56:48 +0000



DeltaMomentum Source Code

View Count: 1079

[2015-07-10 02:40:15]
Acro - Posts: 436
Hi,

There is a really interesting study in the usercontributed studies DLL called DeltaMomentum.

I would really like to change it so the histogram is entirely above the axis and does not become inverted when a reading is negative.

Does anyone know if the source code is available anywhere ?

I can only see the DLL file.

The reason I want to make the change is that I believe it is easier to compare levels if all histograms are above the axis.

Thanks for any help
[2015-07-10 03:05:18]
Sierra Chart Engineering - Posts: 104368


#define ASKCOLOR RGB(255, 128, 128)
#define BIDCOLOR RGB(128, 255, 128)
#define POSDELTACOLOR RGB(32, 255, 32)
#define NEGDELTACOLOR RGB(255, 32, 32)


SCSFExport scsf_DeltaMomentum(SCStudyGraphRef sc)
{
  SCSubgraphRef askVol       = sc.Subgraph[0];
  SCSubgraphRef bidVol       = sc.Subgraph[1];
  SCSubgraphRef deltaVol       = sc.Subgraph[2];
  SCSubgraphRef deltaMomentum   = sc.Subgraph[3];


  if (sc.SetDefaults) {
    sc.GraphName = "DeltaMomentum";
    sc.GraphRegion = 1;
    sc.ScaleRangeType = SCALE_AUTO;
    sc.StudyDescription = "DeltaMomentum";


    sc.FreeDLL = 0;

    sc.AutoLoop = 0; // Manual looping

    askVol.Name = "Ask Volume";
    askVol.PrimaryColor = ASKCOLOR;
    askVol.DrawStyle = DRAWSTYLE_IGNORE;

    bidVol.Name = "Bid Volume";
    bidVol.PrimaryColor = BIDCOLOR;
    bidVol.DrawStyle = DRAWSTYLE_IGNORE;

    deltaVol.Name = "Delta";
    deltaVol.DrawStyle = DRAWSTYLE_IGNORE;


    deltaMomentum.Name = "Delta Momentum";
    deltaMomentum.PrimaryColor = POSDELTACOLOR;
    deltaMomentum.SecondaryColor = NEGDELTACOLOR;
    deltaMomentum.LineWidth = 2;
    deltaMomentum.DrawStyle = DRAWSTYLE_BAR;
    deltaMomentum.AutoColoring = AUTOCOLOR_POSNEG;
    return;
  }
  int ind = sc.UpdateStartIndex;  
  if (ind == 0)
  {
    askVol[ind]   = sc.BaseDataIn[SC_ASKVOL][ind];
    bidVol[ind]   = -sc.BaseDataIn[SC_BIDVOL][ind];
    deltaVol[ind]  = askVol[ind] + bidVol[ind];
    deltaMomentum[ind] = deltaVol[ind];
    ++ind;
  }  
  for (; ind < sc.ArraySize; ++ind)
  {
    askVol[ind]   = sc.BaseDataIn[SC_ASKVOL][ind];
    bidVol[ind]   = -sc.BaseDataIn[SC_BIDVOL][ind];
    deltaVol[ind]  = askVol[ind] + bidVol[ind];
    if (deltaVol[ind] > 0)
    {
      if (deltaMomentum[ind-1] >= 0)
      {
        deltaMomentum[ind] = deltaMomentum[ind-1] + deltaVol[ind];
      }
      else
      {
        deltaMomentum[ind] = deltaVol[ind];
      }
    }
    else if (deltaVol[ind] < 0)
    {
      if (deltaMomentum[ind-1] <= 0)
      {
        deltaMomentum[ind] = deltaMomentum[ind-1] + deltaVol[ind];
      }
      else
      {
        deltaMomentum[ind] = deltaVol[ind];
      }
    }
    else
    {
      deltaMomentum[ind] = deltaMomentum[ind-1];
    }
  }
}

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
[2015-07-10 05:56:42]
Acro - Posts: 436
Thanks

In case anyone wants them here are the attached cpp and dll that give an extra subgraph 4 that has this option for easier comparison between positive and negative delta momentum
attachmentDeltaMomo_2.cpp - Attached On 2015-07-10 05:56:05 UTC - Size: 3.27 KB - 339 views
attachmentDeltaMomo_2.dll - Attached On 2015-07-10 05:56:16 UTC - Size: 18 KB - 313 views

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

Login

Login Page - Create Account