Announcement

Collapse
No announcement yet.

One Function But Two Chart Panes

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

  • One Function But Two Chart Panes

    I have the following portion of a script which I got from the Pearson correlation script:

    with (oTotals1) {
    nSP = SumXY - ( (ASumX * BSumX) / frPeriod );
    nSSX = ASumXX - ( (ASumX * ASumX) / frPeriod );
    nSSY = BSumXX - ( (BSumX * BSumX) / frPeriod );
    Azval = zA;
    Bzval = zB;
    }
    nPearsons = nSP / Math.sqrt( nSSX*nSSY);
    return( nPearsons, Azval, Bzval );

    I've added some additional statistical calculations and would like to plot one chart using "nPearsons" and plot "Azval" and "Bzval" in a separate chart pane. I only use one function to come up with all three numbers, however. I'm not sure exactly how to make two separate chart panes appear. I can't use two functions because of processing time.

    rauthur

  • #2
    Hello authur,

    A single formula can only plot to one pane. To plot your values in two panes will require two formulas.

    There are two ways to accomplish this. The first option is to simply make a copy of your formula with a different name and modify the return statements in the two formulas to only plot "nPearsons" in one and the other two series in the second formula.

    The second method would be to leave your original formula as is and create two new formulas that call the original through efsExternal(). This function retrieves all three series, but your return statement in each of the two new formulas would only plot the series you need. Here's a basic code example (excluding preMain) of how to code this for the two new formulas. Replace the "yourFileName.efs" with the actual name of your original formula. Note that if all three formulas are in the same folder the path does not need to be specified in the efsExternal() function.

    plot Pearsons
    PHP Code:
    var xOriginal null;
    var 
    xPearsons null;

    function 
    main() { 
       if (
    xOriginal == nullxOriginal efsExternal("yourFileName.efs"); 

        
    // extract the nPearsons series from the orignal formula
        
    if (xPearsons == nullxPearsons getSeriesxOriginal); 

       return 
    xPearsons.getValue(0);


    plot Azval and Bzval
    PHP Code:
    var xOriginal null;
    var 
    xAzval null;
    var 
    xBzval null;

    function 
    main() { 
       if (
    xOriginal == nullxOriginal efsExternal("yourFileName.efs"); 

        
    // extract the Azval and Bzval series from the orignal formula
       
    if (xAzval == nullxAzval getSeriesxOriginal); 
       if (
    xBzval == nullxBzval getSeriesxOriginal); 

       return new Array(
    xAzval.getValue(0), xBzval.getValue(0) );

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      OK, this is clear. But, in the second method, does this mean that the original formula only executes once for a new bar and the two new formulas -- with efsExternal -- simply retrieve data from the original formula?

      If so, this works fine as long as the processor can complete all of the tasks before a new bar is completed. If each new formula causes the original formula to re-execute, that could be a problem due to time. I'll just have to try it.

      Thanks.
      ---------------------------------------------------------------
      [QUOTE]Originally posted by JasonK

      A single formula can only plot to one pane. To plot your values in two panes will require two formulas.

      There are two ways to accomplish this. The first option is to simply make a copy of your formula with a different name and modify the return statements in the two formulas to only plot "nPearsons" in one and the other two series in the second formula.

      The second method would be to leave your original formula as is and create two new formulas that call the original through efsExternal(). This function retrieves all three series, but your return statement in each of the two new formulas would only plot the series you need. Here's a basic code example (excluding preMain) of how to code this for the two new formulas. Replace the "yourFileName.efs" with the actual name of your original formula. Note that if all three formulas are in the same folder the path does not need to be specified in the efsExternal() function.

      Comment

      Working...
      X