NexusFi: Find Your Edge


Home Menu

 





Bar by Bar degap


Discussion in Sierra Chart

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




 
Search this Thread

Bar by Bar degap

  #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?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
17 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: 844

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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts