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

Multiple SL errors

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

    Multiple SL errors

    Hello support team.
    I have faced a weird issue with error about stop loss above/below the market. The error itself is not problem for me. Let's consider it step by step. The strategy (ES, 987 ticks) implements the following scenario:
    1. The position is flat. Stop loss is placed for 40 ticks. Let's call it "original" SL.
    2. The strategy get short signal and places entry order with entry price 4300.75 (3 contracts) (stop price = 4300.75 + 40 * 0.25 = 4310.75)
    3. The strategy get target profit 1 signal by indicators and places exit order with exit price 4300.00 (2 contracts)
    4. The strategy places breakeven for the rest 1 contract as stop loss: SetStopLoss(CalculationMode.Price, 4300.75). This way "original" SL is changed.
    5. Error occurs "Sim_v4_es_987, Stop price can't be changed below the market. affected Order: BuyToCover 1 StopMarket @ 4310.75".
    I understand, the stop price is too close to the entry price. I guess the price movement possibly was so fast that stop price got below the market. It is clear to me. The unclear thing is why I see that error window for hundreds times? I guess it is displayed at each tick until the current bar is closed. The number of ticks is 987. My trading environment was heavy loaded. There is no any loop in the strategy logic because breakeven was placed in OnOrderUpdate method once TP1 has been filled. I think the loop was somewhere inside NT8 logic... Also it is unclear to me why there is 4310.75 value in the text of error and not 4300.75?

    Here is log imported from NT8 as excel file in the attachmrnt. You can check weird behaviour of error message from November 2, 3:52pm. Is it possible to be explained and what will be your suggestions? Thank you.
    Attached Files

    #2
    Hello PopovDS,

    For a buy stop ensure the price chosen is greater than GetCurrentAsk() at the time of submission, for a sell stop ensure the stop price is less than GetCurrentBid().

    https://forum.ninjatrader.com/forum/...ed#post1199001

    You've not posted the code that submits the order, so we wouldn't be able to provide any guidance..

    With Set methods, these update on every tick. (Which is why if you manually change the order price it will revert right back to the code set price)

    Use exit methods with IsLiveUntilCancelled as true if you only want these submitted once.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB. Thank you for your response. Yes, I know that approach with checking of bid/ask. But in rare occasions when price movement is unpredictable and very-very fast it may not work, correct? The main problem that I want to point to is hundreds of error windows. I would like to avoid it in future.

      Comment


        #4
        Hello PopovDS,

        It could still be rejected in a really fast moving market, but generally as long as it's at least one tick above the ask or below the bid it should be ok.

        Use Exit methods instead of Set methods to avoid the hundreds of error windows.

        See the 'ProfitChaseStopTrailExitOrdersExample' example linked below.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Your suggestion "Use exit methods with IsLiveUntilCancelled as true if you only want these submitted once."... Do you mean usage of ExitLongLimit and ExitShortLimit methods instead of SetStopLoss one?

          Comment


            #6
            Hello PopovDS,

            Yes, this is what I am referring to. (Though for a stop loss it would be ExitLongStopMarket()/ExitShortStopMarket())
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Balage0922, Today, 07:38 AM
            0 responses
            5 views
            0 likes
            Last Post Balage0922  
            Started by JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            19 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            6 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Working...
            X