Support Board
Date/Time: Tue, 26 Nov 2024 07:47:12 +0000
[Programming Help] - ACSIL for automating price expansion tool with float array from study
View Count: 422
[2023-12-30 06:36:48] |
mv3trader5 - Posts: 5 |
I'm trying to build a custom study that draws the custom study from the high and low as identified by the High/Low for Time Period study. I'm getting stuck at how to reference the high and low from the float array to for the Beginvalue and endvalue of the price expansion tool. I'm assuming "BeginValue and EndValue is the Anchor points for the expansion tool. Please point me in the right direction if what I'm trying to achieve is possible, thanks. Here's the error I'm receiving when compiling: 137:20: error: cannot convert 'SCFloatArray' {aka 'c_ArrayWrapper<float>'} to 'float' in initialization One of the ways I've attempted: //log SCString msg; //inputs SCInputRef i_RangeHigh = sc.Input[0]; SCInputRef i_RangeLow = sc.Input[1]; // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "Auto Power Range Levels"; sc.GraphRegion = 0; sc.AutoLoop = 1; i_RangeHigh.Name = "High for Time Period Reference"; i_RangeHigh.SetChartStudySubgraphValues(1,1, 0); i_RangeLow.Name = "Low for Time Period Reference"; i_RangeLow.SetChartStudySubgraphValues(1,1, 0); return; } SCFloatArray powerRange; sc.GetStudyArrayFromChartUsingID(i_RangeHigh.GetChartStudySubgraphValues(), powerRange); sc.GetStudyArrayFromChartUsingID(i_RangeLow.GetChartStudySubgraphValues(), powerRange); //Draw Price Expansion (Fib Levels) tool int& r_LineNumber = sc.GetPersistentInt(1); if (sc.IsFullRecalculation) { s_UseTool Tool; //Tool.Clear(); Tool.ChartNumber = sc.ChartNumber; Tool.DrawingType = DRAWING_PRICE_EXPANSION; if (r_LineNumber != 0) Tool.LineNumber = r_LineNumber; //Plotting Price Expansion Tool float BarIndex = powerRange; Tool.BeginValue = sc.High[BarIndex]; Tool.EndValue = sc.Low[BarIndex]; Tool.AddMethod = UTAM_ADD_OR_ADJUST; Tool.ShowPrice = 1; Tool.ShowPercent = 0; } } |
[2023-12-30 12:17:28] |
User431178 - Posts: 541 |
1. You need a separate array for each of lows and highs, powerRange would only contain data relating to the second call of sc.GetStudyArrayFromChartUsingID. SCFloatArray powerRangeHigh; SCFloatArray powerRangeLow; sc.GetStudyArrayFromChartUsingID(i_RangeHigh.GetChartStudySubgraphValues(), powerRangeHigh); sc.GetStudyArrayFromChartUsingID(i_RangeLow.GetChartStudySubgraphValues(), powerRangeLow); 2. You need to identify the index where you wish to draw / access values from. As you seem to be drawing only once, during reclaculation, maybe use sc.ArraySize - 1 for the index value, in other words the most recent bar. The code below does not make sense and is the source of the error message you quoted. float BarIndex = powerRange; Instead you could use something like below Tool.BeginIndex = sc.ArraySize - 1; Tool.EndIndex = Tool.BeginIndex Tool.BeginValue = powerRangeHigh[sc.ArraySize - 1]; Tool.EndValue = powerRangeLow[sc.ArraySize - 1]; 3. If you are getting values from another chart, as might be implied by the use of 'sc.GetStudyArrayFromChartUsingID', then using sc.ArraySize - 1 (as shown above) would not be correct. Instead you would need to find the corresponding index on the referenced chart - see following link for details - Referencing Other Time Frames and Symbols When Using the ACSIL Once you have the corresponding other chart index, the snip from 2. would be rewritten as below Tool.BeginIndex = sc.ArraySize - 1; Tool.EndIndex = Tool.BeginIndex Tool.BeginValue = powerRangeHigh[otherChartIndex]; Tool.EndValue = powerRangeLow[otherChartIndex]; |
To post a message in this thread, you need to log in with your Sierra Chart account: