Announcement

Collapse
No announcement yet.

Creating a series from the substraction of two other series

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

  • Creating a series from the substraction of two other series

    Hi,

    I'm trying to create a series by substracting the current value of two other series.

    I know the script below plots fine but I need to access the last value of that created series using Series.getValue(0) for use in a larger efs study.

    As I understand it, the output of efsInternal should create a series as in:

    PHP Code:
    debugClear();

    function 
    preMain() {
        
    setPriceStudy(false);
    }

    function 
    main() {

        
    DIFF test();

        return 
    DIFF;
    }
    / *************************************************
                 
    SUPPORT FUNCTIONS                    
    **************************************************/    
    var 
    xPDI null;
    var 
    xNDI null;

    function 
    test(){

        
    xPDI pdi(10,12);
        
    xNDI ndi(10,12);

        return 
    xPDI.getValue(0)-xNDI.getValue(0);

    But I have only been able to create a single value. It plots fine but I need it as a series. I've tried many variations, even including the DIFF = Test(); within a bInit routine but that doesn't work either.

    I appreciate any help.

    wayne
    Last edited by waynecd; 02-05-2009, 08:23 PM.

  • #2
    Hi Wayne,

    You need to use the efsInternal() to obtain a series like you described. However you did not use efsInternal()...

    Comment


    • #3
      Hi Steve,

      What a brain lapse.

      Thanks

      Wayne

      Comment


      • #4
        In an attempt to make this post worthwhile, here is my solution to my original post for those who may have a use for it.

        PHP Code:
        debugClear();
        var 
        bInit false;

        function 
        preMain() {
            
        setStudyTitle("test");
            
        setPriceStudy(false);
        }

        function 
        main( ) {

            if(
        bInit == false){
                
        bInit true;
            }
            
        DIFF efsInternal("PDI_NDI_DIFF");
            
        vDiff DIFF.getValue(0);
            
        //debugPrintln(vDiff);

            
        return DIFF;
        }
        /*******************************************
                     SUPPORT FUNCTIONS              
        ********************************************/    

        function PDI_NDI_DIFF(){

            
        xPDI pdi(10,12);
            
        xNDI ndi(10,12);

            return 
        xPDI.getValue(0)-xNDI.getValue(0);

        wayne

        Comment


        • #5
          Hi Wayne,

          Figured it was a slip, thanks for posting the followup code.

          Comment

          Working...
          X