Bar by Bar degap - Sierra Chart | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > Sierra Chart

Bar by Bar degap
Started:September 12th, 2013 (11:28 AM) by xioxxio Views / Replies:436 / 2
Last Reply:September 13th, 2013 (12:02 AM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Bar by Bar degap

Old September 12th, 2013, 11:28 AM   #1 (permalink)
Trading Apprentice
New York United States
Futures Experience: Advanced
Platform: TradeNavigator, Sierra Charts
Broker/Data: IB
Favorite Futures: ES
Posts: 9 since Apr 2011
Thanks: 0 given, 0 received

Bar by Bar degap

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


#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; 





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


  if (sc.Index == 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.DateTimeOut[Index] = sc.BaseDateTimeIn[Index]; 


  ShiftArray[Index] = 0; 


  if(Index < 1) 



  // don't process the same index again 

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



  // calculate start date for current index 

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



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

    StartDateTimeOfCurIndex -= DAYS; 


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



  // 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 



    // update shift value 

    ShiftArray[i] += Shift; 



Reply With Quote

Old September 12th, 2013, 11:50 AM   #2 (permalink)
Elite Member
las vegas
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
Posts: 1,147 since Feb 2010
Thanks: 304 given, 832 received

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

Reply With Quote

Old September 13th, 2013, 12:02 AM   #3 (permalink)
Trading Apprentice
New York United States
Futures Experience: Advanced
Platform: TradeNavigator, Sierra Charts
Broker/Data: IB
Favorite Futures: ES
Posts: 9 since Apr 2011
Thanks: 0 given, 0 received

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


Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > Sierra Chart > Bar by Bar degap

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Book Discussion: Reading Price Charts Bar by Bar by Al Brooks cunparis Traders Hideout 530 October 19th, 2016 07:45 PM
How to step forward bar by bar (F12) with full bar not half bar? mercyman MetaTrader 1 October 23rd, 2012 04:49 PM
End of bar strategies with advanced bar types (Renko, Range, Kagi, etc) RM99 Elite EasyLanguage Automated Trading 2 September 9th, 2011 08:38 AM
Whats the difference between Bar Magnifier & look inside bar testing? crbucks MultiCharts 1 May 4th, 2011 12:22 AM
Image:al brooks reading price charts bar by bar.jpg Big Mike Trading Wiki Images 0 July 1st, 2010 08:00 PM

All times are GMT -4. The time now is 10:00 AM.

Copyright © 2016 by 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.
no new posts

Page generated 2016-10-25 in 0.07 seconds with 19 queries on phoenix via your IP