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

Assigning SetParabolicStop to a variable

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

    Assigning SetParabolicStop to a variable

    I was using a strategy built by the Strategy Builder because I'm not even good enough yet to be considered a beginner programmer. This strategy uses a Parabolic Stop which gave me an error when running during a live trade due to the strategy trying to set a long stop loss above the current market price. I thought I would put an if statement in that would basically check to see if the new parabolic stop is above the current price if I'm in a long position (and below if I'm in a short position). If the new stop value is going to be above then close the position and wait for a new entry signal (same thing with a short).

    Right now I'm having a hard time assigning the value of the parabolic stop to a variable to be able compare it to the current market price. Any suggestions on how to do that?

    I'm also planning on getting through a series of else if statements to test the parabolic stop value with the last else line reading something like else SetParabolicStop(calculationMode.Ticks, XX); which I believe would set it to the same original value that I had applied to my variable for the test. Any problem doing it this way?

    #2
    Maybe I'm going about this all wrong. What I want to do is close my position of an order gets rejected but not the strategy. I want the strategy to keep working and enter any new points that fill my requirements. What would be the best way to do that?

    Comment


      #3
      Hello GMiller64,

      Thanks for your post.

      In the strategy builder you would not be able to assign the SetParabolicStop value to a variable.

      I suspect that the reason for the rejected order being placed incorrectly would be due to using the calculate mode of Calculate.OnBarClose. In order to use the SetParabolicStop() (or the SetTrailingStop()) methods, you would need the strategy to use the calculate mode of Calculate.OnPriceChange or Calculate.OnEachTick.

      From the help guide on the SetParabolicStop(): "Parabolic stop orders are modified based on the strategies 'Calculate' settings. In the case of 'Calculate' on bar close, when the bar closes the parabolic stop order modification will occur using the closing price of the bar as the reference price to apply the trail offset. Subsequently if the open price of the next bar is significantly higher or lower then the current close price then there is a possibility that the calculated parabolic stop price is now an invalid stop price. This is a risk with modifying any stop order closer to the current market price since any modification above/below the current price would be rejected." Link: https://ninjatrader.com/support/help...abolicstop.htm

      Paul H.NinjaTrader Customer Service

      Comment


        #4
        That makes sense. Thank you, I'll try that.

        Comment


          #5
          I thought about it a while and was thinking if I change to OnPriceChange then as the bar moves so will my parabolic stop potentially stopping me out prematurely. I've had plenty of times where the bar shoots up drifts back down before the close then the next couple of bars continue the trend. With the OnPriceChange I could potentially miss most if not all if those other trend moves. I have to think about that one.

          Comment


            #6
            Hello GMiller64,

            Thanks for your post.

            I would suggest testing using PlayBack>Market replay data. Once you find that situation you described, you can repeatedly test with different parabolic settings or determine that a parabolic stop is not what you need.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jon17, Today, 04:33 PM
            0 responses
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            5 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Started by alifarahani, Today, 09:40 AM
            6 responses
            41 views
            0 likes
            Last Post alifarahani  
            Started by Waxavi, Today, 02:10 AM
            1 response
            20 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Working...
            X