Announcement

Collapse
No announcement yet.

Get existing data point?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get existing data point?

    I have a couple of efs that currently generate a data series line on my chart. Is it possible to get the value of a point after it has been generated without having to regenerate the value through another efs.

    I have two values that are being generated through other efs formulas and I would like to that that existing data and in another efs run a comparison and plot a background color based on the comparison of those 2 data points?

    Are these data points stored in a manner that can be accessed from another efs. If so, How?

    thank you for your help

  • #2
    pcmd
    You can accomplish that using the efsExternal() function which allows you to retrieve values returned by an external efs (see the link for the description and syntax required by this function).
    Enclosed below is a basic example of the required logic together with some comments. For more detailed examples on the use of efsExternal() see also this and this thread.
    Alex
    Alex

    PHP Code:
    //call the external efs(s) and retrieve the data series returned by those scripts
    var myVar1 efsExternal("path_to_efs/name_of_efs1.efs",parameter1parameter2etc);//(parameters if required)
    var myVar2 efsExternal("path_to_efs/name_of_efs2.efs",parameter1parameter2etc);
     
    //the efsExternal function creates a series object which means that you could also use it as the source
    //for other functions that require a series object such as a the built-in studies. For example you could create 
    //a moving average of the series ie
    //var myAvg = sma(10, myVar1);
     
    //once you have the series then use the .getValue() method to retrieve the values and use them in the conditions
    //.getValue(0) is the current bar, .getValue(-1) is the prior bar, etc
    if(myVar1.getValue(0) > myVar2.getValue(0)){
        
    setBarBgColor(your_color);

    Comment

    Working...
    X