Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

execution issue

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

    execution issue

    Hello,

    I have in onexecution with entries for first position
    avgFillkSa = execution.Order.AvgFillPrice;

    and then I have
    if(execution.Name=="Profit target" && execution.Order.FromEntrySignal=="kSa")
    {SetStopLoss("kSb", CalculationMode.Price, avgFillkSa + 2*TickSize, false); }

    But stop for kSb doesnt move with fill of target kSa



    Thank you!
    Tony

    #2
    Originally posted by tonynt View Post
    Hello,

    I have in onexecution with entries for first position
    avgFillkSa = execution.Order.AvgFillPrice;

    and then I have
    if(execution.Name=="Profit target" && execution.Order.FromEntrySignal=="kSa")
    {SetStopLoss("kSb", CalculationMode.Price, avgFillkSa + 2*TickSize, false); }

    But stop for kSb doesnt move with fill of target kSa

    Why would it move? I mean, once set, it's not supposed to move, is it?

    Comment


      #3
      Hello tonynt, and thank you for your query.

      According to the documentation for SetStopLoss,

      You will need to move this method to OnBarUpdate . You will need to use class members to pass information from OnExecution to OnBarUpdate.

      Please let us know if there are any other ways we may help.
      Jessica P.NinjaTrader Customer Service

      Comment


        #4
        Jessica, bltdavid,

        because it worked this way for SetStopLoss, as it also works for Iorders with if(execution.Name=="xkSa" && execution.Order.FromEntrySignal=="kSa").
        (in onExecution of course)

        So, I´m wondering only why suddenly it does not work and what might be the reason.

        bltdavid, attached is a sample from NT-support.

        Thanks for your reply!
        Attached Files
        Last edited by tonynt; 11-04-2016, 08:39 AM. Reason: clearifying

        Comment


          #5
          Thank you for providing this additional information and sample. Could you attempt to move SetStopLoss to OnBarUpdate and let us know if you do not see the desired results?
          Jessica P.NinjaTrader Customer Service

          Comment


            #6
            Hello Jessica,

            thank you for your reply. I know it is working in onbarupdate. But I want to have it moved immediately with execution of 1st target (and not onbarupdate with COBCtrue).I´m curious why it doesn´t work all the sudden when I have it for months in my scripts for futures and also my scripts for forex. I tried to find out what might be the reason.

            Idea: in my forex scripts I dont have SetStopLoss in Initialize. This I have in the futures scripts (for no special idea). Might this be the reason, or is it from Initialize only set to the value there when flat or script enabled? (if so, then this is not the reason for)

            Thank you!
            Tony
            Last edited by tonynt; 11-04-2016, 08:54 AM. Reason: clearifying

            Comment


              #7
              While I would be interested in the results of your personal investigations, especially if you discover why your strategy was able to update from there before, the documentation states that SetStopLoss must be in OnBarUpdate in order to update SetStopLoss. As such, that is the scope of the support I may provide.

              I am attaching a modified version of your strategy in which the information you are switching on is passed to OnBarUpdate. Please let us know if there are any other ways we may help.
              Attached Files
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Hello Jessica,

                thank you for providing this modified sample. Please notice that the sample I sent was from your collegue who posted this with a reply to a question from me months ago. Since then I know how it works and I used it. With my humble knowledge I will not find out why it did not work. I only copy and pasted what I got and changed it to the order names I have.

                A question please to your modified sample: will the stop be moved immediately when bool is true or only when bool is true and with close of bar? If only with close of bar, then I should put in onorderupdate.

                Thank you for your support!
                Tony
                Last edited by tonynt; 11-04-2016, 09:20 AM. Reason: translation error

                Comment


                  #9
                  If you would like this to execute at the earliest possible moment after the bool is set, you may use a multi time frame strategy. Tips on creating these are here, http://ninjatrader.com/support/helpG...nstruments.htm . We are happy to help with any questions that come up.
                  Jessica P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello Jessica,

                    thank you for your reply. Yes, this would be the next step. But if it would continue to work in onexecution I dont need to do so.

                    Tony
                    Last edited by tonynt; 11-09-2016, 07:44 AM.

                    Comment


                      #11
                      Thank you for this information. I look forward to assisting in your development process by answering any questions about the documented operation of NinjaTrader that I can.
                      Jessica P.NinjaTrader Customer Service

                      Comment


                        #12
                        An additional question in this concern please:

                        if(execution.Name=="Profit target" && execution.Order.FromEntrySignal=="kSa")
                        {SetStopLoss("kSb", CalculationMode.Price, avgFillkSa + 2*TickSize, false); }

                        is this true with Profit target FILLED only or already with ENTRY?
                        (because it occurred now when testing that the stop for the 2nd position "kSb" was moved immediately with entry to the entryprice+2*TickSize)

                        I have an idea about this behavior: as I moved the setstoploss and profittarget from onbarupdate to onexecution (same as in the NT-"SampleOnOrderUpdate" it is shown) might the reason be that onexecution reads now "profit target" even when not filled? If so, I have to ask how is it possible to distinguish between bringing in SetProfitTarget and filled ProfitTarget (in onExecution)?

                        Thank you!
                        Tony
                        Last edited by tonynt; 11-09-2016, 07:59 AM. Reason: solution?

                        Comment


                          #13
                          My solution:

                          first I moved the condition to move stoploss from onexecution to onorderupate. but there occurred the same as the onexecution true means also onorderupdate true, therefore also in onorderupdate the stop is moved with the entry.

                          BUT in onorderupate I can add as condition another tradequantity than the entryquantity to the "if(o.name =profittarget...) and with this it does move the stop now only when profittarget and also the positionqty<entryqty.

                          Best
                          Tony

                          Comment


                            #14
                            As far as getting a little more information out of your orders is concerned, the IOrder documentation gives us a little more information.

                            Originally posted by http://ninjatrader.com/support/helpGuides/nt7/?iorder.htm
                            • OrderAction
                            • AvgFillPrice
                            • Error
                            • Filled
                            • FromEntrySignal
                            • Instrument
                            • LimitPrice
                            • LiveUntilCancelled
                            • Name
                            • NativeError
                            • Oco
                            • OrderId
                            • OrderState
                            • OrderType
                            • OverFill
                            • Quantity
                            • StopPrice
                            • Time
                            • TimeInForce
                            • Token

                            Of these, I believe the Filled and OrderState properties will be of interest to you. With the Print command, you can view most of this information using the order's ToString() method as well.
                            Jessica P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by argusthome, 03-08-2026, 10:06 AM
                            0 responses
                            105 views
                            0 likes
                            Last Post argusthome  
                            Started by NabilKhattabi, 03-06-2026, 11:18 AM
                            0 responses
                            53 views
                            0 likes
                            Last Post NabilKhattabi  
                            Started by Deep42, 03-06-2026, 12:28 AM
                            0 responses
                            35 views
                            0 likes
                            Last Post Deep42
                            by Deep42
                             
                            Started by TheRealMorford, 03-05-2026, 06:15 PM
                            0 responses
                            38 views
                            0 likes
                            Last Post TheRealMorford  
                            Started by Mindset, 02-28-2026, 06:16 AM
                            0 responses
                            74 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Working...
                            X