• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parabolic SAR cross above

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

    Parabolic SAR cross above

    I would like to use the stored value at the time that it crosses above the Parabolic SAR, but I'm having problems with that as well as errors in my script. Thanks in advance.

    Code:
    #region Variables
    private DataSeries  crossAboveSeries;
    #endregion
    
    protected override void Initialize()
    {
    crossAboveSeries  = new DataSeries(this);
    }
    
    protected override void OnBarUpdate()
    {
    crossAboveSeries.Set(CrossAbove(Close[0],ParabolicSAR(0.02,0.20,0.02)[0],1));
    }

    #2
    Hello,
    Thank you for your post.

    Currently you are trying to set the data series to a boolvalue. You can set the DataSeries to the Close when the Cross occurs by doing the following:
    Code:
    protected override void()
    {
    
        if(CrossAbove(Close[0],ParabolicSAR(0.02,0.20,0.02)[0],1)
        {
            crossAboveSeries.Set(Close[0]);
        }
    If this is not what you are trying to achieve please let us know.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      CodyB,

      Thanks for the fast response. Following your suggestions, I'm getting the following errors CS1502 that CrossAbove has some invalid arguments and NT1503, Argument "2" cannot convert from double to Data.IData.Series

      Comment


        #4
        Hello,
        Thank you for the reply.
        My apologies you would want to do something like the following example:
        Code:
        protected override void()
        {
        
            if(CrossAbove(Close,ParabolicSAR(0.02,0.20,0.02),1)
            {
                crossAboveSeries.Set(Close[0]);
            }
        Please let me know if we can be of any other assistance.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          CodyB,

          Thanks, that took care of the errors. On the other hand, as I do a “Print”, I get multiple values that are not consistent with the Close[0] as it crosses above the Parabolic SAR. Where did I miss out in my script?

          Comment


            #6
            Hello,
            What print statements are you using?

            Can you provide a screenshot of the results and their discrepancies?

            I look forward to your reply.
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Thanks again CodyB,
              I've also included a sample screenshot and a textfile of the output window.

              Based on the screenshot:
              at 13:21 Close= 1182.40, but the output window shows 1156.40
              at 13:36 Close= 1182.10, output window shows 1137.10
              at 14:16 Close= 1181.80, output window shows 1157.40

              Code:
              Print(Time[0].ToString("HH:mm:ss")+"   " +crossAboveSeries);
              Attached Files

              Comment


                #8
                Hello
                So that I may assist further can you provide me a copy of the indicator?
                You can attach your indicator to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your Indicator > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.
                Cody B.NinjaTrader Customer Service

                Comment


                  #9
                  Indicator is enclosed.
                  Attached Files

                  Comment


                    #10
                    Hello,
                    I have fully reviewed the indicator and I am seeing it is working properly.
                    You will want to print out the following to verify this.
                    Code:
                    Print(Time[0].ToString("HH:mm:ss")+"   " +crossAboveSeries[0]);
                    In addition on my end I debugged by telling the indicator to draw a dot at the current bar of the crossAboveSeries and compare it to the closing price of the bar using the databox.

                    Code:
                    private int myCount = 0
                    
                    protected override void()
                    if(CrossAbove(Close,ParabolicSAR(0.02,0.20,0.02),1)) 
                    {
                        crossAboveSeries.Set(Close[0]);
                        myCount++;
                        DrawDot("dot when cross" + myCount,  true, Time[0], crossAboveSeries[0],   Color.Pink);
                    
                    }
                    If we can be of any other assistance please let us know.
                    Cody B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks CodyB for taking the time to review it. I compared it with a "DrawText" of the crossAboveSeries and the indicator is working properly.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by jerblaster23, Today, 03:42 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by brian meade, Today, 01:39 PM
                      1 response
                      4 views
                      0 likes
                      Last Post NinjaTrader_PaulH  
                      Started by Johnny Santiago, Today, 12:20 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_ChrisL  
                      Started by NinjaTrader_Brandon, Today, 10:24 AM
                      0 responses
                      52 views
                      0 likes
                      Last Post NinjaTrader_Brandon  
                      Started by ptertich, Today, 07:56 AM
                      2 responses
                      15 views
                      0 likes
                      Last Post Johnny Santiago  
                      Working...
                      X