Announcement

Collapse
No announcement yet.

Parabolic SAR function

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

  • Parabolic SAR function

    I have written the following formula:

    function preMain()
    {
    setPriceStudy(true);
    setStudyTitle("Parabolic SAR Entry");
    }

    // Sets Parabolic SAR variables

    var PrevSAR = 0;
    var CurrSAR = 0;

    function main()
    {

    // Gets Parabolic SAR value for current bar and previous bar

    CurrSAR = sar(.15, .07, .3)

    PrevSAR = sar(.15, .07, .3, -1)

    debugClear();
    debugPrintln("CurrSAR: " + CurrSAR);
    debugPrintln("PrevSAR: " + PrevSAR);
    }

    When I load this in a 400 tick chart for AB #F or AB U5 in the Bar Replay Mode, the values are returned properly in the Formual Output Window. If I click the Replay button, or click Go Forward, the subsequent values returned in the window are:

    PrevSAR: NaN
    CurrSAR: null

    If I let it sit on a bar for a while (about 60 seconds or so), sometimes the NaN and the null will change to a correct SAR value, but only occassionally. I only have 3 days of data in the chart. Any idea what the problem is in my formula?

    I am running 7.91 on a 3.2 Mhz CPU with 2 gig of RAM on XP Pro ,with my broker's application as the only other application software installed on the machine, so I'm assuming the problem is in the formula.
    Last edited by werosen; 06-23-2005, 07:55 AM.

  • #2
    Hello werosen,

    I tested your code in the latest build (730) for 7.9.1 and it is working fine. When you run this in bar replay do the values you see in the formula output window always say NaN and null? Try adding a return statement to the end of main() and return CurrSAR and PrevSAR. Let me know if you see two valid lines plotting on the chart.

    PHP Code:
    return new Array(CurrSARPrevSAR); 
    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


    • #3
      Hi Jason

      Since we are running different builds, we don't have a basis for comparison. I installed the download available on your site yesterday and that is build 729. If you tell me how to get build 730, I'll install it and run the test you request.

      Here is an except from my post to answer your question regarding what is displayed in Formula Output window:

      When I load this in a 400 tick chart for AB #F or AB U5 in the Bar Replay Mode, the values are returned properly in the Formula Output Window. If I click the Replay button, or click Go Forward, the subsequent values returned in the window are:

      PrevSAR: NaN
      CurrSAR: null

      If I let it sit on a bar for a while (about 60 seconds or so), sometimes the NaN and the null will change to a correct SAR value, but only occasionally.

      Additionally, I am using this code in a larger script on live data and it regularly fails to execute. Just as with the script I posted, when I reload the formula it executes correctly on the initial bar, but then fails on subsequent bars.

      Thanks,
      Warren

      Comment


      • #4
        Warren
        FWIW I am running build 729 on one of my machines and I am not getting any invalid returns. If I use Bar Replay and go back in time to a point where the Parabolic is not yet plotting the Formula Output window just returns 0 for both PrevSAR and CurrSAR. As I then move forward I get a first value for CurrSAR (while PrevSAR is still 0) after which that value shifts to PrevSAR.
        Alex

        Comment


        • #5
          I hear you Alex. Now what do I do since we are getting different results with the exact same code?

          Comment


          • #6
            Jason:

            I added the return code and ran the test. The lines plot correctly on the chart in replay mode. On initial load, the values are returned correctly in the formula window, but on every subsequent bar PrevSAR returns: NaN and CurrSAR returns: null. However, now the NAN and null will change to the correct values in a 2 - 6 second timeframe for every bar.

            Warren

            Comment


            • #7
              Hello werosen,

              I am seeing the problem with a 400T chart as you are. I wasn't testing that interval previously. Strange as it is, Alex is not having the problem. I've been looking into this for some time now and I'm not able to tell at the moment what the cause is. We'll continue to investigate.

              I tested the code on 7.9 (build 719) and it works fine on the 400T interval. I would suggest rolling back to 719 for now, until we can get this ironed out. Alex and I will be looking into this later today and will report the problem to development if we don't find the solution.
              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

              Working...
              X