Announcement

Collapse
No announcement yet.

GetStochStudy() for a different interval

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

  • GetStochStudy() for a different interval

    Hello,

    I have an EFS script where I want to determine the stochastic situation for a different interval. How would I do that?

    For example, if I am viewing a 3-min chart, I'd like to know the stochastic direction on the 5-min and the 30-min interval.

    When you load the stochastic study, I don't see how so specify the interval in any way: var studyStoch = new GetStochStudy( 14, 3, 3 );


    Thanks!
    Daniel
    eSignal File Share: http://share.esignal.com/groupcontents.jsp?groupid=1130

  • #2
    Re: GetStochStudy() for a different interval

    Daniel
    The GetXxx() studies have not been ported to efs at this time so they do not have the capability on their own to be based on an external symbol and/or interval (like the efs2 studies).
    However you can calculate one of these studies in a separate function [within the same efs] or in a different efs and then call either one using the efsInternal() or efsExternal() functions and passing as the last parameter the external symbol and/or interval through the sym() or inv() functions. This will allow you to control the context in which the separate function or efs is running and at the same time will create a series.
    In this post you can find a basic example of how to call an efs1 function which like the GetStochStudy() function is not enabled for use with multiple intervals and/or symbols.
    For the description and syntax required by the efsInternal() and efsExternal() functions see the links to the corresponding articles in the EFS KnowledgeBase.
    Alex


    Originally posted by neoikon
    Hello,

    I have an EFS script where I want to determine the stochastic situation for a different interval. How would I do that?

    For example, if I am viewing a 3-min chart, I'd like to know the stochastic direction on the 5-min and the 30-min interval.

    When you load the stochastic study, I don't see how so specify the interval in any way: var studyStoch = new GetStochStudy( 14, 3, 3 );


    Thanks!
    Daniel

    Comment


    • #3
      I tried to create a simple script to get this to work and keep getting null returned for the value that I care about most (StochK2).

      "StochK" returns the expected value.
      "StochK2" returns null
      "testVal" returns the expected value.

      Am I missing something? Thanks!


      PHP Code:
      function preMain()
      {
          
      debugClear();
          
          
      setPriceStudy(true);
          
      setShowCursorLabelfalse );
          
      setShowTitleParameters(false);

          
      setStudyTitle("Test");
      }


      var 
      InvShort "377T";

      function 
      main()
      {    
          var 
      studyStoch = new GetStochStudy143);    // GetStochStudy( nLength, nMavg1, nMavg2 )
          
      var StochK studyStoch.getValue(GetStochStudy.STOCHK,0);
        
          var 
      studyStoch2 efsInternal"getStochStudyCustom"sym(getSymbol()+","+InvShort) );
          var 
      StochK2 studyStoch2.getValue(GetStochStudy.STOCHK,0);
          
          var 
      testVal efsInternal("simpletest",sym(getSymbol()+","+InvShort));
          
          
      debugPrintlnStochK " " StochK2 " " testVal);
      }


      // Called as an "efsInternal" which allows us to specify the interval context
      //
      function getStochStudyCustom()
      {
          return new 
      GetStochStudy143);    // GetStochStudy( nLength, nMavg1, nMavg2 )
      }

      function 
      simpletest() 
      {
          return 
      close(0);

      eSignal File Share: http://share.esignal.com/groupcontents.jsp?groupid=1130

      Comment


      • #4
        To answer my own question, it seems that using the method that I posted earlier would equate to returning an array of arrays, which it seems EFS can't handle (I've run into that frustrating problem in the past). So, to fix that problem, you have to return each array separately, via separate calls.

        Updated code that seems to work:

        PHP Code:
        function preMain()
        {
            
        debugClear();
            
            
        setPriceStudy(true);
            
        setShowCursorLabelfalse );
            
        setShowTitleParameters(false);

            
        setStudyTitle("efsInternal Test");
        }


        var 
        InvShort "610T";

        function 
        main()
        {    
            
        // Wait until last bar drawn before we do our stuff
            //if (getCurrentBarIndex() != -1)  {return;}
            
            
        var studyStoch = new GetStochStudy143);    // GetStochStudy( nLength, nMavg1, nMavg2 )
            
        var StochK studyStoch.getValue(GetStochStudy.STOCHK,0);
          
            var 
        studyStochCustK efsInternal"getStochStudyCustomK"sym(getSymbol()+","+InvShort) ).getValue(0);
            var 
        studyStochCustD efsInternal"getStochStudyCustomD"sym(getSymbol()+","+InvShort) ).getValue(0);
            var 
        studyStochCustMarks efsInternal"getStochStudyCustomMarks"sym(getSymbol()+","+InvShort) ).getValue(0);
           
            var 
        testVal efsInternal("simpletest",sym(getSymbol()+","+InvShort));
            
               
        debugPrintlnStochK " " studyStochCustK " " studyStochCustD " " studyStochCustMarks);
        }


        // Called as an "efsInternal" which allows us to specify the interval context
        //
        var studyStochCustom null;
        function 
        getStochStudyCustomK()
        {
            if (
        studyStochCustom==nullstudyStochCustom = new GetStochStudy143);    // GetStochStudy( nLength, nMavg1, nMavg2 )
            
        return studyStochCustom.getValue(GetStochStudy.STOCHK);
        }
        function 
        getStochStudyCustomD()
        {
            if (
        studyStochCustom==nullstudyStochCustom = new GetStochStudy143);    // GetStochStudy( nLength, nMavg1, nMavg2 )
            
        return studyStochCustom.getValue(GetStochStudy.STOCHD);
        }
        function 
        getStochStudyCustomMarks()
        {
            if (
        studyStochCustom==nullstudyStochCustom = new GetStochStudy143);    // GetStochStudy( nLength, nMavg1, nMavg2 )
            
        return studyStochCustom.getValue(GetStochStudy.MARKS);
        }

        function 
        simpletest() 
        {
            return 
        close(0);

        eSignal File Share: http://share.esignal.com/groupcontents.jsp?groupid=1130

        Comment


        • #5
          Daniel,
          Thanks for the interesting post, for a while now I've been trying to work out a similar method or formula (running an alternate time interval chart within a page). My Java programing skills are very basic, I tried coping your latest code and running, but it oviously calls other formulas and gives an error. How would I set this up to make it functional?
          Thanks for your help.
          Dan

          Comment


          • #6
            Originally posted by dan4665
            Daniel,
            Thanks for the interesting post, for a while now I've been trying to work out a similar method or formula (running an alternate time interval chart within a page). My Java programing skills are very basic, I tried coping your latest code and running, but it oviously calls other formulas and gives an error. How would I set this up to make it functional?
            Thanks for your help.
            Dan

            Dan,
            The code should be functional. What error are you getting? Perhaps you are having an issue due to not having AGET? That GetStochStudy() is an AGET only call (I believe).

            Daniel
            eSignal File Share: http://share.esignal.com/groupcontents.jsp?groupid=1130

            Comment


            • #7
              No, I don't have AGET... so that explains the error message 'line 21, GetStochStudy not enabled'.
              Thanks for your help,
              Dan

              Comment

              Working...
              X