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

Using some order commands at one OnBarUpdate

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

    Using some order commands at one OnBarUpdate

    Hello,

    here is the situation.
    I have opened positon. Then at one moment in OnBarUpdate i decide to change the position to opposite. I close my position with ExitLong or ExitShort and immediately send EnterShortLimit or EnterLongLimit, and then receive usual "An Enter() method to submit an entry order at '11/05/2017 03:48:54' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation."

    The log:

    Code:
    Historical 11/05/2017 03:48:54      We're are in long position right now. Exiting it...
    Historical 11/05/2017 03:48:54    Order updated: Type=Market; Action=Sell; Name=Exit long; Qty=1; CurrentState=Submitted; 
    Historical 11/05/2017 03:48:54    Order updated: Type=Market; Action=Sell; Name=Exit long; Qty=1; CurrentState=Accepted; 
    Historical 11/05/2017 03:48:54    Order updated: Type=Market; Action=Sell; Name=Exit long; Qty=1; CurrentState=Working; 
    Historical 11/05/2017 03:48:54    Attention: Entry signal occured: Enter short: 
    Historical 11/05/2017 03:48:54      Opening short limit at price 47.4...
    Strategy 'Adam Trading Strategy/-1': An Enter() method to submit an entry order at '11/05/2017 03:48:54' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
    Historical 11/05/2017 03:48:54    Order updated: Type=Market; Action=Sell; Name=Exit long; Qty=1; CurrentState=Filled; FillPrice=47.45; 
    Historical 11/05/2017 03:48:54    Filling executed. Current price info:Current Ask=47.45, Bid=47.45, Bar Index=22, Bar TOHLC=[11/05/2017 03:48:54;47.45;47.47;47.44;47.45], Bar Ticks=1, Position=[Flat]
    Historical 11/05/2017 03:48:54    Position updated: instrument='CL 06-17' account='Backtest' avgPrice=0 quantity=0 marketPosition=Flat statementDate='1800-01-01'
    I see the reason: my order for exiting the position is not filled yet when I try to enter ShortLimit. If I postpone my short limit order and send it AFTER exit position execution, everything will be ok. But I can't, because I have the signal exactly on this bar and I must to place order right now (in current OnBarUpdate instance)

    Is there any mechanism to wait exiting position filled not leaving OnBarUpdate?

    #2
    Hello,

    Thank you for the post.

    In this situation, one solution could be instead of using Exit orders, submit EnterShortLimit to reverse the position. Calling the opposite Entry order method would both Close and Enter into the opposite direction. If you are worried that the position may not close you would also need to review the isLiveUntilCancelled true in case the order is being expired when a bar closes. Otherwise, what you are seeing would be expected and you would need to wait for the exit to fill before submitting the new limit.

    If you are using OnBarUpdate to wait for the next bar to check for the exit to be filled, using OnExecutionUpdate may provide quicker confirmation on the fill so a new entry can be submitted upon filling:


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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Waxavi, Today, 02:10 AM
    0 responses
    6 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by TradeForge, Today, 02:09 AM
    0 responses
    11 views
    0 likes
    Last Post TradeForge  
    Started by Waxavi, Today, 02:00 AM
    0 responses
    2 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by elirion, Today, 01:36 AM
    0 responses
    4 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by gentlebenthebear, Today, 01:30 AM
    0 responses
    5 views
    0 likes
    Last Post gentlebenthebear  
    Working...
    X