Announcement

Collapse
No announcement yet.

passing string through efsExternal

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

  • passing string through efsExternal

    Hi,

    I have the following studies and efsExternal, however, I am getting null for the string inside the myMA function.


    var xLMA = efsExternal("myMA.efs", "close", MAlength, eSignalsym+" "+ContractMth+Exchange);
    SMA0 = xSMA.getValue(0);


    and inside myMA.efs, I get Null when I print the aSymbol string.

    function main(nPrice, MALength, aSymbol) {
    ...
    debugPrintln(aSymbol);
    var temp=open(0,sym(aSymbol));

    }

    Not sure what I'm doing wrong.

    W
    Last edited by whammer; 02-28-2008, 06:09 PM.

  • #2
    Re: passing string through efsExternal

    William
    I just tried your example using both efsExternal() and efsInternal() [shown in the screenshot] and it is working fine.
    You may want to post the complete script
    Alex




    Originally posted by whammer
    Hi,

    I have the following studies and efsExternal, however, I am getting null for the string inside the myMA function.


    var xLMA = efsExternal("myMA.efs", "close", MAlength, eSignalsym+" "+ContractMth+Exchange);
    SMA0 = xSMA.getValue(0);


    and inside myMA.efs, I get Null when I print the aSymbol string.

    function main(nPrice, MALength, aSymbol) {
    ...
    debugPrintln(aSymbol);
    var temp=open(0,sym(aSymbol));

    }

    Not sure what I'm doing wrong.

    W

    Comment


    • #3
      Alex, the efsExternal call was able to pass the string through parameter. But because I had applied the external function to the chart as well and the aSymbol value was not set in the chart, so it returned null because of that chart. Now it works. Thanks.

      A question regarding plotting different colors in different return values.

      Below is an indicator function which is supposed to plot 2 MA's on the same chart. But it only plots one of the MA and not the other. Could you point out to me how I can correct it please?
      Thank you.

      W


      PHP Code:
      function main(PriceSourcefastMAslowMA
      {
          if (
      getBarState() == BARSTATE_NEWBAR )
          {
              
      xFMA efsExternal("MA_withgap.efs"PriceSourcefastMAgetSymbol());
              
      FMA0 xFMA.getValue(0);
              
      setDefaultBarFgColor(Color.cyan0);
              
              
      xSMA efsExternal("MA_withgap.efs"PriceSourceslowMAgetSymbol());
              
      SMA0 xSMA.getValue(0);
              
      setDefaultBarFgColor(Color.red1);
              
              return (
      SMA0FMA0);
          }

      Comment


      • #4
        William
        Post the efs that this script is calling.
        Alex


        Originally posted by whammer
        Alex, the efsExternal call was able to pass the string through parameter. But because I had applied the external function to the chart as well and the aSymbol value was not set in the chart, so it returned null because of that chart. Now it works. Thanks.

        A question regarding plotting different colors in different return values.

        Below is an indicator function which is supposed to plot 2 MA's on the same chart. But it only plots one of the MA and not the other. Could you point out to me how I can correct it please?
        Thank you.

        W


        PHP Code:
        function main(PriceSourcefastMAslowMA
        {
            if (
        getBarState() == BARSTATE_NEWBAR )
            {
                
        xFMA efsExternal("MA_withgap.efs"PriceSourcefastMAgetSymbol());
                
        FMA0 xFMA.getValue(0);
                
        setDefaultBarFgColor(Color.cyan0);
                
                
        xSMA efsExternal("MA_withgap.efs"PriceSourceslowMAgetSymbol());
                
        SMA0 xSMA.getValue(0);
                
        setDefaultBarFgColor(Color.red1);
                
                return (
        SMA0FMA0);
            }

        Comment


        • #5
          Here it is.

          PHP Code:

          function main(nPriceMALengthaSymbol) {
              var 
          hPrice=0lPrice=0oPrice=0cPrice=0;
              var 
          Price = new Array;

              if(
          nPrice == "close") {
                  
          Price getValue("close"0, -MALengthaSymbol);
              }
              else if (
          nPrice == "hl/2") {
                  
          hPrice getValue("High"0, -MALengthaSymbol);
                  
          lPrice getValue("Low"0, -MALengthaSymbol);
                  for (
          i=0i<MALengthi++) {
                      
          Price[i] = (hPrice[i] + lPrice[i])/2;  
                  }
              }
              else if (
          nPrice == "oc/2") {
                  
          oPrice getValue("open"0, -MALengthaSymbol);
                  
          cPrice getValue("close"0, -MALengthaSymbol);
                  for (
          i=0i<MALengthi++) {
                      
          Price[i] = (oPrice[i] + cPrice[i])/2;  
                  }
              }
              if(
          MALength == null)
                  
          MALength 3;
              
              var 
          temp=0;
              var 
          vValue;
              
              for (
          i=0i<MALengthi++) 
              { 
                      
          temp += Price[i];    
              }
             
              return (
          temp/MALength);

          Comment


          • #6
            William
            The calling efs is returning a single plot because you are not returning an array.
            In the script replace return (SMA0, FMA0); with return new Array (SMA0, FMA0); and it should work fine
            Alex


            Originally posted by whammer
            Here it is.

            PHP Code:

            function main(nPriceMALengthaSymbol) {
                var 
            hPrice=0lPrice=0oPrice=0cPrice=0;
                var 
            Price = new Array;

                if(
            nPrice == "close") {
                    
            Price getValue("close"0, -MALengthaSymbol);
                }
                else if (
            nPrice == "hl/2") {
                    
            hPrice getValue("High"0, -MALengthaSymbol);
                    
            lPrice getValue("Low"0, -MALengthaSymbol);
                    for (
            i=0i<MALengthi++) {
                        
            Price[i] = (hPrice[i] + lPrice[i])/2;  
                    }
                }
                else if (
            nPrice == "oc/2") {
                    
            oPrice getValue("open"0, -MALengthaSymbol);
                    
            cPrice getValue("close"0, -MALengthaSymbol);
                    for (
            i=0i<MALengthi++) {
                        
            Price[i] = (oPrice[i] + cPrice[i])/2;  
                    }
                }
                if(
            MALength == null)
                    
            MALength 3;
                
                var 
            temp=0;
                var 
            vValue;
                
                for (
            i=0i<MALengthi++) 
                { 
                        
            temp += Price[i];    
                }
               
                return (
            temp/MALength);

            Comment


            • #7
              I see. Thank you again, Alex! :-)

              Comment


              • #8
                William
                You are most welcome
                Alex


                Originally posted by whammer
                I see. Thank you again, Alex! :-)

                Comment

                Working...
                X