Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator to modify trailing stop of order opened by the UI

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

    Indicator to modify trailing stop of order opened by the UI

    Hi all,

    I am new to NT8 but experienced in C#. I want to have an indicator that will do the following:

    provided I open an order via the UI, it will calculate a distance for a stop loss order, and it will place the stop order.

    Then on each bar it will recalculate and if needed, it will trail if needed

    I managed to get this working by creating the order but it is not able to update it when the trailing price changes, using this code:

    stopOrder.StopPrice = currentStopPrice;
    account.Change(new List<Order> { stopOrder });​

    stopOrder is the one that was created earlier with account.CreateOrder(), stored in a field in the indicator class,

    The only way I managed to do it was by deleting the order and creating it again every time I want to change it.

    My questions to you more experienced guys:

    1. is the indicator supposed to be able to modify such a stop order (instead of recreating it each time) and if yes how?
    2. if not, assuming I stay with the working version (indicator that recreates the stop order), would that be fawned upon by the NT broker or prop firms for submitting too many orders (if we work let's say on a fast timeframe chart and there are several modifications per minute)?

    Any other ideas?

    Thanks

    #2
    Hello challenger78,

    A stop loss order specifically that is opened from the UI would be from an Atm strategy.

    Any modifications to an order with Account.Change() would be overridden by the Atm which would put it back at the price it is calculating.

    You would need to submit a stop order manually (or through a script) without an Atm strategy, and then you can modify the order with Account.Change().
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello challenger78,

      A stop loss order specifically that is opened from the UI would be from an Atm strategy.
      thanks for the reply.

      When I submit the order via the chart trader, the ATM Strategy dropdown says "None" so why does an ATM still manages the order? and is there any way to remove the ATM from the order programmatically?

      Click image for larger version  Name:	image.png Views:	0 Size:	2.0 KB ID:	1341983

      Also, this kind of information should be in the documentation of Change that you linked above
      Last edited by challenger78; 05-02-2025, 01:13 AM.

      Comment


        #4
        Hello challenger78,

        "When I submit the order via the chart trader, the ATM Strategy dropdown says "None" so why does an ATM still manages the order? and is there any way to remove the ATM from the order programmatically?"

        With None selected, there would not be an Atm strategy applied to the entry and no stop loss order would be submitted by the platform.

        So there wouldn't be any stop order to change.


        "lso, this kind of information should be in the documentation of Change that you linked above"

        Account.Change() is documented and I did provide a link.

        Can you clarify what is not documented?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello challenger78,
          Account.Change() is documented and I did provide a link.

          Can you clarify what is not documented?
          Hi, thanks for the reply again. And thanks for providing the link. The part that is not documented is that it cannot change all types of orders but only specific ones. The documentation states:

          Change()
          Definition
          Changes specified Order object(s).​

          This implies that the function should be able to change all types of orders, it does not make any distinction about types of orders or that it will change an order and then the system magically will change it back in a millisecond. If there are orders that this function is not able to change, it should be clearly stated there, along with alternatives solution about how said orders can be changed. If this documentation applies only to specific types of orders, it should be stated very clearly. This documentation therefore seems incomplete. Because of this, me and I am sure others have spend and will spend a lot of time, before they arrive to this forum and ask for an explanation that a kind person like yourself will provide, eventually.

          Does this make sense?

          Also I am now confused. Originally I asked why the order can't be managed by Change() function, you said because there was ATM strategy. Your second answer says because it is submitted without an ATM strategy there won't be any stop to change. This is true at the moment we submit the order. So far so good.

          However, according to my first post here, the indicator attaches a stop order, so at that moment there is a stop order attached. And then it tries to change it. So why does the system change it back? and most importantly, they key question is, how can we alter our order without the system interfering with it?

          I do appreciate the time you take to answer, yet the actual SDK is extremely annoying in that respect and it's not your fault, just it doesn't make any sense whatsoever. I've worked with many different platforms and trading SDKs in the past, this is the first time I see something so confusing and not working, and I am actually shocked because I regard NT as one of the most mature and well developed platforms out there.. really disappointing. I've already spend about a week for a task that should have been literally 10 minutes... and it's still not working and no answer to the issue at hand...

          The simple question is: UI submits order without stops, indicator attaches a stop, and then subsequently it wants to modify said stop, how to do this simple thing? Oh and I've already tried doing it via Strategy but that was yet another big fail as apparently strategy cannot change UI submitted orders (very weird and totally unhelpful but yes, that's a totally different subject) - the point is if we can't do it via a Strategy and we can't do it via an Indicator, then how can we do it? and where is this documented in an example with the function? and if we can't do it at all, what kind of programmable platform is this? and why we can delete/add but not change?

          Sorry about all these questions but this is an extremely frustrating experience so far and totally unexpected.

          Thanks anyway
          Last edited by challenger78; 05-04-2025, 06:14 AM.

          Comment


            #6
            Hello challenger78,

            Account.Change() can change any order order type, however market orders in general fill immediately or are rejected and typically don't have time to be modified, nor do they have stop or limit price to change.

            As far as the system changing the price back, this occurs if you are using Atm strategies or Set methods, as the orders are continuously updated which will supersede any changes made. This is not quite related to Account.Change() which will change the order, but if something else also changes the order after then that would take precedence.

            "provided I open an order via the UI, it will calculate a distance for a stop loss order, and it will place the stop order."

            If it's an stop order sent automatically by the UI this would have to be an Atm. You haven't confirmed this, but this would be the only way a stop order would be sent automatically from an entry submitted through the UI.

            "When I submit the order via the chart trader, the ATM Strategy dropdown says "None" so why does an ATM still manages the order?"

            If you are selecting None in the Atm drop-down then there is no stop order being sent automatically as there is no Atm and your first post isn't making any sense.


            "However, according to my first post here, the indicator attaches a stop order"

            I didn't address that you want an indicator to submit an order, my apologies.

            You would need to detect the entry has filled from the Account.OrderUpdate or Account.ExecutionUpdate event. Then create an order with Account.CreateOrder() and submit the order with Account.Submit().
            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


            The ProfitCaseStopTrailIndicatorExample has some sample of this. If you want to manually modify the orders, your script would need to submit the stop once and never modify it or any manual changes will be superseded by the script.


            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X