Announcement

Collapse
No announcement yet.

Floating Vertical Line

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

  • #31
    Hello Steve,

    Yep, create four global variables.

    var nHcntr = 0;
    var nLcntr = 0;
    var bH = false;
    var bL = false;

    The first two will store counts for the number of times a new high or low occurs. The two booleans will be used for real time processing so that only one new high or low occurence is counted for any single bar. In other words, it will prevent the cntr variables from incrementing every time a new high or low occurs during the bar or interval.

    If you want the count to reset for each day, then reset these two variables to 0 inside your check for the new day (i.e. getDay(0) != getDay(-1)) at the top of main.

    Somewhere at the top of main, add a check for new bar and reset the two booleans.

    PHP Code:
    if (getBarState() == BARSTATE_NEWBAR) {
        
    bH false;
        
    bL false;


    Next, add two if statements just before you do the Math.max and .min calls for vHigh and vLow. These statements will test for a new breach of the high or low and increment the counters accordingly. If one of the conditions evaluates to true you need to set the corresponding boolean to true, which will prevent the count from incrementing again until the next bar starts.

    PHP Code:
    if (bH == false && vHigh) {
        
    bH true;
        
    nHcntr++;
    }
    if (
    bL == false && vLow) {
        
    bL true;
        
    nLcntr++;

    At this point nHcntr and nLcntr should have the numbers you're looking for. You can then use drawTextRelative() and place the number above or below the bar.
    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


    • #32
      Jason, thanks for the code. I'm getting syntax error on line 44. I've attached the study showing all your additions:

      ln 12-15 global variables;
      ln 35-38 if getBarState;
      ln 44-52 if statements for high/low.

      Also, where do I add drawTextRelative()?

      Thanks and hope ya have a great weekend.

      Steve
      Attached Files

      Comment


      • #33
        Hello Steve,

        You have a space between the "==" operator. It should look like this:

        PHP Code:
            if (bH == false && vHigh) { 
        The drawText calls would go inside the if statements just after you increment the cntr variables.
        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


        • #34
          Jason, I've never used drawTextRelative
          so need some help. Getting syntax errors on these:

          ln 47: missing var name.
          What name do I give this variable and on what line?
          Are these the "count" increment variables I need and is this the correct line?

          ln 48: invalide number of arguments (8).
          What arguments do I need to change and is this the correct line?

          Once that these are determined do I need to repeat each drawText Relative statement for each incremental count?

          I've enclosed the study for your quick reference. Thanks again.

          Steve
          Attached Files

          Comment


          • #35
            Hello Steve,

            You left out the text parameter (3rd) to be drawn. All of our EFS reference material can be found in our EFS KnowledgeBase. Here's a link to drawTextRelative().

            drawTextRelative(xBar, yValue, Text, [FGColor], [BGColor], [Flags], [FontName], [FontSize], [TagName], [cx], [cy])

            The parameters surrounded by brackets (ie []) are optional parameters. For your formula try the following.

            PHP Code:
            drawTextRelative(0high(0), nHcntrColor.blacknullText.ONTOP|Text.BOTTOMnull12"High"+nHcntr);  // High labels

            drawTextRelative(0low(0), nLcntrColor.blacknullText.ONTOP|Text.TOPnull12"Low"+nLcntr);  // Low labels 
            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


            • #36
              Not appearing correctly

              Hello All,

              I liked this (as per the images posted) and when I tried on to my chart, the candle bars are not appearing other than some vague dots. Attached the screen shot. What could be error?

              Thanks.

              Sam
              Attached Files

              Comment


              • #37
                Re: Not appearing correctly

                Sam
                If [as I am assuming] you are referring to the Heikin-Ashi formula then you may want to see my post here in reply to a similar question
                Alex


                Originally posted by Sam7768
                Hello All,

                I liked this (as per the images posted) and when I tried on to my chart, the candle bars are not appearing other than some vague dots. Attached the screen shot. What could be error?

                Thanks.

                Sam

                Comment


                • #38
                  Like a miracle!

                  Thank you Alexis.

                  Comment


                  • #39
                    Sam
                    You are welcome
                    Alex


                    Originally posted by Sam7768
                    Like a miracle!

                    Thank you Alexis.

                    Comment

                    Working...
                    X