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

SetProfitTarget and SetStopLoss for Unmanaged Approach

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

    SetProfitTarget and SetStopLoss for Unmanaged Approach

    Hi,

    the SetProfitTarget and SetStopLoss are defined to be used only for Managed Approach.

    I would like to use them also for Unmanaged Approach. There is a way to replicate them with SubmitOrderUnmanaged?

    I tried in this way for SetStopLoss (in case a but order has been filled) but it doesn't really work the same:

    SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, Quantity, LimitPrice, 0, "", "Stop Loss");

    Thanks & Regards.

    #2
    Hello Peppo,

    Yes, you would need to use SubmitOrderUnmanaged() in an unmanged strategy to send the stop market order for the stop loss and limit order for the profit target.
    These should be submitted from OnExecutionUpdate() when the entry order fills.

    Below is a link to an example named ProfitChaseStopTrailUnmanagedExample. (You don't have to implement the logic for updating the stop and limit prices in OnBarUpdate())
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      Thank you for your answer.
      Your point is quite clear but the behavior of SetStopLoss and SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, Quantity, 0, StopPrice, "", "Stop Loss"); looks a bit different.
      I have tested both. With SetStopLoss I can set whatever price below the open position price (even the stop price directly at the open position just as a try) and the order is never rejected while with SubmitOrderUnamanaged() I get the error that the orders are sometimes rejected due to "invalid price range...". The problem is that sell stop orders must be placed always below the current bid price. So, to avoid the rejection, I place a check respect to the current bid price and then I adjust the stop price consequently.
      My question now is why I have to do this check with SubmitOrderUnmanaged() and not with SetStopLoss?
      Thank you.

      Comment


        #4
        Hello Peppo,

        "So, to avoid the rejection, I place a check respect to the current bid price and then I adjust the stop price consequently.
        My question now is why I have to do this check with SubmitOrderUnmanaged() and not with SetStopLoss?​"

        Calling SetStopLoss() with CalculationMode.Price with an invalid price WILL result in a rejected order.

        Always ensure the order stop price is a valid price for any order method (including SetStopLoss(), ExitLongStopMarket()/ExitShortStopMarket(), and SubmitOrderUnmanaged).
        Hi I have a sellshort StopLimit order that i change if unfilled. I tick below the last bar's low. I keep getting the stop price can't be changed above the market but the price value it quotes ( the one I want) is below the market. Currently I am on the simulated feed. I appreciate in real market situations this could happen

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,
          I think I understood where the problem lies.
          SetStopLoss and SetProfitTarget are immediately active when they are placed allowing also intrabar fills in case the stop or profit are reached.
          SubmitOrderUnmanaged() starts to be valid from the next bar. So, since it is placed in the current bar, the check it is done with the current bar bid price even if the stop price will be valid in the next bar.
          Why there is this discrepancy? It is not possible to have the same behavior in the Unamanaged approach?
          Thank you.

          Comment


            #6
            Hello Peppo,

            Just to confirm, you are submitting the stop and limit from OnExecutionUpdate() when the entry order fills as directed in post # 2, correct?

            Orders submitted from OnExecutionUpdate() would not be submitted on the next bar. They would be submitted when the entry order fills, even before the bar updates.

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea,

              I am doing a backtest and using OnExecutionUpdate().

              Thanks.

              Comment


                #8
                Hello Peppo,

                In a backtest the orders are still submitted immediately when submitted from OnExecutionUpdate().

                However, if you have not implemented 1-tick intra-bar granularity entry and exit orders will be filled using end of bar data.
                This forum post discusses.


                Set methods also will fill with end of bar data, but cannot implement 1-tick intra-bar granularity. They can be used with High Order Fill Resolution, but not at the same time as TickReplay.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by TAJTrades, Today, 09:46 AM
                0 responses
                1 view
                0 likes
                Last Post TAJTrades  
                Started by rhyminkevin, Yesterday, 04:58 PM
                5 responses
                62 views
                0 likes
                Last Post dp8282
                by dp8282
                 
                Started by realblubb, Today, 09:28 AM
                0 responses
                4 views
                0 likes
                Last Post realblubb  
                Started by AaronKoRn, Yesterday, 09:49 PM
                1 response
                18 views
                0 likes
                Last Post Rikazkhan007  
                Started by ageeholdings, Today, 07:43 AM
                0 responses
                12 views
                0 likes
                Last Post ageeholdings  
                Working...
                X