Announcement

Collapse
No announcement yet.

efsInternal problems

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

  • efsInternal problems

    im trying run a moving average on the a series returned from efsInternal(). I thought this was quite simple, as the following example does what intended on chart reload. The problem is when the bars update in realtime all i get is a straight line from the moving average. What am i missing here. In this example i have reduced the function used to something basic returning a barnumber.

    This study uses computeonclose()

    Code:
    var xIntSeries = null;
    function main(){
    
    var nBarIndex = getCurrentBarCount()-1;
    
      debugPrintln(nBarIndex);
    
      xIntSeries = efsInternal( "myinternal"); 
    debugPrintln("xIntSeries="+xIntSeries.getValue(0));    
    debugPrintln("xIntSeries="+xIntSeries.getValue(1));    
    debugPrintln("xIntSeries="+xIntSeries.getValue(2));    
      vSMA = sma(20,xIntSeries);
    
      return new Array (xIntSeries.getValue(0), vSMA.getValue(0) );
    
    }
    
    function myinternal(){
    var nBarIndex = getCurrentBarCount()-1;
      return nBarIndex;
    }
    Another funny observation is the formula output at the end of historical reload and the beginning of realtime output.

    xIntSeries=null // why do these become null in realtime
    xIntSeries=null
    xIntSeries=1298
    1298
    xIntSeries=null
    xIntSeries=1296
    xIntSeries=1297
    1297
    xIntSeries=1294
    xIntSeries=1295
    xIntSeries=1296
    1296

  • #2
    You get the nulls in realtime because you are asking for future values of the series with the getValue(1) and getValue(2) statements.

    You told it to give you the value 1 and 2 bars into the future. Since they don't exist on realtime, you get null values.

    If you meant to get 1 and 2 bars back you should use -1 and -2.

    Steve

    Comment


    • #3
      theperm
      At this time setComputeOnClose() is not compatible with the efsInternal() and efsExternal() functions
      Alex

      Comment


      • #4
        Thats not much use. When will it be supported.

        So how is one suppose to do this. I'm having real trouble with update on tick here, when i run efsinternal series through a moving average.

        Comment


        • #5
          Hello theperm,

          I'm not sure that efsInternal() and efsExternal() can be compatible with setComputeOnClose(). Regardless, if this is important to you, please feel free to submit your request to [email protected].

          However, looking at your code, I don't see a need for setComputeOnClose(). Try placing your series initialization inside a "bInit" routine. This forces the series object to be initialized only once. For the remaining bars, you can simply reference their values with the getValue() method. Start with the following and see if this works for you.

          PHP Code:
          var bInit false;
          var 
          xIntSeries null;
          var 
          xSMA null;

          function 
          main(){
              
              if (
          bInit == false) {
                  
          xIntSeries efsInternal"myinternal"); 
                  
          xSMA sma(20,xIntSeries);
                  
          bInit true;
              }
              
              if (
          xSMA.getValue(0) == null) return;

              return new Array (
          xIntSeries.getValue(0), xSMA.getValue(0) );
              
          }

          function 
          myinternal(){
              var 
          nBarIndex getCurrentBarCount()-1;
              return 
          nBarIndex;

          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

          Working...
          X