Announcement

Collapse
No announcement yet.

efsInternal - Passing functions as parameters

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • efsInternal - Passing functions as parameters

    Hi,

    Can someone point me to some examples of using [more than once, very important] efsInternal to the same function, who's parameters are other internal functions?

    Example:

    var st1 = rsi(3, efsInternal("rOsc",rMA5,rMA10));
    var st2 = rsi(3, efsInternal("rOsc",rMA10,rMA20));
    var st3 = rsi(3, efsInternal("rOsc",rMA20,rMA50));

    where:
    function rOsc(,rFast,rSlow) {return rFast(0)-rSlow(0);}

    and:
    function rMA5() {return stMA5.getValue(0)*5;}
    function rMA10() {return stMA10.getValue(0)*10;}
    function rMA20() {return stMA20.getValue(0)*20;}
    function rMA50() {return stMA50.getValue(0)*50;}

    and of course stMA5,stMA10,stMA20,stMA50 are properly declared.

    The above example works fine if I use hard coded rsi function [internally], but it is slow. With efsInternal I get the same plot [the last declared]. If I use diferent length for rsi, i get three diferent plots.

    Note: We went through something similar before, but it was blamed on EFS1 at the time.
    Here, I suspect it has to do with the way EFS engine runs series, one at a time, at ALLBARS, which may require that ALL PARAMETERS of efsInternal to be already declared data series, case when I can't use it.

    If someone who understands the internals of the efs engine can clarify this issue, it would be greatly appreciated.

    Thank you.
    Mihai Buta

  • #2
    It has been almost a week since I posted this question.

    Nobody from eSignal support feels obligated to provide an answer? I am, afterall, a am paying customer.

    Thank you.
    Mihai Buta

    Comment


    • #3
      Hi Mihai,

      Although EFS is supported by the community of users, we do try to assist where we can. Unfortunately, our EFS experts have been tied-up recently. We'll have more availability next week to assist. Sorry for the delay.

      Hopefully, another user may have some insight.

      Thanks.

      Comment


      • #4
        Hi Scott,

        Thank you very much.
        I can wait, no problem, as long as I know I am not forgotten.
        Mihai Buta

        Comment


        • #5
          Hello Mihai,

          The key is to make sure the parameters you are passing inside the efsInternal() calls are also in the form of series objects, which can be accomplished using efsInternal() nested inside the efsInternal() call for the rOsc function. Try the following and let us know if this accomplishes what you wanted.

          PHP Code:
          function preMain() {
              
          //setPriceStudy(true);
              
          setStudyTitle("test");
              
          //setShowCursorLabel(false);
              
          setCursorLabelName("st1"0);
              
          setCursorLabelName("st2"1);
              
          setCursorLabelName("st3"2);
          }

          var 
          bInit false;

          var 
          stMA5 null;
          var 
          stMA10 null;
          var 
          stMA20 null;
          var 
          stMA50 null;

          var 
          st1 null;
          var 
          st2 null;
          var 
          st3 null;

          function 
          main() {
              if (
          bInit == false) {
                  
          stMA5  sma(5);
                  
          stMA10 sma(10);
                  
          stMA20 sma(20);
                  
          stMA50 sma(50);
                  
          st1 rsi(3efsInternal("rOsc",efsInternal("rMA"stMA55),efsInternal("rMA"stMA1010)));
                  
          st2 rsi(3efsInternal("rOsc",efsInternal("rMA"stMA1010),efsInternal("rMA"stMA2020)));
                  
          st3 rsi(3efsInternal("rOsc",efsInternal("rMA"stMA2020),efsInternal("rMA"stMA5050)));
                  
          bInit true;
              }
           
              return new Array(
          st1.getValue(0), st2.getValue(0), st3.getValue(0));
          }


          function 
          rOsc(rFastrSlow) {
              return 
          rFast.getValue(0)-rSlow.getValue(0);
          }

          function 
          rMA(xnum) {
              if (
          == null) return;
              return 
          x.getValue(0)*num;

          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


          • #6
            Hi Jason,

            Thank you and, again, sorry for the late reply.

            I understand now and it makes absolute sense what you say: because the EFS engine runs all data series at ALBARS time, all parameters have to be data series as well.

            The only issue is with performance vs ease of coding.
            I wanted to use efsInternal for the latter, but ran into performance slowdown, because it will execute every tick [in real time].

            I suggested this before as solution: Allow INDIVIDUAL "ExecuteOnCloseOnly" for each data series, as opposed to the entire efs. This way, we could choose which functions to be executed every tick and which not.

            As I believe others run often in similar problem, I suggest to add some notes/clarifications about it in efsInternal Help file.

            Thank you again for your help.
            Mihai Buta

            Comment

            Working...
            X