Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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...
    BertrandNinjaTrader Customer Service

    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
        BertrandNinjaTrader Customer Service

        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 popecapllc, 08-09-2023, 07:42 PM
                8 responses
                1,343 views
                0 likes
                Last Post Johng22
                by Johng22
                 
                Started by ETFVoyageur, 04-30-2024, 02:04 PM
                11 responses
                100 views
                0 likes
                Last Post ETFVoyageur  
                Started by bubblegum, 03-18-2024, 10:41 AM
                3 responses
                44 views
                0 likes
                Last Post vjsworld  
                Started by JamesK1, Today, 02:48 PM
                1 response
                13 views
                0 likes
                Last Post JamesK1
                by JamesK1
                 
                Started by llanqui, Today, 03:51 PM
                0 responses
                11 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Working...
                X