Login Page - Create Account

Support Board


Date/Time: Tue, 24 Jun 2025 00:14:30 +0000



Post From: ACSIL Renko Open Close

[2022-02-10 01:33:37]
1+1=10 - Posts: 270
Below I've pasted an entire study written by SC located in the ACS_Source folder within file "Studies2.cpp". That study happens to use manual looping. I don't know which examples you're referring to that use "sc.BaseData[SC_RENKO_OPEN][-1]" and "sc.BaseData[SC_RENKO_CLOSE][0]" but note below SC uses:
sc.Subgraph[SubGraph][BarIndex] = sc.BaseDataIn[SC_RENKO_OPEN][BarIndex]

I added comments with an arrow to help you find it quicker below. For sc.BaseData/sc.BaseDataIn[][] the second [] is used to grab data from a certain bar. Similarly, for subgraphs the last [] is which bar you're writing the value of the subgraph for. See the docs here: ACSIL Interface Members - Variables and Arrays: sc.BaseDataIn[][] / sc.BaseData[][]

Again, I highly recommend you refresh your memory of how to work with the data/subgraph arrays and understanding looping: Working with ACSIL Arrays and Understanding Looping

Lastly, if you take both parts of the code I wrote in my first response, it will do exactly what you asked for here:

Subgraph_Renko_PriorOpen[sc.Index] = the RENKO OPEN 1 bar ago.
Subgraph_Renko_PriorClose[sc.Index] = the RENKO CLOSE 1 bar ago
Subgraph_Renko_Open[sc.Index] = the RENKO OPEN current bar
Subgraph_Renko_Close[sc.Index] = the RENKO CLOSE current


SC's code:

SCSFExport scsf_BarsInTicks(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName = "Bars in Ticks";
    //sc.GraphRegion = 0;
    sc.ValueFormat = VALUEFORMAT_WHOLE_NUMBER;
    sc.AutoLoop = 0;
    sc.GraphDrawType = GDT_OHLCBAR;
    sc.StandardChartHeader = true;
    sc.GraphUsesChartColors = true;

    return;
  }

  n_ACSIL::s_BarPeriod BarPeriod;
  sc.GetBarPeriodParameters(BarPeriod);
  int RenkoTicksPerBar = BarPeriod.IntradayChartBarPeriodParameter1;


  if (sc.IsFullRecalculation && sc.UpdateStartIndex == 0)
  {
    sc.GraphName.Format("%s in Ticks", sc.GetStudyName(0).GetChars());

    for (int SubgraphIndex = 0; SubgraphIndex <= NUM_BASE_GRAPH_ARRAYS; ++SubgraphIndex)
    {
      sc.Subgraph[SubgraphIndex].Name = sc.GetStudySubgraphName(0, SubgraphIndex);
    }

  }

  for(int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++)
  {
    for (int SubGraph = 0; SubGraph <= NUM_BASE_GRAPH_ARRAYS; SubGraph++)
    {
      if (SubGraph == SC_VOLUME || SubGraph == SC_NUM_TRADES || SubGraph == SC_BIDVOL || SubGraph == SC_ASKVOL)
        sc.Subgraph[SubGraph][BarIndex] = sc.BaseDataIn[SubGraph][BarIndex];
      else
      {

        if (RenkoTicksPerBar != 0 && SubGraph == SC_OPEN)
          sc.Subgraph[SubGraph][BarIndex] = sc.BaseDataIn[SC_RENKO_OPEN][BarIndex] / sc.TickSize; // <---
        else if (RenkoTicksPerBar != 0 && SubGraph == SC_LAST)
          sc.Subgraph[SubGraph][BarIndex] = sc.BaseDataIn[SC_RENKO_CLOSE][BarIndex] / sc.TickSize; // <---
        else
          sc.Subgraph[SubGraph][BarIndex] = sc.BaseDataIn[SubGraph][BarIndex] / sc.TickSize;
      }
    }
  }
}