Announcement

Collapse
No announcement yet.

offsetting result of formula ahead one bar

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

  • offsetting result of formula ahead one bar

    I have a formula that creates a result for the next bar.

    the formula utilizes a plottype_line and correctly plots the result but that is displayed on the most recently completed bar. The result being displayed on the current bar being built appropriately jumps around until that bar is completed.

    I do not wish to change the formula to include anything along the lines of set compute on close.

    Is there anyway to plot the resulting line forward by one bar (for the entire displayed history of the line and not just the current bar)?

    My formula simply plots the one line as "return x" and does not include any parameters or any variable numbers that are passed into main (other than var xyz = whatevers in premain).

    thanks in advance,

    Christine

  • #2
    Christine
    Attached is an example that uses the builtinMA.efs and displaces the plot forward by one bar without using the MA's offset parameter. The changes are commented in the efs
    Hope this helps
    Alex
    Attached Files

    Comment


    • #3
      I've looked over the code and it appears that this formula (if properly edited) will NOT show the results of the line being calculated by the current bar.

      I've already edited my formula to create a version that accomplishes the same thing (using the barstate_newbar x1=x thing).

      What I am looking to do is to plot x one space ahead of the current bar being drawn (which would show x1 on the current bar being drawn). (references to x and x1 based on your kindly-posted efs)

      is that impossible?

      I'm trying to avoid having to run the formula versions twice, or for that matter to draw two lines instead of just one.

      I admittedly am not at all versed in the use of an offset other than a way to vary inputs into a formula, but it seems that there does not seem to be a way to do something along the lines of
      return x(currently drawn bar +1)

      The only other idea I had was if I could do something along the lines of the following:

      return x1, x
      (or return new array(x1,x) )(x1 being based on your below formula)
      where x would be plotted only once and on the current bar along with the x1 line

      (edited for grammar only)
      Last edited by christineesq; 04-07-2004, 03:31 PM.

      Comment


      • #4
        Christine
        If I understood correctly you want to see the plot of x which will now be to the right of the current bar. FYI an efs cannot plot where there is no data so you will have to resort to a workaround ie using drawLineRelative to simulate the plot of the study at x.
        To see how this could be done add the following
        drawLineRelative(0,x1,1,x,PS_SOLID,1,Color.blue,1) ;
        in line 63 of the efs I posted earlier and you should now see that the MA is "plotting" one bar beyond the current bar.
        Hope this helps
        Alex

        Comment


        • #5
          Alex,

          As usual, you have saved the day!

          thanks very much for your continuous generosity of knowedge, time and effort!

          Christine

          Comment


          • #6
            Alex,
            That is a good work-around.

            The only problem now is that you can't see what the value of the "extension" is. The cursor window and the box in the price column both display the return value (x1) and not the value of the final piece added by drawLineRelative.

            Do you know of any way to control that?

            Thanks, Bob

            Comment


            • #7
              Hello Bob,

              The data in the cursor window reflects the data that is returned to the chart via the return statement from main(). Since we can't return data to future bars, we don't have control over the cursor label data for future bars. One possible solution here might be to use drawTextAbsolute() to display the future bar's value on the chart.
              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


              • #8
                To complete the example efs posted earlier in this thread here is the same efs that now includes all the revisions that have been suggested since.
                Alex

                Attached Files

                Comment

                Working...
                X