• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trailing stops in umanaged framework

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

    trailing stops in umanaged framework

    Hello. I'm working in unmanaged framework where I have multiple trades on the same instrument, for which each has it's own stop/ profit target. I've got it working so I can put in static stops/ targets associated with each trade, but I'm having trouble figuring out how I might set up trailing stops for each of those. Essentially, I might have 6 separate stops out, and the price of each would need to be updated (by same amount) following every bar update. Have you guys encountered any examples of this? I could imagine just cycling through all the stops and making the adjustment, but some might have already been filled, etc

    Thanks

    #2
    Hello stewarco,

    Thank you for your note.

    I put together a sample for the unmanaged approach which will submit a buy order, then a stop which is assigned to an order object and that order object is added to a list of type Order. Then on each bar update, this list is looped to check that the order is a stop market order and above the price which would trigger a change order call for that stop.

    With your additional stop orders, you’d just add them to this list and have each changed as needed.

    Please see attached.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      thanks this is helpful

      Comment


        #4
        possibly relate question

        Hi. This methodology works great. However, I'm having a new problem which may or may not be related. When I try to run a playback simulation, I'm getting the error about "Strategy has been disabled because it attempted to modify a historical order that has transitioned to a live order." I currently have the standard language:

        else if (State == State.Realtime)
        {
        // one time only, as we transition from historical
        // convert any old historical order object references
        // to the new live order submitted to the real-time account
        if (entryOrder != null)
        entryOrder = GetRealtimeOrder(entryOrder);
        if (stopOrder != null)
        stopOrder = GetRealtimeOrder(stopOrder);
        if (targetOrder != null)
        targetOrder = GetRealtimeOrder(targetOrder);
        }

        However, each stopOrder is going into stopList for updating the trailing levels. So do I need to update the code above to cycle through the entire list of outstanding stops? Or is the issue completely unrelated?
        Thanks

        Comment


          #5
          Hello stewarco,

          The sample I provided only should run in real time so this looks unrelated.

          For the issue with attempting to modify a historical order that has transitioned to a live order, please see the following link discussing how to resolve this.
          https://ninjatrader.com/support/help...storicaltolive

          Please let us know if you need further assistance.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            follow up

            Hey Alan. I reviewed the section you provided, and included language as referenced below but I'm still having that issue. I guess I'm not entirely clear on the historical to realtime transition, but are you saying if I have multiple stop and target orders outstanding when I transition to realtime they'd still be picked up by

            else if (State == State.Realtime)
            {
            // one time only, as we transition from historical
            // convert any old historical order object references
            // to the new live order submitted to the real-time account
            if (entryOrder != null)
            entryOrder = GetRealtimeOrder(entryOrder);
            if (stopOrder != null)
            stopOrder = GetRealtimeOrder(stopOrder);
            if (targetOrder != null)
            targetOrder = GetRealtimeOrder(targetOrder);
            }

            Thanks

            Comment


              #7
              Hello stewarco,

              I would expect that code to have issues with multiple stops and profit targets.

              Have you attempted to assign each target and stop its own unique order object?

              I look forward to your reply.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                hi

                Hey alan. Any chance you or somebody can give me a call and I can try to walk you through what I have so far?

                Comment


                  #9
                  Hello stewarco,

                  Could you please send an email to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread.

                  I look forward to your email.
                  Alan P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Bouzayen, Yesterday, 08:31 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post Bouzayen  
                  Started by IanC28, 03-27-2020, 10:20 AM
                  6 responses
                  30 views
                  0 likes
                  Last Post jim1234
                  by jim1234
                   
                  Started by aramtrader, 04-01-2020, 03:05 PM
                  7 responses
                  40 views
                  0 likes
                  Last Post woodie1
                  by woodie1
                   
                  Started by renehtx, Yesterday, 03:51 PM
                  2 responses
                  16 views
                  0 likes
                  Last Post renehtx
                  by renehtx
                   
                  Started by eidog2020, Yesterday, 03:31 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post eidog2020  
                  Working...
                  X