Support Board
Date/Time: Sat, 23 Nov 2024 19:28:43 +0000
[Programming Help] - Can't Access Renko Bar Data that is in Chart #2 from Chart #1 in Chartbook.
View Count: 151
[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
|
[2024-08-06 10:25:26] |
User431178 - Posts: 541 |
float RenkoSecOpen2 = RenkoSecOpenArray[sc.ArraySize - 2];
if you want to ghet the second last element from the other chart, you need to use RenkoSecOpenArray.GetArraySize() - 2
not sc.ArraySize - 2
sc.ArraySize applies only to the chart you are working from. Also, Renko open and close are stored in SC_RENKO_OPEN and SC_RENKO_CLOSE |
[2024-08-06 14:49:21] |
User413206 - Posts: 26 |
Thanks for the GetArraySize() correction. I forgot to change the code back to SC_RENKO_OPEN and SC_RENKO_CLOSE after testing whether it worked with SC_OPEN/SC_CLOSE. Date Time Of Last Edit: 2024-08-06 14:50:06
|
To post a message in this thread, you need to log in with your Sierra Chart account: