Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Avoiding Historical Trades When Turning On Strategy

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

    Avoiding Historical Trades When Turning On Strategy

    When I enable my strategy, historical trades are placed (as expected) when I enable Tools -> Options -> Strategies -> Ninjascript -> Immediately submit live working historical orders.

    However, when I select "Wait until flat before executing live", I get a "phantom" position when I enable my strategy -- e.g., I see an unrealized value, but no position.

    When the next entry signal occurs, I get an error message when Ninjatrader tries to close the "phantom" trade. As a side note, on connection loss, I have Handling set as "KeepRunning", and I have Cancel Entry/Exit orders checked under order handling.

    Is there a way in my code or via settings to prevent active historical orders? When I start my strategy, I don't want historical orders to be placed. I'd like for trading to begin at the next entry signal after I turn on my strategy. Thanks in advance.

    #2
    Hello micprice,

    Thanks for your post.

    The nature of Wait until flat is that the strategy will start yellow if there is a historical position. Reversing the direction or exiting the trade will allow the strategy to become/pass through flat. This readies the script for the first live trade.

    To prevent historical trades, and start the strategy flat, use the Historical bool to prevent orders.

    For example add to the beginning of OnBarUpdate():
    if (Historical)
    return;

    Below is a link to the help guide on historical.
    http://www.ninjatrader.com/support/h...historical.htm


    Regarding the error message, what does this error message say?

    If you are trying to exit and enter on the same bar this will cause an overfill, just something to watch out for.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea! I meant to screenshot the error message earlier -- my brain is too fried to change my settings and duplicate it!

      The strategy did start yellow. When the strategy tried to exit an existing "phantom"/historical short position before entering a new long position, I got the dialog box with the error message.

      It was pretty long, and had three buttons at the bottom (Ignore, Abort, and something else). If I hit Ignore, the script would continue on. If I hit Abort, Ninjatrader would shut down.

      Comment


        #4
        Hello micprice,

        Thank you for your response.

        If you can please take a screenshot of this if it occurs again.

        In the meantime we can look further into this. Please send me your log and trace files for today so that I may look into what occurred. You can do this by going to the Control Center-> Help-> Mail to Platform Support. Please reference this thread in the body of the e-mail: "http://www.ninjatrader.com/support/forum/showthread.php?t=73048"

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        5 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X