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

OCO errors and shutdown

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

    OCO errors and shutdown

    from searching the forums, this has been happening to a lot of NT users and it seems like the solution is to code in an unique OCO ID. However, for those of us who are beginner coders and don't want to use the unmanaged approach, how can this problem be solved? My strategy places initial SetStoploss and SetProfitTargets but I also have two conditions where it will call a SetStoploss to a new price when the conditions are met in the future. The profit targets don't change.

    2 SetProfitTarget (1 for long entry, 1 for short entry)
    6 losses (3 longs, 3 shorts with a setstop placed immediately after entry and 2 others if 2 conditions meet, 1 breakeven, 1 to take some profit )

    I don't want to use the unmanaged approach as I am not an advanced coder and currently I don't think I can manage all the intricacies of custom order handling. So what is a solution to this problem? All the entires are tagged Long or Short and each setstoploss and profit target are attached to the corresponding longs/shorts

    I also noticed that in the strategy builder, you can use set methods for profit target and stoplosses. Do these errors and shutdowns not happen when you just have one setprofit and one setstop? Is it because I have additional setstoploss in addition to the initial one?

    #2
    Originally posted by Boonfly8 View Post
    from searching the forums, this has been happening to a lot of NT users and it seems like the solution is to code in an unique OCO ID. However, for those of us who are beginner coders and don't want to use the unmanaged approach, how can this problem be solved? My strategy places initial SetStoploss and SetProfitTargets but I also have two conditions where it will call a SetStoploss to a new price when the conditions are met in the future. The profit targets don't change.

    2 SetProfitTarget (1 for long entry, 1 for short entry)
    6 losses (3 longs, 3 shorts with a setstop placed immediately after entry and 2 others if 2 conditions meet, 1 breakeven, 1 to take some profit )

    I don't want to use the unmanaged approach as I am not an advanced coder and currently I don't think I can manage all the intricacies of custom order handling. So what is a solution to this problem? All the entires are tagged Long or Short and each setstoploss and profit target are attached to the corresponding longs/shorts

    I also noticed that in the strategy builder, you can use set methods for profit target and stoplosses. Do these errors and shutdowns not happen when you just have one setprofit and one setstop? Is it because I have additional setstoploss in addition to the initial one?
    You need to ensure your stop loss change conditions are mutually exclusive from a logical perspective. It sounds like your strategy is trying to set two stops at once.

    Comment


      #3
      hi Liquid,

      They are set one at a time. The code has initial SetStopLoss and SetProfitTarget. However, as the market moves in the trade's favor, new stops are placed at breakeven, and at some profit. These conditions are sequential and are at different prices each time as the market moves.

      Comment


        #4
        What I am saying is: "are you SURE all logically possible possibilities are accounted for in your logic?"


        I have code which does this, and the danger of sequential operations is when the market does something you didn't account for, calling on two commands at once. I can't tell what the problem is since I don't know what your code is.

        Comment


          #5
          Hello Boonfly8,

          Thanks for your post.

          SetProfitTarget and SetStopLoss are bound by OCO. These methods also control the entire position tied by the fromEntrySignal string and cannot have quantity split from one entry method.

          If you would like to split multiple stops and targets, you will have to have separate Entry methods to open separate positions and have stop/target pairs for each position.

          I have attached a demonstration showing how this can be done, and I have included publicly available documentation on SetProfiotTarget and SetStopLoss so you may reference the documented notes and tips.

          SetProfitTarget - https://ninjatrader.com/support/help...ofittarget.htm

          SetStopLoss - https://ninjatrader.com/support/help...etstoploss.htm

          Please let us know if we can be of further assistance.
          Attached Files
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by f.saeidi, Today, 10:19 AM
          0 responses
          2 views
          0 likes
          Last Post f.saeidi  
          Started by kujista, Today, 06:23 AM
          4 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by traderqz, Yesterday, 09:06 AM
          2 responses
          16 views
          0 likes
          Last Post traderqz  
          Started by traderqz, Today, 12:06 AM
          3 responses
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by RideMe, 04-07-2024, 04:54 PM
          5 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X