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

Checking that Position is Flat

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

    Checking that Position is Flat

    I have a strategy that calls an ATM Strategy. The ATM Strategy starts with 4 contracts and scalps 3 at 4 ticks, then lets the last one run with a trail stop. In the strategy code I need to ensure that the last contract has closed before setting up another trade (order). I'm using this:
    if( GetAtmStrategyMarketPosition(ATMOrder) == MarketPosition.Flat) {
    // ATM is done - can allow a new order
    Print("Order Complete");
    }

    Instead, "Order Complete", prints out after the first 3 contracts are scalped. Am I using the correct approach here?

    Thanks.

    #2
    How are you determining that it has not closed the 4th already as well? What does GetAtmStrategyPositionQuantity() say?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh:

      I will add that check. Here's how I determined there was an issue: I had the DOM running and the Output Window visible concurrently. I saw the ATM strategy begin, the order fill and the first target hit. So, I was left with a contract that was being trailed. That last contract took enough time that I could look at Output Window and see the "Output Complete" print, before the
      trailing stop hit it much later.

      Having said all that, I'll add the check you suggest and see what results.

      Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by esmall, Today, 07:14 PM
      0 responses
      3 views
      0 likes
      Last Post esmall
      by esmall
       
      Started by Option Whisperer, 05-09-2024, 07:58 PM
      6 responses
      26 views
      0 likes
      Last Post Option Whisperer  
      Started by rayyyu12, Today, 05:38 PM
      0 responses
      12 views
      0 likes
      Last Post rayyyu12  
      Started by xepher101, Yesterday, 12:19 PM
      2 responses
      30 views
      0 likes
      Last Post xepher101  
      Started by thumper57, Today, 04:30 PM
      0 responses
      8 views
      0 likes
      Last Post thumper57  
      Working...
      X