NexusFi: Find Your Edge


Home Menu

 





Bar by Bar degap


Discussion in Sierra Chart

Updated
    1. trending_up 1,748 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
xioxxio
New York United States
 
Posts: 9 since Apr 2011
Thanks Given: 0
Thanks Received: 0

Hey guys I am looking for the study that de-gaps every 5 minute bar. ie the close of previous bar is equal to open on current bar. Does anyone have it?

There is a study out there called shifted where it only shifts the previous days close to match current days open. Not all bars on the chart.

The shifted study is below

Regards

 
Code
#include "sierrachart.h" 

 

 

SCDLLName("Shifted Study DLL")  

 

/***********************************************************************/ 

SCSFExport scsf_ShiftedStudy(SCStudyGraphRef sc) 

{ 

  // Set configuration variables 

 

  if (sc.SetDefaults) 

  { 

    // Set the defaults 

 

    sc.GraphName = "Shifted BaseGraph"; 

 

    sc.StudyDescription = "The Open value of the next day is set to the Close value of the previous day for all the days, starting with 2nd."; 

 

    sc.IsCustomChart = 1; 

    sc.GraphRegion = 0;    

    sc.DrawZeros = 0; 

    sc.GraphDrawType = GDT_OHLCBAR; 

    sc.StandardChartHeader = 1; 

    sc.DisplayAsMainPriceGraph = 1; 

 

    // Subgraphs 

    sc.Subgraph[0].Name = "Open"; 

    sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[1].Name = "High"; 

    sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[2].Name = "Low"; 

    sc.Subgraph[2].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[3].Name = "Last"; 

    sc.Subgraph[3].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[4].Name = "Open Base"; 

    sc.Subgraph[4].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[5].Name = "High Base"; 

    sc.Subgraph[5].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[6].Name = "Low Base"; 

    sc.Subgraph[6].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[7].Name = "Last Base"; 

    sc.Subgraph[7].DrawStyle = DRAWSTYLE_LINE; 

 

    sc.Subgraph[4].Name = "Volume"; 

    sc.Subgraph[4].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.Subgraph[5].Name = "# of Trades / OI"; 

    sc.Subgraph[5].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.Subgraph[6].Name = "OHLC Avg"; 

    sc.Subgraph[6].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.Subgraph[7].Name = "HLC Avg"; 

    sc.Subgraph[7].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.Subgraph[8].Name = "HL Avg"; 

    sc.Subgraph[8].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.Subgraph[9].Name = "Bid Vol"; 

    sc.Subgraph[9].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.Subgraph[10].Name = "Ask Vol"; 

    sc.Subgraph[10].DrawStyle = DRAWSTYLE_IGNORE; 

 

    sc.PersistVars->i1 = -1; 

 

    sc.AutoLoop = 1; 

 

    return; 

  } 

 

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

 

  if (sc.Index == 0) 

  { 

    sc.ResizeArrays(0); 

    sc.PersistVars->i1 = -1; 

  } 

 

  int Index = sc.Index; 

   

  if (sc.OutArraySize - 1 < Index) 

    sc.AddElements(Index - sc.OutArraySize + 1); 

 

  //this tick is last day, so just copy everything 

  for (int SubGraph = 0; SubGraph <= 10; SubGraph++)  

    sc.Subgraph[SubGraph][Index] = sc.BaseDataIn[SubGraph][Index]; 

   

  sc.CalculateOHLCAverages(Index); 

  sc.DateTimeOut[Index] = sc.BaseDateTimeIn[Index]; 

 

  ShiftArray[Index] = 0; 

 

  if(Index < 1) 

    return; 

 

  // don't process the same index again 

  if (sc.PersistVars->i1 >= sc.Index) 

    return; 

 

  // calculate start date for current index 

  SCDateTime StartDateTimeOfCurIndex = sc.BaseDateTimeIn[sc.Index].GetDate(); 

  StartDateTimeOfCurIndex.SetTime(sc.StartTimeOfDay); 

 

  if(sc.StartTimeOfDay > sc.BaseDateTimeIn[sc.Index].GetTime()) 

    StartDateTimeOfCurIndex -= DAYS; 

 

  if(sc.BaseDateTimeIn[Index-1] >= StartDateTimeOfCurIndex) 

    return; 

 

  // save last processed index. We should process it only once 

  sc.PersistVars->i1 = Index; 

 

  float Shift = sc.Subgraph[SC_OPEN][Index] - sc.BaseDataIn[SC_LAST][Index-1];; 

 

  for (int i = Index - 1; i >= 0; i--) 

  { 

    float CumulativeShift = Shift + ShiftArray[i]; 

 

    // shift prices prices 

    sc.Subgraph[SC_OPEN][i] = sc.BaseDataIn[SC_OPEN][i] + CumulativeShift; 

    sc.Subgraph[SC_HIGH][i] = sc.BaseDataIn[SC_HIGH][i] + CumulativeShift; 

    sc.Subgraph[SC_LOW][i] = sc.BaseDataIn[SC_LOW][i] + CumulativeShift; 

    sc.Subgraph[SC_LAST][i] = sc.BaseDataIn[SC_LAST][i] + CumulativeShift; 

 

    //recalculate averages 

    sc.CalculateOHLCAverages(i); 

 

    // update shift value 

    ShiftArray[i] += Shift; 

  } 

}


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Irans Dual Probability: Guns Quiet at 99.95% While Forma …
Prediction Markets & Event Contracts
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Prop Firm Tracked Payouts Hit $115M in Q1 but Growth Fla …
Funded Trading Evaluation Firms
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
Hormuz Normalization Collapses to 19.5% -- Iran Regime F …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 845

Maybe try changing StartDateTimeOfCurIndex -= DAYS; to StartDateTimeOfCurIndex -= MINUTES;


Reply With Quote
  #3 (permalink)
xioxxio
New York United States
 
Posts: 9 since Apr 2011
Thanks Given: 0
Thanks Received: 0


Thanks, I tried that it does not work. I really would appreciate help.

Regards


Reply With Quote




Last Updated on September 13, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts