Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

why was this stop order rejected.

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

    why was this stop order rejected.

    i have attached the logs. pl clarify.
    the code that produces the stop order is below.
    Code:
    [FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnExecution(IExecution execution) 
    { 
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//if (entryOrder != null && entryOrder.Token == execution.Order.Token) 
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Print(execution.ToString()); 
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// we have execution. now handle the trades.
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]( (entryorder!= [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ) && (execution.Order.Token == entryorder.Token))
    {
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// make sure that there is a stop 
    [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](exitstoporder != [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])
    {
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// modify the exitstoporder to have the full position value.
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]}
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]{
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (execution.MarketPosition)
    {
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] MarketPosition.Long:
    ExitLongStop(entryorder.AvgFillPrice- ATRValue, SIGNALZLREXIT_STOP, SIGNALZLR_ENTRY);
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] MarketPosition.Short:
    ExitLongStop(entryorder.AvgFillPrice+ ATRValue, SIGNALZLREXIT_STOP, SIGNALZLR_ENTRY);
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]default[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]:
    
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// crap happened.
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]Log([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"It reached OnExecution/switch (execution.MarketPosition) default section "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], NinjaTrader.Cbi.LogLevel.Alert);
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
    }
    
    }
    
    
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// check if we have partial or full fills
    [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]}
    
    [/SIZE][/FONT]
    Attached Files

    #2
    Hi junkone,
    From your code you submit a ExitLongStop order for both longs and shorts...

    Comment


      #3
      even with the typo, this code should have only gone into
      case MarketPosition.Long
      and attempted the
      ExitLongStop(entryorder.AvgFillPrice- ATRValue, IGNALZLREXIT_STOP, SIGNALZLR_

      why did it get rejected

      Comment


        #4
        Do you rebmit your orders at the end of each bar? They may have expired in this case, please see the explanations in this link - http://www.ninjatrader-support.com/H...verview36.html

        Comment


          #5
          ok. i am using the NT simulated trading. when i subscribe to NT, does NT send a cancel of the order at the end of the bar to IB. the order types that i know in IB is good till close or good till cancel. i have not come accross a timed order unless the system is sending a cancel at the end of the bar.

          Comment


            #6
            This is the way NinjaTrader is designed. You can either set your order as live until cancelled or go with the default behavior which would be order expires at the next OnBarUpdate() if not kept alive with a resubmission. The resubmission is just theoretical. It is not cancelling your original and resubmitting. It is just keeping the order alive.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              so, if i use the default behaviour and do not resubmit the order everybar , i will have a live order at the broker which i cannot modify. is that right? just making sure that i understood it properly.

              Comment


                #8
                If you go with the default behavior and you do not resubmit NT will cancel that order. It expired to NinjaTrader therefore it gets cancelled out at your brokerage too. If you want the order to persist you need to resubmit in NinjaTrader which essentially just tells NinjaTrader not to cancel the live order. Otherwise it will.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X