Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 14:43:08 +0000



[User Discussion] - Back Adjusted Gap Fill

View Count: 230

[2024-02-24 07:38:11]
esMike - Posts: 69
Hello, is it possible to do a back adjusted Gap fill with Sierra Chart? It looks like this.

The numbers for prior days are adjusted different depending upon the gap, but that just how it works.
imagenonFilled.png / V - Attached On 2024-02-24 07:37:27 UTC - Size: 10.14 KB - 51 views
imagebackAdj.png / V - Attached On 2024-02-24 07:37:32 UTC - Size: 8.87 KB - 51 views
[2024-02-24 08:33:57]
esMike - Posts: 69
I created a study to do it... Feel free to modify/include it in user contributed studies if you want.




SCSFExport scsf_MVNoGaps(SCStudyInterfaceRef sc)
{
//Copyright @meanVelocity - Free for personal use.

  SCSubgraphRef Subgraph_Open = sc.Subgraph[0];
  SCSubgraphRef Subgraph_High = sc.Subgraph[1];
  SCSubgraphRef Subgraph_Low = sc.Subgraph[2];
  SCSubgraphRef Subgraph_Last = sc.Subgraph[3];
  SCSubgraphRef Subgraph_Volume = sc.Subgraph[4];
  SCSubgraphRef Subgraph_NumTrades = sc.Subgraph[5];
  SCSubgraphRef Subgraph_OHLCAvg = sc.Subgraph[6];
  SCSubgraphRef Subgraph_HLCAvg = sc.Subgraph[7];
  SCSubgraphRef Subgraph_HLAvg = sc.Subgraph[8];
  SCSubgraphRef Subgraph_BidVol = sc.Subgraph[9];
  SCSubgraphRef Subgraph_AskVol = sc.Subgraph[10];

  SCFloatArrayRef barDate = sc.Subgraph[11].Arrays[0];

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

    sc.GraphName = "MV NoGaps";
    sc.StudyDescription = "MV NoGaps";

    sc.AutoLoop = 1;
    sc.FreeDLL = 0;
    sc.DisplayStudyName = 0;
    sc.DisplayStudyInputValues = 0;
    sc.GlobalDisplayStudySubgraphsNameAndValue = 0;
    sc.DisplayAsMainPriceGraph = 1;

    sc.GraphDrawType = GDT_BLANK;
    sc.StandardChartHeader = 1;
    sc.GraphRegion = 0;
    sc.ValueFormat = VALUEFORMAT_INHERITED;

    Subgraph_Open.Name = "Open";
    Subgraph_Open.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Open.PrimaryColor = RGB(0, 255, 0);
    Subgraph_Open.SecondaryColorUsed = true;
    Subgraph_Open.SecondaryColor = RGB(0, 255, 0);

    Subgraph_High.Name = "High";
    Subgraph_High.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_High.PrimaryColor = RGB(128, 255, 128);

    Subgraph_Low.Name = "Low";
    Subgraph_Low.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Low.PrimaryColor = RGB(255, 0, 0);
    Subgraph_Low.SecondaryColorUsed = true;
    Subgraph_Low.SecondaryColor = RGB(255, 0, 0);

    Subgraph_Last.Name = "Last";
    Subgraph_Last.DrawStyle = DRAWSTYLE_LINE;
    Subgraph_Last.PrimaryColor = RGB(255, 128, 128);

    Subgraph_Volume.Name = "Volume";
    Subgraph_Volume.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_Volume.PrimaryColor = RGB(255, 0, 0);

    Subgraph_NumTrades.Name = "NumTrades";
    Subgraph_NumTrades.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_NumTrades.PrimaryColor = RGB(0, 0, 255);

    Subgraph_OHLCAvg.Name = "OHLC Avg";
    Subgraph_OHLCAvg.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_OHLCAvg.PrimaryColor = RGB(127, 0, 255);

    Subgraph_HLCAvg.Name = "HLC Avg";
    Subgraph_HLCAvg.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_HLCAvg.PrimaryColor = RGB(0, 255, 255);

    Subgraph_HLAvg.Name = "HL Avg";
    Subgraph_HLAvg.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_HLAvg.PrimaryColor = RGB(0, 127, 255);

    Subgraph_BidVol.Name = "Bid Vol";
    Subgraph_BidVol.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_BidVol.PrimaryColor = RGB(0, 255, 0);

    Subgraph_AskVol.Name = "Ask Vol";
    Subgraph_AskVol.DrawStyle = DRAWSTYLE_IGNORE;
    Subgraph_AskVol.PrimaryColor = RGB(0, 255, 0);

    return;
  }

  Subgraph_Open[sc.Index] = sc.Open[sc.Index];
  Subgraph_High[sc.Index] = sc.High[sc.Index];
  Subgraph_Low[sc.Index] = sc.Low[sc.Index];
  Subgraph_Last[sc.Index] = sc.Close[sc.Index];
  Subgraph_Volume[sc.Index] = sc.Volume[sc.Index];
  Subgraph_NumTrades[sc.Index] = sc.NumberOfTrades[sc.Index];

  barDate[sc.Index] = float(sc.BaseDateTimeIn.DateAt(sc.Index));

  if (barDate[sc.Index] != barDate[sc.Index - 1]) {
    if (Subgraph_Open[sc.Index] > Subgraph_Last[sc.Index - 1] || Subgraph_Open[sc.Index] < Subgraph_Last[sc.Index - 1]) {
      float gapAmount = Subgraph_Open[sc.Index] - Subgraph_Last[sc.Index - 1];

        for (int Index = sc.Index - 1; Index > 0; Index--) {
          Subgraph_Open[Index] = Subgraph_Open[Index] + gapAmount;
          Subgraph_High[Index] = Subgraph_High[Index] + gapAmount;
          Subgraph_Low[Index] = Subgraph_Low[Index] + gapAmount;
          Subgraph_Last[Index] = Subgraph_Last[Index] + gapAmount;
        }
    }
  }

  sc.CalculateOHLCAverages();
}

Date Time Of Last Edit: 2024-02-24 08:36:45
[2024-02-26 16:19:26]
John - SC Support - Posts: 36244
The definition of a back-adjusted Continuous Futures Contract option is that it fills that gap by moving the data. Refer to the following:
Continuous Futures Contract Charts: Understanding Back Adjusted Price Data and Comparisons

And refer to the following for how you can control the amount of the back-adjustment:
Continuous Futures Contract Charts: Controlling Rollover Amount for Back Adjustments
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-02-27 07:37:45]
esMike - Posts: 69
No, I’m creating full back adjusted charts. So if you set session time to 9:30am to 4PM, there will be no gaps, or even 9:30 to 12:00, it will back adjust and remove all gaps.

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

Login

Login Page - Create Account