Login Page - Create Account

Support Board


Date/Time: Thu, 18 Apr 2024 19:07:00 +0000



Post From: Can I plot data from file into the future on a chart?

[2014-01-12 17:29:25]
WarEagle - Posts: 70
After reading through the example code given in scsf_ExtendedArraySample you pointed me to, I am still not sure how to get data from another chart or file to plot in the future part of the array. In the example, they are taking data points (in this case an RSI) from previous bars in the same chart and shifting them forward. Since all they need to do is call an older array location this is pretty simple and I understand it.

Since I already have the forecast line in a chart I thought it might be simplest to copy the Price Overlay (single line) indicator code and add the extended array functionality. The problem I run in to is that I don't know how to reference the future bars from the chart that is being overlayed. I tried using the following code by trying to simply reference bars past sc.ArraySize by the number of bars I want to plot ahead, but that did not produce any values past the current bar on the chart.


ForecastOverlay.ExtendedArrayElementsToGraph = 50; //This is done in the sc.SetDefaults section

SCFloatArray PriceArray;
sc.GetChartArray(-ChartNumberToOverlay.GetChartNumber(), InputData.GetInputDataIndex(), PriceArray);
// ^^ Gets data from the chart being overlayed, in this case its the price forecast ^^
  
int TheirIndex = sc.GetNearestMatchForDateTimeIndex(ChartNumberToOverlay.GetChartNumber(), sc.Index);
ForecastOverlay[sc.Index] = PriceArray[TheirIndex];
// ^^ The above code matches the overlay up to the current bar just fine ^^

int NumberOfBarsToForwardPlot = ForecastOverlay.ExtendedArrayElementsToGraph;
if(sc.Index >= sc.ArraySize)  
  {
    for (int i = sc.ArraySize;i < sc.ArraySize + NumberOfBarsToForwardPlot ;i++)
    {  
      ForecastOverlay[i] = PriceArray[i];  
    }
  }
// ^^ This is the code I am using adapted from the scsf_ExtendedArraySample that seems to do nothing. ^^

What am I doing wrong?

Thanks as always!