Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 19:23:21 +0000



Post From: Can't Access Renko Bar Data that is in Chart #2 from Chart #1 in Chartbook.

[2024-08-06 08:52:02]
User413206 - Posts: 26
I attempted refactor the code in the following example:

sc.GetChartBaseData()

But I can't get the values using the refactored code:

  // 1. Define a graph data object to get all of the base graph data from the secondary chart
  SCGraphData BaseGraphData;
  sc.GetChartBaseData(ChartStudy.GetChartNumber(), BaseGraphData);
  
  // 2. Create arrays for open and close prices from secondary chart.
  // - 2a. Get the Renko Open array from the secondary chart
  SCFloatArrayRef RenkoSecOpenArray = BaseGraphData[SC_OPEN];

  // - 2b. Get the Renko Close array from the secondary chart
  SCFloatArrayRef RenkoSecCloseArray = BaseGraphData[SC_CLOSE];
  
  // 3. Check if secondary array has enough bars.
  if (RenkoSecOpenArray.GetArraySize() < 2 || RenkoSecCloseArray.GetArraySize() < 2)
  {
    sc.AddMessageToLog("Insufficient data in secondary chart arrays.", 1);
    return;
  }
  
    
  // 5. Get the Renko open of second to last bar on secondary chart.
  float RenkoSecOpen2 = RenkoSecOpenArray[sc.ArraySize - 2];

  // 6. Get the Renko close of second to last bar on secondary chart.
  float RenkoSecClose2 = RenkoSecCloseArray[sc.ArraySize - 2];
  
  //DEBUG
  SCString Message;
  Message.Format("Bar Values: RenkoOpen=%f, RenkoClose=%f", RenkoSecOpen2, RenkoSecClose2);
  sc.AddMessageToLog(Message, 0);

The DEBUG message is showing:

2024-08-06 04:23:43.755 | Chart: CLU24[M] Flex Renko 5-3-2 #1 | Study: Renko Test | Bar Values: RenkoOpen=0.000000, RenkoClose=0.000000