Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot drag and move stop loss order or profit target orders (IB)?

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

    Cannot drag and move stop loss order or profit target orders (IB)?

    Hello,

    I have a strategy that sets a stop loss, a profit target and enters long (IB paper).

    It seems that I cannot manually drag and move the orders after initial entry? When I try to move the "order line" moves but immediately flahses orange just snaps back to the "original values".

    What could be causing this? Thank you.
    Last edited by focus333; 02-02-2021, 02:51 PM.

    #2
    Hello focus333,

    Thank you for your post.

    Are you referring to an ATM Strategy or are you referring to a fully automated NinjaScript strategy?

    Are there any error or rejection messages within the log tab of your Control Center when you attempt to adjust the order?

    Are you able to successfully adjust manually placed orders?

    Are you attempting to adjust the order to another price on the same side of the market?

    I look forward to your reply.
    Zachary S.NinjaTrader Customer Service

    Comment


      #3
      Hi there NinjaTrader_Zachary .

      This is an actual strategy coded in NinjaScript. I don't see errors in the control center but I figured I'd send you the entries for one of the tickers I tried this morning DTEA.

      The sequence of events today (and always) is to turn on the strategy, then place the order (get filled) then attempt to move the stoploss higher as the trade goes in my favor, or attempt to lower the profit target if I feel that it might not get as far as the original profit target order.

      It's almost as if the SL and PT orders get reset to the original orders on price or tick change. Sometimes they will stay in the new desired location for a few seconds but then snap back.

      Please take a look at the attached file containing everything I did for DTEA this morning.

      Thank you kindly for helping with this, really would like to get this very important functionality working

      UPDATE: If I use an ATM strategy I can move the orders (and nor sure if it is relevant but the lines have different colors when using ATM. With ATM they are green and red, with my strategy they are cyan and pink respectively).

      UPDATE 2: I am attaching the strategy here so you can try it. To enter the order, double-click on the chart in the desired stop price (must be below current candle's low). You will see a bracket order get created.

      Last edited by focus333; 02-08-2021, 01:08 AM.

      Comment


        #4
        Hello focus333,

        Thank you for your reply and for providing the strategy.

        We are removing the attached .txt file from your post because it contains personal information. With regard to the strategy, I've tested and was able to reproduce the behavior. It appears that each time the strategy recalculates, the stop loss and profit target levels are adjusted to their original position. Since I am not a Scripting Support team member, I do not have any additional input into why this may be occurring but I am going to have one of our Scripting Support team members take a look and see if they can provide some guidance. Before I do that, I would like to confirm that this is a custom strategy and not one that was purchased from a third party. Is that correct?

        I look forward to your reply.
        Zachary S.NinjaTrader Customer Service

        Comment


          #5
          Hello NinjaTrader_Zachary.

          Thank you for removing the personal data, did not realize it was included.

          Yes this strategy was not purchased, it was coded by myself with bits and pieces I learned from the support forum and examples provided by NinjaTrader customer reps. I also have the NinjaTrader Lifetime in case that is useful information.

          Looking forward to the next update, thank you so much!
          Last edited by focus333; 02-04-2021, 04:30 PM.

          Comment


            #6
            Hello focus333, thanks for your post.

            I am editing the original post here because I had an oversight. The Set methods can not be modified by the chart after a strategy has submitted them, but you can still use the Exit orders and still modify from Chart Trader. Instead of using SetStopLoss and SetProfitTarget to submit the protective orders, use

            ExitLongLimit and ExitLongStopMarket (or StopLimit). Also, make sure to set isLiveUntilCanceled to true so the order stays alive until it is filled or canceled.

            https://ninjatrader.com/support/help...tlonglimit.htm
            https://ninjatrader.com/support/help...stopmarket.htm

            Please let me know if I can assist any further.
            Last edited by NinjaTrader_ChrisL; 02-05-2021, 10:18 AM.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks ChrisL for suggesting the alternative way. I have a question. So, if I use ExitLongStopMarket/ExitShortStopMarket instead of SetStopLoss and ExitLongLimit/ExitShortLimit instead of SetProfitTarget, how would they get linked to the Entry order, since when SetStopLoss and SetProfitTarget are used the are linked as OCO orders, so when anyone of it is filled the other is cancelled.
              Last edited by amul_shail2020; 02-25-2021, 09:39 AM.

              Comment


                #8
                Hello amul_shail2020 thanks for your reply.

                The OCO logic must be handled through the script as well. We have a full example demonstrating how to use the OnOrderUpdate and OnExecution event methods to submit protective orders:

                https://ninjatrader.com/support/help...and_onexec.htm

                Please let me know if you have any questions on this material.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks ChrisL, I looked at the code and it becomes far more complex with the alternate approach (stated in the example )
                  I think NINJATRADER could do better and update their EXIT METHODS with a additional new parameter - OCO = YES/NO so that if the user want to link them as OCO then can do so, while will work similarly to the SetStopLoss and SetProfitTarget and NINJATRADER takes care of everything else behind the scene. Please can I request this to be a feature in the new Ninjatrader development.

                  Comment


                    #10
                    Hello amul_shail2020, thanks for your reply.

                    Yes, I will submit a feature request to our development team for a new OCO parameter.

                    Kind regards.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      //You can use ATM template(e.g. a XYZAtmtemplate) via the AtmStrategyCreate method to control the Stoploss and ProfitTarget. This will allow you to move the stops and targets without problems
                      //Note: SHORTSIGNAL and LONGSIGNAL are condition when you want to entry SHORT or LONG ENTRY. There is need to use PositionAccount.Quantity < 1 so that you always have 1 open position active at one time, otherwise when you are in long position and get a short signal it will fire out a signal for short entry which will cancel you existing long entry.

                      if(SHORTSIGNAL){
                      #region Short Entry Order
                      if(PositionAccount.Quantity < 1){// Restricting it to keep only 1 open position at any one time
                      shortOrderId = GetAtmStrategyUniqueId();
                      shortAtmId = GetAtmStrategyUniqueId();
                      AtmStrategyCreate(OrderAction.SellShort, OrderType.MIT, 0, EntryPrice, TimeInForce.Day, shortOrderId, "XYZAtmtemplate", shortAtmId, (atmCallbackErrorCode, atmCallBackId) => {
                      //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
                      if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == shortAtmId)
                      Print( "SHORT ORDER ENTRY AT - " + EntryPrice + " SUCCESSFULL");
                      });

                      }
                      #endregion
                      }
                      else if(LONGSIGNAL){
                      #region Entry Long Order
                      if(PositionAccount.Quantity < 1){// Restricting it to keep only 1 open position at any one time
                      longOrderId = GetAtmStrategyUniqueId();
                      longAtmId = GetAtmStrategyUniqueId();
                      AtmStrategyCreate(OrderAction.Buy, OrderType.MIT, 0, EntryPrice, TimeInForce.Day, longOrderId, "XYZAtmtemplate", longAtmId, (atmCallbackErrorCode, atmCallBackId) => {
                      //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
                      if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == longAtmId)
                      Print( "LONG ORDER ENTRY AT - " + EntryPrice + " SUCCESSFULL");
                      });

                      }
                      #endregion
                      }

                      Hope the above will help someone who is facing similar problem as myself where I could not move the Stop and profit using setstoploss and setprofittarget methods.
                      Note: The only issue with this approach is that the stoploss and profittarget are defined in the ATMstrategy template instead within the code. I did not find that to be a big problem since I could use multiple ATM templates to get around it.
                      Last edited by amul_shail2020; 03-01-2021, 12:29 PM.

                      Comment


                        #12
                        How do you set the profit target and stop loss in an ATM strategy created by your script?

                        Comment


                          #13
                          Hello barbaros,

                          Thank you for your reply.

                          The ATM template you use to create the ATM would define where the stops and targets are placed.



                          Please let us know if we may be of further assistance to you.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_ChrisL View Post
                            Hello amul_shail2020 thanks for your reply.

                            The OCO logic must be handled through the script as well. We have a full example demonstrating how to use the OnOrderUpdate and OnExecution event methods to submit protective orders:

                            https://ninjatrader.com/support/help...and_onexec.htm

                            Please let me know if you have any questions on this material.
                            Hi there, apologize for a post that came 2 years later....but do you have an update on the URL ? The one you posted is dead.

                            Comment


                              #15
                              Hello elirion,

                              I've tested this link and found it to be correct. However, we have had reports of links not functioning correctly on the forums. Our IT is aware of the situation and is investigating.

                              Try copying and pasting the link text below.
                              Code:
                              https://ninjatrader.com/support/helpGuides/nt8/?using_onorderupdate_and_onexec.htm
                              I also wanted to provide a link to some sample code on the forum of placing orders that can be manually modified.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by lorem, Yesterday, 09:18 AM
                              4 responses
                              13 views
                              0 likes
                              Last Post lorem
                              by lorem
                               
                              Started by Spiderbird, Today, 12:15 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Spiderbird  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              12 responses
                              42 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by FrazMann, Today, 11:21 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post FrazMann  
                              Started by geddyisodin, Yesterday, 05:20 AM
                              8 responses
                              52 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X