Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

ParabolicSAR return value

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

    ParabolicSAR return value

    I'm trying to use ParabolicSAR for the stop trailing:

    SetStopLoss(CalculationMode.Price, ParabolicSAR(0.02, 0.2, 0.02)[0]);

    Looks like the returned value of ParabolicSAR(0.02, 0.2, 0.02)[0] is for the green dot where I got stopped out, instead of for the orange one, see attached for details. I confirmed that in the output window.

    How can I get the ParabolicSAR orange dot value?

    Thanks in advance,
    Gary
    Attached Files

    #2
    Hi Gary,

    You'll have to specify the plot you want in the code, or else it uses the default plot. For help with getting syntax for multi plot indicators, see the following link then > How to compare plot values of multi-plot indicators
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks much for your quick response, Ryan.

      I still have no ideal how to do it in the code. ParabolicSAR looks not a multi-plot indicator to me. Please advice.

      What I'm using now is:

      SetStopLoss(CalculationMode.Price, ParabolicSAR(0.02, 0.2, 0.02)[0]);

      Is there any new parameter for the function ParabolicSAR(0.02, 0.2, 0.02)[0], which I can use to get the orange dot value?

      Thanks,
      Gary
      Last edited by gjing; 02-28-2011, 06:46 PM.

      Comment


        #4
        Thanks for the reply Gary. Correct - The ParabolicSar built into NinjaTrader has only one plot, so your syntax is correct for that.

        To help track down what's happening, add a print statement so you can check the value submitting with the stop loss.

        Print(ParabolicSAR(0.02, 0.2, 0.02)[0]);

        View this in tools > output window.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          I've already tried it and found the returned value was for the green dot, not orange one. I'm even not sure where the green one coming from. Looks like when the trade gets finished, NT adds it automatically (green one for win, red for loss). Any ideals?

          Thanks,
          Gary

          Comment


            #6
            Yes exactly. The green dotted line is not connected to ParabolicSar. It indicates this particular trade is a win. The green line is not a value at all - It just connected the entry and exit points.

            ParabolicSar can whipsaw back and forth in real time, so it may not be a suitable value for a stop loss.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your help, Ryan. Looks like it's a bug. Hope you can fix in the next release. ParabolicSAR(0.02, 0.2, 0.02)[0] returns wrong value.

              Meanwhile, has anyone ever tried to use ParabolicSAR for trailing stop? How did you do that? I really like the indicator for the stop trailing.

              Appreciate for any inputs,
              Gary

              Comment


                #8
                Hi Gary,

                Can you please clarify where the bug is? What value do you expect, what are you seeing instead?

                This parabolic sar indicator alternates from values above highs to below lows. If you base a stop loss on it and it switches direction, then your stop loss is likely to be rejected.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Ryan,

                  The returned value of ParabolicSAR(0.02, 0.2, 0.02)[0] is for the green dot added by NT when the trade finished. As you mentioned early, the green dot line has nothing to do with ParabolicSAR. It can be added by any other stop methods.

                  What I expect is that the returned value should be for the orange dot. Please check the attached screenshot for details.

                  I confirmed that by using:

                  Print(ParabolicSAR(0.02, 0.2, 0.02)[0]);

                  Thanks,
                  Gary

                  Comment


                    #10
                    The green line is not a value. It connects two points. The value of ParabolicSar can change in real time as the bar is forming, so there is nothing in the screenshot to suggest there is a bug there.

                    I suggest you play around with ParabolicSar, using the simulated data feed with CalculateOnBarClose = false so you can see this effect. Use the trend slider for this. If the value of the indicator is above the high, trend market up and then watch it switch to below the bar. I attached a couple screenshots to help illustrate.
                    Attached Files
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Ryan,

                      To make things simple, lets' forget the green dot line first.

                      If I use ParabolicSAR(0.02, 0.2, 0.02) in the code, I should get the returned value of ORANGE dot, right? So now my question is that how to get that in the code?

                      I've confirmed that ParabolicSAR(0.02, 0.2, 0.02) is not returning the right one by using:

                      Print(ParabolicSAR(0.02, 0.2, 0.02)[0]);

                      Looks like the returned value was for the green dot to me. I thought it's a bug.

                      Not sure if I state the issue clearly.

                      Thanks,
                      Gary

                      Comment


                        #12
                        I was not able to reproduce this. Programatic access always matched indicator plot values here.

                        Print(Time[0] +" " + ParabolicSAR(0.02, 0.2, 0.02)[0]);
                        Attached Files
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks Ryan. I'll test later on my machine and let you know the result.

                          Comment


                            #14
                            Hi Ryan,

                            I found the problem in my code finally. Because my strategy is for multi time frame, so I have to use BarsArray to get what I want, like this:

                            ParabolicSAR(BarsArray[0], 0.02, 0.2, 0.02)[0]

                            Anyway, thank much for your help,
                            Gary

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bmartz, Today, 09:30 AM
                            2 responses
                            11 views
                            0 likes
                            Last Post bltdavid  
                            Started by f.saeidi, Today, 11:02 AM
                            1 response
                            3 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by geotrades1, Today, 10:02 AM
                            4 responses
                            12 views
                            0 likes
                            Last Post geotrades1  
                            Started by rajendrasubedi2023, Today, 09:50 AM
                            3 responses
                            16 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by lorem, Today, 09:18 AM
                            2 responses
                            11 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Working...
                            X