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

SetStopLoss rejected

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

    SetStopLoss rejected

    I have seen some forum posts on this issue.
    My case is not very different.
    In Live market as well as in Playback mode I get the error on exit with SetStopLoss.
    the order is rejected.... buystop or buystoplimit can't be placed bellow the market.

    my setstoploss are placed inside the OnBarUpdate

    without bothering you too much..
    what would be the best approach to handle this ?

    RealtimeErrorHandling ? and if the stop loss is filled then cancel all orders and go flat ?


    thanks

    #2
    Hello dadarara,

    Thanks for your post and welcome to the forums!

    The SetStopLoss() method will retain the last value it was set to. If in your code sequence you are placing the entry order first then the setting the stop level please note that the prior stop level would be used when the entry is made thus likely causing the rejection.

    If you are using the entry price to set your stoploss then you may want to use a 2 step process where you establish a "'default" stop, for example set the stop as in SetStopLoss(CalculationMode.Ticks, 10) so that upon entry you have a 10 tick stop loss, then after entry you can use Position.AveragePrice to then set a stop you prefer. You can mix CalculationModes in the strategy.

    References:

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul

      actually thats what I am doing. setting the initial setstoploss somewhere bellow.
      then checking that we moved far enough away and setting stop loss again on breakeven.
      what happens is when the prices drops lower and gets to the stop level, I get the above errors. the price drops hard bellow the stop .

      Comment


        #4
        Hello dadarara,

        Thanks for your post.

        Can you post your code or a segment of your code that would demonstrate the issue?

        Alternatively, if you prefer, feel free to send your code into PlatformSupport[at]NinjaTrader[dot]Com, mark the e-mail Atten:Paul and include a link to this thread. The source file can be found in Documents>NinjaTrader8>bin>Custom>Strategy>
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          done
          I sent the email
          any suggestions about any of the code I did are welcome
          I am not a very good coder and I am just started a few weeks ago.
          Last edited by dadarara; 07-18-2017, 08:33 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by maybeimnotrader, Yesterday, 05:46 PM
          2 responses
          20 views
          0 likes
          Last Post maybeimnotrader  
          Started by adeelshahzad, Today, 03:54 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          7 responses
          32 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by merzo, 06-25-2023, 02:19 AM
          10 responses
          823 views
          1 like
          Last Post NinjaTrader_ChristopherJ  
          Started by frankthearm, Today, 09:08 AM
          5 responses
          22 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X