Announcement

Collapse
No announcement yet.

And another pivot formula (with bugs) -help needed

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

  • And another pivot formula (with bugs) -help needed

    Hello,

    I have modified The Matrix Pivot formula who displays R4,S4,R5,S5 so that the code looks cleaner and it adds gap& ATR calculation.

    Unfortunately there is something wrong in it and I can't find it...

    Maybe you can help ?
    Attached Files

  • #2
    Phantom:

    You need to return some data in order for eSignal to plot it. Right now, all you are doing is performing calculations.

    Add the following line at the very end of your main() function (e.g., right after the DoPivotDo = ..... stuff);

    return vOutputArray;


    Chris

    Comment


    • #3
      Thanks Chris for your help!

      I also tried to use your ATR calculation formula, but it gives me different results than the ones from your own Pivot Console formula, this is a mystery for me...

      And for whatever reason the lines are drawn but not since the start of the day, just on the latest bars...

      I upload corrected 3.1 formula
      Attached Files
      Last edited by Phantom; 06-21-2003, 09:55 AM.

      Comment


      • #4
        No one can help me debug this formula?

        Comment


        • #5
          Phantom:

          First of all, you should not be calling the calcATR function from the main loop.... it now gets called on every new tick which is a waste of resources. You should move the call down into the calcPivotD() function... just below the line that says:

          if (vIndex != null ) {

          That way it will only get calculated once each day which is what you want.

          So, change calcPivotD(GapX, cATR) to calcPivotD(GapX,ATRPeriod) and then add the following line at the location mentioned above:

          cATR = calcATR( ATRPeriod );

          Finally, what are you going to do with the cATR value?? You have no code to deal with that. The average ES ATR these days is around 18 points... if you just return the ATR value to the chart (which is what you are doing now), it will be drawing lines down around the 18 level which I doubt is what you intended. Instead, you probably need to use the ATR value as a basis for calculating 2 new bands to be displayed. Exactly what those calculations will be is up to you. I typically take the lowest-low of the current day so far and add the ATR to it to make the high band and then take the highest-high of the day so far and subtract the ATR from it to make the low band but there are alternate methods as well. You need to decide what you want displayed and then write the appropriate formula.

          Chris

          Comment


          • #6
            Thanks Chris for this help.

            As for ATR, I just want to display it in the OHLC box but not on the graph.

            Even if I use your function, the calculation is different than from your Pivot Console formula, a mystery I can't solve...for example on ES#F=2 on a 30 days template, you find ATR20=15.29 and I find 19.11

            And the other annoying bug : the pivot lines are only displayed on the last bars and not on all bars since I was expecting it...
            Does it come from the fact my pivot calculation is in a function? Should I create a loop to launch the pivot calculation on all bars?

            Comment


            • #7
              Phantom:

              I'll take a look at the ATR code and see if I can figure out what's going on. Who knows, your numbers may be the correct ones.

              Regarding the pivot lines, when I run your script on my end, It does plot the lines for all days so I'm not sure what you mean.

              Chris

              Comment


              • #8
                OK Chris you are right, the problem with pivot lines appears in the latest code modification so I started again with 3.1 and everything was ok again, so the bug disappeared.

                Comment

                Working...
                X