Does anyone know how to get the x-coordinate for an indicator value on a chart ?
Announcement
Collapse
No announcement yet.
Getting x-coordinate for an indicator value on a chart ?
Collapse
X
-
Re: Getting x-coordinate for an indicator value on a chart ?
hi danclark,
There are several ways to do this, but I'm not really sure what exactly you are looking for. If you have a specific code example, you could post it and that may help.
Otherwise, if you are just getting started, take a look at the JavaScript for EFS link at the bottom of this post. This is a direct shortcut to some of the reference material available from the eSignal Support tab above.
Hope this helps,
Steve
Originally posted by dancclark
Does anyone know how to get the x-coordinate for an indicator value on a chart ?
-
Hi Steve,
I've written many EFS scripts before, so I'm not new to programming.
What I'm wondering is, if there is a way to get x-coord (for example) of the current MACD-signal line.
Do you know if there is a function that I can call and pass the bar index of the x-coord (or y-coord) that I want retrieved within my EFS chart ?
If I have a EFS script that's creating and returning a chart value that is drawn on the screen everytime, all I'm trying to do, is get the the x or y coord on the chart of where my value is at on the chart. Let me know if you dont understand. Thanks
Comment
-
Hi danclark,
Seems straight forward enough. Since you are are not new to programming EFS scripts, just take a look in the EFS Knowledgebase for the getValue() method. This method is associated with every EFS2 Series Object. This is the most basic technique that can be used to obtain values from EFS2 Series Object(s) used in an EFS script and/or returned to the chart.
Originally posted by dancclark
Hi Steve,
I've written many EFS scripts before, so I'm not new to programming.
What I'm wondering is, if there is a way to get x-coord (for example) of the current MACD-signal line.
Do you know if there is a function that I can call and pass the bar index of the x-coord (or y-coord) that I want retrieved within my EFS chart ?
If I have a EFS script that's creating and returning a chart value that is drawn on the screen everytime, all I'm trying to do, is get the the x or y coord on the chart of where my value is at on the chart. Let me know if you dont understand. Thanks
Comment
-
Hi Steve,
I checked out the getValue() function but I didnt see any way to get the x-coordinate of a point on the chart.
The first parameter of getValue() is: I]String for type of value to retrieve: "open", "high", "low", "close", "time", "rawtime", "volume", "oi", "year", "month", "day", "hour", "minute", "second"[/I] , but how do any of those help me get the x-coordinate ? Can you elaborate.
Check out the attached image. I'm trying to get (for example), the x-coordinate of the OBV (On balance volume) where I have drawn the red arrow at.
Is that possible ? It would be extremely helpful if so. Thanks
Comment
-
Forgive me if this has already been answered or stated, but the X coordinate is essentially the bar number.
If you want to know the value of the MACD at the current bar, then the x coordinate would be 0 (if using the bar index) or the total number of bars on the chart (if you are using the bar counter method).
There are other ways to determine an x coordinate for any chart/indicator or other trading system. You simply have to remember that in EFS you are dealing with bars that make up the X values on the chart. Y values are prices or indicator return values.
Steve is correct in his stating that you would use getValue(n) to retrieve the values for an indicator on a chart.
If you wanted to get the value of the MACD 5 bars ago, then you would use MACD.getValue(-5). If the location you want to retrieve changes often (with each call), then you might want to create a mechanism to handle this.
I use the bar counter method because it is easy to deploy. Simply create a bar counter like this in your code.
PHP Code:
var nBarCounter = 0;
function main() {
if (getBarState() == BARSTATE_NEWBAR) {
nBarCounter ++;
}
}
Hope this helps.Brad Matheny
eSignal Solution Provider since 2000
Comment
-
Hi danclark,
Good to hear from you.
As you noted, getValue can be a stand-alone function, but it is also a Method associated with an EFS2 Series object. This is a link to a Knowledge Base Article for the built in study functions macd(), macdSignal(), macdHist().
In the code below, the getValue
() Method is being used where you use the barIndex to refer to past bars in the chart.
getCurrentBarIndex() is a function that returns the current offset into the price series that is loaded in the chart. The current barIndex would be 0, the previous -1, -2, -3, etc.
So, in terms of the chart's "x-coordinate" and the plotted value relative to the most recent bar, the bar Index is applicable. Here is a link: http://kb.esignalcentral.com/article...ticle=2111&p=4
Regarding a charts barCount, this can be accessed by using the built-in getCurrentBarCount() function. The charts barCount is is an ever increasing number that starts at 1. Here is a link http://kb.esignalcentral.com/article...ticle=2159&p=4
PHP Code://global Series Object variables
var xStudy1 = null;
var xStudy2 = null;
var xStudy3 = null;
function main() {
if (xStudy1 == null) xStudy1 = macd(12, 26, 9);
if (xStudy2 == null) xStudy2 = macdSignal(12, 26, 9);
if (xStudy3 == null) xStudy3 = macdHist(12, 26, 9);
// retrieve single values for conditional statements
var nValue1_0 = xStudy1.getValue(0); // Current Bar Index value
var nValue2_0 = xStudy2.getValue(0); // Current Bar Index value
var nValue3_0 = xStudy3.getValue(0); // Current Bar Index value
var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value
// Plot Current Bar Index Value
return new Array(nValue1_0, nValue2_0, nValue3_0);
}
Originally posted by dancclark
Hi Steve,
I checked out the getValue() function but I didnt see any way to get the x-coordinate of a point on the chart.
The first parameter of getValue() is: I]String for type of value to retrieve: "open", "high", "low", "close", "time", "rawtime", "volume", "oi", "year", "month", "day", "hour", "minute", "second"[/I] , but how do any of those help me get the x-coordinate ? Can you elaborate.
Check out the attached image. I'm trying to get (for example), the x-coordinate of the OBV (On balance volume) where I have drawn the red arrow at.
Is that possible ? It would be extremely helpful if so. Thanks
Comment
Comment