Login Page - Create Account

Support Board


Date/Time: Tue, 16 Apr 2024 10:59:18 +0000



sc.YPixelCoordinateToGraphValue();

View Count: 776

[2017-03-17 01:14:33]
User553714 - Posts: 184
I can't seem to return the GraphValues using sc.YPixelCoordinateToGraphValue for anything other than the main price graph?
I am using this simple line of code;
ClientWindowHeightInRegionValueRun = sc.YPixelCoordinateToGraphValue(sc.StudyRegionTopCoordinate), sc.YPixelCoordinateToGraphValue(sc.StudyRegionBottomCoordinate);

When the following is placed in a study in the main price graph region it returns correctly, see below;
GraphValue Top & Bot : 0.77019, 0.76565 | 2017-03-17 11:49:24 * (Correct)

When the same line of code is placed into the client window of an MACD study it returns incorrect values, see below;
GraphValue Top & Bot : 15000000.00000, -316000000.00000 | 2017-03-17 11:56:14 *
It should have returned the GraphValues of the MACD study IE the upper and lower MACD scale values?

Can sc.YPixelCoordinateToGraphValue() be used in any ChartRegion or only the main price chart region 1?
[2017-03-18 07:38:34]
User553714 - Posts: 184
I have spent a fair bit of time trying to resolve this but it seems like an issue with the function itself?
With AutoLoop=1. when you set sc.YPixelCoordinateToGraphValue() to a value in the main price graph region, for example sc.YPixelCoordinateToGraphValue(37) the function returns after the study is added correctly with the main price graph Yaxis region value. However when you set the function to a return a value in the region of the attached study, say MACD in chartRegion 2 with sc.YPixelCoordinateToGraphValue(900), the function returns with incorrect values until the chart is placed in replay/live mode at which point it starts to return correct MACD scale values.

I thought that this might be an issue with when the MACD subgraph is getting populated but surely these would be fully calculated by the time it returns for a 2nd time after running through SetDefaults? Even a manual recalc or reload & recalc it won't return the correct values; it only returns correct values when the chart is placed in replay or live mode? The code itself is physically after the MACD subgraphs are calculated so there should be no precedance issues?

Am I missing something and is the function working as you would anticipate?
Regards
[2017-03-18 07:53:26]
User553714 - Posts: 184
I went back and double checked and "recalculation" and "reload & recalculation" do both return the correct chart values. So the issue is only during the first calculation when the study is added.
Regards
[2017-03-20 04:28:33]
Sierra Chart Engineering - Posts: 104368
This function and the related variables can only function properly after the chart is actually drawn:

sc.YPixelCoordinateToGraphValue(sc.StudyRegionTopCoordinate);
sc.YPixelCoordinateToGraphValue(sc.StudyRegionBottomCoordinate);

And they will return values based upon what was last drawn not what the study function is currently doing. This is something to keep in mind because they are going to be returning data based upon the last time the chart was drawn. The chart is always drawn after the study function is calculated. So a study function will always be working with values which may not be current.


We are going to do some testing, and make sure invalid values do not get returned and make sure the documentation explains all of this clearly although some of this is already documented if not already clearly.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2017-03-20 04:30:03

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

Login

Login Page - Create Account