Announcement

Collapse
No announcement yet.

Using An Array To Draw A Line

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

  • #16
    Lines

    Jason,

    Attached is the chart after reload.

    Best Regards,

    Alan
    Attached Files

    Comment


    • #17
      Hello Allan,

      The formula you posted has syntax errors. Please double check your formula, or post the version you were using in your chart examples.
      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


      • #18
        Drawline

        Jason,

        Sorry for the mix up on the file.

        Attached is a copy of the file used to produce the subsequent charts. I used April 1st $indu on a 1 minute time frame on $playback. The min/max scale is set for the range needed at 11AM so if you replay just let the chart pass the first hour and the lines will come back into scale. The line movement is noticeable just before 11am, 12:30 and 13:30.

        Best regards,

        Alan
        Attached Files

        Comment


        • #19
          draw

          Jason,

          The attached chart is after pause and before reload.

          Best regards,

          Alan
          Attached Files

          Comment


          • #20
            draw

            Jason,

            The attached chart is after reload.

            Best regards,

            alan
            Attached Files

            Comment


            • #21
              Hello Alan,

              1. All of your drawLine calls need to be inside a check for BARSTATE_NEWBAR. You'll actually need two drawLine calls for Basis1. Just before the NEWBAR routine with all the drawLine calls you'll do a drawLine for Basis1 where point A is the close(0) ( or your eventual second external calc) on bar 0 and B is vReturn on bar -1. This duplicates the Basis1 segment in real time.

              The Basis1 drawLine inside the NEWBAR routine will redraw the line from point A, which will be close(0) on bar 0 to vReturn on bar -1. This is a bit confusing. The key is to remember that at NEWBAR we're setting bar -1 to the value of vReturn. So your drawLine lines need to reflect the same action as what setBar does to the indicator line.

              Then Basis2 will be drawn from vReturn1 on bar -1 to aMyArray1[0] on bar -2. Basis3 will be drawn from aMyArray1[0] on bar -2 to aMyArray1[1] on bar -3. The rest of the lines use the next two elements of the array and their respective bars.

              2. vReturn1 = (vReturn+5) needs to be inside the BARSTATE_NEWBAR routine just before the drawLine calls. By doing this outside the NEWBAR routine, the line gets out of wack because vReturn1 needs to store the last value of vReturn from the previous bar. In real time, you were allowing vReturn1 to get set the the current bar's value of vReturn. That's why the line realigns after a reload. When a formula is reloading it only executes once per bar, which eliminates the need for the NEWBAR routine. But as you can see now, you need to incorporate this to handle real time data where there are multiple executions of the formula during the bar.

              3. Delete the line: aMyArray1[0] = vReturn1. It's not needed. Your pop/unshift routine takes care of updating the array.
              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


              • #22
                Drawline

                Jason,

                Thank you for the suggestions. Will these changes effect the plotting of the drawline, setbar or both?

                Best Regards,

                Alan

                Comment


                • #23
                  Hello Alan,

                  These instructions correct your logic for the drawLine routine so that is matches the indicator line. The setBar routine is unchanged.
                  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


                  • #24
                    Drawline

                    Jason,

                    If these changes only effect the drawline function, why does the setbar line move when the DOC201 efs is reloaded?

                    Best Regards,

                    Alan

                    Comment


                    • #25
                      drawline

                      Jason,

                      I have included your suggestions into the attached code. The following charts show the old code you reviewed on top and the attached code on the bottom. We are getting close but the lines remain different. The second chart is after a reload and both setbar blue lines move and change shape after the reload.

                      Your assistance is greatly appreciated.

                      Best Regards,

                      Alan
                      Attached Files

                      Comment


                      • #26
                        drawline

                        Jason,

                        This chart is after pause on replay.

                        Alan
                        Attached Files

                        Comment


                        • #27
                          drawline

                          Jason,

                          This chart is after reloading both efs.

                          Alan
                          Attached Files

                          Comment


                          • #28
                            Hello Alan,

                            The instructions from #1 weren't completely incorporated into your code. I made the corrections for you. Take a look at the attached code to see what the differences were. By the way, I took the +5 logic out so that the drawline line overlaps the indicator line. I think it's easier to see that way, but feel free to add that back in.
                            Attached Files
                            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


                            • #29
                              Drawline

                              Jason,

                              Thank you for all the time you have invested during the last 9 days. The code works great! The changes are subtle and I have learned a lot from this effort.

                              Best Regards,

                              Alan

                              Comment

                              Working...
                              X