Announcement

Collapse
No announcement yet.

Multiple time Frames

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

  • Multiple time Frames

    Good Morning,

    The following Test code draws objects on a chart. How would I modify it to calculate on a 10 minute basis when applied to a 1 minute chart?

    Thank you for your assistance.

    Alan


    /********
    Test File
    *********/
    var BB = 0;
    var CC = 0;

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("TEST2");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
    }

    function main() {
    if ( getBarState() == BARSTATE_NEWBAR ) {
    CC++;
    }

    Range();
    }

    function Range() {
    if (((close() - low())/(high() - low())) >= 0.9 ) {
    drawTextRelative( 0, high(), "ˆ", Color.blue, null, Text.BOLD | Text.CENTER | Text.BOTTOM, "Wingdings 1", 20, AA() );
    }

    }

    function AA() {
    BB ++;
    return(BB);
    }

  • #2
    Hi Alan,

    replace your call to the function Range() with this:

    if(getMinute(0)%10==0)Range();

    This is the modulo command which returns the remainder. Therefore, this will return a remainder of zero every 10 minutes and execute your function.

    Comment


    • #3
      Time

      Thank you for the sugestion. The following code shows the implimentation. I receive an error message saying there is a missing ";". Please advise how to correct my mistake.

      Thank you,

      Alan

      /********
      Test File
      *********/
      var BB = 0;
      var CC = 0;

      function preMain() {
      setPriceStudy(true);
      setStudyTitle("TEST2");
      setShowCursorLabel(false);
      setShowTitleParameters(false);
      }

      function main() {
      if ( getBarState() == BARSTATE_NEWBAR ) {
      CC++;
      }

      if(getMinute(0)%10==0)Range();

      }

      function Range() {
      if (((close() - low())/(high() - low())) >= 0.9 ) {
      drawTextRelative( 0, high(), "ˆ", Color.blue, null, Text.BOLD | Text.CENTER | Text.BOTTOM, "Wingdings 1", 20, AA() );
      }

      }

      function AA() {
      BB ++;
      return(BB);
      }

      Comment


      • #4
        Alan,

        I ran the following code in a one minute chart with no errors. Please try and post your code using php so I can look to see if there are any extranious characters ...

        PHP Code:
        /********
        Test File
        *********/
        var BB 0;
        var 
        CC 0;

        function 
        preMain() {
        setPriceStudy(true);
        setStudyTitle("TEST2");
        setShowCursorLabel(false);
        setShowTitleParameters(false);
        }

        function 
        main() {
        if ( 
        getBarState() == BARSTATE_NEWBAR ) {
        CC++;
        }

        if(
        getMinute(0)%10==0)Range(); 

        }

        function 
        Range() {
        if (((
        close() - low())/(high() - low())) >= 0.9 ) {
        drawTextRelative0high(), "ˆ"Color.bluenullText.BOLD Text.CENTER Text.BOTTOM"Wingdings 1"20AA() ); 
        }



        function 
        AA() {
        BB ++;
        return(
        BB);

        here is how to create a similar block of code





        This is much easier to read and convenient for mid size efs's.

        When you got your error signal, what line did the error occur?

        Comment


        • #5
          Drawing

          Steve,

          Thank you for the help.

          I attached the code in the old method because I do not know what php is. Please advsie how to do that to help in the future.

          I corrected the return and it now plots ok on a 1 minute chart. It produces the same results as using a return() in the call on a seperate 1 minute chart.

          When I use an EFS with the return() call on a chart and then add an EFS like the following using the 10 minute feature onto the same chart I get many extranious markers on the chart.

          My objective is I like the plot of the EFS using the return() call when applied to a 1 and 10 minute chart. I want to plot the results of the 10 minute chart on the 1 minute chart.

          Your assistance is greatly appreciated.

          Alan







          /********
          Test File
          *********/
          var BB = 0;
          var CC = 0;

          function preMain() {
          setPriceStudy(true);
          setStudyTitle("TEST2");
          setShowCursorLabel(false);
          setShowTitleParameters(false);
          }

          function main() {
          if ( getBarState() == BARSTATE_NEWBAR ) {
          CC++;
          }

          if(getMinute(0)%10==0)Range();

          }

          function Range() {
          if (((close() - low())/(high() - low())) >= 0.9 ) {
          drawTextRelative( 0, (high()+1), "ˆ", Color.blue, null, Text.BOLD | Text.CENTER | Text.BOTTOM, "Wingdings 1", 50, AA() );
          }

          }

          function AA() {
          BB ++;
          return(BB);
          }

          Comment


          • #6
            Hi Alan,

            Regarding php, evidently you cannot see my demo of how to enclose your code using the php option in my previous post, hmm... perhaps you have the "Show image attachments and [img] code in Posts?" option in your profile turned off.

            If you would like to learn I would recommend trying to look at the GIF image I posted which shows how to post code in the manner I referenced.

            Regarding the error you had. In your repost, only the drawtextrelative line was different than the previous post, so I am a bit confused as to what was really giving you that error.

            As far as your current question(s), I need some clarification

            Originally posted by Alan2004
            It produces the same results as using a return() in the call on a seperate 1 minute chart.
            how exactly are you calling this efs?

            Originally posted by Alan2004
            My objective is I like the plot of the EFS using the return() call when applied to a 1 and 10 minute chart. I want to plot the results of the 10 minute chart on the 1 minute chart.
            You indicate you want to apply to both a 1 and 10 minute chart, then turn right around and indicate you want the 10 minute results plotted only on the 1 minute chart. This is a bit confusing.

            Do you want to call this efs from any chart by imbedding code in another efs to do the calling??

            Clarification would help quite a bit, I would hate to spend an hour on this believing I was helping you, only to later find out it is not what you want.

            Comment


            • #7
              customCCI previous value

              Please see the modified "customCCI" file from EFS2 Formulas:

              I run this on a 30min chart to collect the daily CCI values. The current and previous CCI values plot correctly, but the "vLast" does not change from vLast=1 or vLast=2.

              Any help would be appreciated.
              Thanks,
              kenac
              Attached Files

              Comment


              • #8
                try moving

                bInit = true;
                }

                after

                var v2 = xCCI.getValue(-1);

                I think you are only testing the current and last cci value once when bInit = false.

                Comment


                • #9
                  Thanks Dave...that did it. I must have been so tired trying to get it to where it was.
                  kenac

                  Comment

                  Working...
                  X