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

Cancel Order in managed approach

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

    Cancel Order in managed approach

    Hello

    I have an strategy calculate OnBarClose and order entries with bool isLiveUntilCancelled true.

    I have these lines in OnBarUpdateSection to cancel them if prices goes up or go down a distance before execution (variables myEntryShortCancelPrice and myEntryLongCancelPrice.

    if (entryShortOrder != null
    && (Low[0] < myEntryShortCancelPrice))
    {
    CancelOrder(entryShortOrder);
    }

    if (entryLongOrder != null
    && (High[0] < myEntryLongCancelPrice))
    {
    CancelOrder(entryShortOrder);
    }

    There are lot of entries that are ordered and cancelled in the same moment. I guess the reason is that Highs or Lows of entry conditions bars are above or below my variables level to cancel, but that is previous than my order...

    Have you got any idea or example to solve that issue? Maybe adding something to "entryLongOrder != null" or "entryShortOrder != null"?

    Thanks in advanced

    #2
    Hello Impeesa,

    Thank you for the post.

    You mentioned that this may be because of the order previous to the current, are you setting the order variables to null when you cancel or see the order filled?

    For the condition you are using to work it would need to have entryLongOrder null to avoid canceling the order. If that was not null from a previous order then it could be true right away. This condition could still become true basically right away if the cancel price is less than the current high right after the entryLongOrder is assigned to the order. This depends on how frequent this logic is called from OnBarUpdate as well.

    If you are trying to avoid cancelling an order on the same bar you could add other logic like checking the BarsSinceEntryExecution or adding a variable to store the CurrentBar for comparisons.





    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Stanfillirenfro, Today, 07:23 AM
    9 responses
    23 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by George21, Today, 10:07 AM
    0 responses
    8 views
    0 likes
    Last Post George21  
    Started by DayTradingDEMON, Today, 09:28 AM
    3 responses
    19 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by navyguy06, Today, 09:28 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    8 responses
    32 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X