Login Page - Create Account

Support Board


Date/Time: Thu, 27 Feb 2025 22:11:00 +0000



[Programming Help] - ASCIL - Potential Bug in GetStudyPeakValleyLine.

View Count: 631

[2021-07-29 14:45:43]
P3rri - Posts: 16
Greetings,
I have a similar for loop that grabs the the Peak for the next X candles.

sc.Input[0].GetStudyID() -> A VP that I am manipulating.


closing_time = 0.483;
for(i=0; i<10; i++) {
sc.SetChartStudyInputFloat(sc.ChartNumber,sc.Input[0].GetStudyID(), 40, closing_time);

int index_last_peak = 0;

int PeakValleyType = 0;
int StartIndex = 0;
int PeakValleyExtensionChartColumnEndIndex = 0;
float PeakValleyLinePrice = 0;
sc.GetStudyPeakValleyLine(sc.ChartNumber, sc.Input[0].GetStudyID(), PeakValleyLinePrice, PeakValleyType, StartIndex, PeakValleyExtensionChartColumnEndIndex, 0, index_last_peak);

Subgraph[i] = PeakValleyLinePrice;

closing_time = closing_time + 0.05 //Increasing the time to move the profile more to the right.
}

The problem is, even if the Peak changed on the meantime for some reason all the 10 iterations will give first's iterations Peak value. So if the first PeakValleyLinePrice is 4000.00 all of them are gonna be 4000.00 even if I am setting PeakValleyLinePrice = 0 and again setting it with the function.
I do not think I am doing something wrong, I tried a lot of different variables and everything else works. If I try to get the next 10 sc.Highs I can, without having a problem but when I am trying to get the Peak I am getting the same results for all 10 iterations(all same like first one).

Could you please have a look, looks like a bug to me.
Thank you, have a great day!
Date Time Of Last Edit: 2021-07-29 16:17:44
[2021-07-29 15:14:06]
User907968 - Posts: 833
All the variables are declared within the loop meaning that you are calling the 'GetStudyPeakValleyLine' with the exact same parameters each time.

Maybe review this - ACSIL Interface Members - Functions: sc.GetStudyPeakValleyLine()
[2021-07-29 15:19:40]
P3rri - Posts: 16
Hello,

I am not actually, out of the for I am manipulating the volume profile. That I am grabbing the peaks from.
I just did not upload the code, cause I know the rest works.
[2021-07-29 15:51:20]
User907968 - Posts: 833
So what is your expectation from the sample code above, because it is clearly calling each iteration in the for loop with the same parameters?
Date Time Of Last Edit: 2021-07-29 15:52:10
[2021-07-29 16:06:58]
P3rri - Posts: 16
I edited the code, my bad. I tried to give an example without enough info.
[2021-07-29 16:18:55]
User907968 - Posts: 833
sc.SetChartStudyInputFloat(sc.ChartNumber,sc.Input[0].GetStudyID(), 40, closing_time);
This is not going to take effect until the VBP study is recalculated.
Date Time Of Last Edit: 2021-07-29 16:19:05
[2021-07-29 16:20:13]
P3rri - Posts: 16
Will sc.RecalculateChart(sc.ChartNumber); do the job?
[2021-07-29 16:38:24]
P3rri - Posts: 16
Tried it. Added a recalculate after the SetChartStudy but still not working. I am still getting the same Peak over the next X candles.
[2021-07-29 16:50:44]
User907968 - Posts: 833
Will sc.RecalculateChart(sc.ChartNumber); do the job?
Not within the for loop, no, as it is not actually called until the next study update, which will be after your code has finshed execution.
Date Time Of Last Edit: 2021-07-29 16:50:54
[2021-07-29 17:02:37]
P3rri - Posts: 16
Is there a workaround to this problem?
[2021-08-02 17:27:04]
User99735 - Posts: 234
Is the problem resolved?
If not changing input sc.SetChartStudyInputFloat(sc.ChartNumber,sc.Input[0].GetStudyID(), 40, closing_time); will not solve anything.
You will need to capture the peaks/valleys as the bars are updated.
[2021-08-02 18:04:27]
P3rri - Posts: 16
Hello, thank you for the answer.
No I am still trying to solve it.
What do you mean?
[2021-08-02 18:18:40]
User99735 - Posts: 234
"I have a similar for loop that grabs the the Peak for the next X candles."
This is for historical candles, or for current candle and the next X candles?
[2021-08-02 18:22:19]
P3rri - Posts: 16
I want to be able to to if both, I want to be able to grab historical Peaks and Valleys and future peaks and valleys.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account