Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketPosition is set to Flat

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

    MarketPosition is set to Flat

    Hello,

    I have just started with NinjaTrader and created my first strategy. The strategy trades FAS and FAZ and the rule is that at any given time I can only have a position open in either FAS or FAZ.

    In the Positions property I have two entries: 0 for FAS and 1 for FAZ.Then, OnBarUpdated, I check Positions[opposite].MarketPosition == MarketPosition.Flat (where opposite is the index of the non-current symbol) in order to safeguard from entering positions in both FAS and FAZ at the same time.

    Here is the problem. On this one date, I enter FAZ, and then, for some reasons, the strategy keeps entering FAS. I debugged it in VS 2010 and I can see that after EnterLong for FAZ is called on consequent calls to OnBarUpdated, the MarketPosition for FAZ is still shows Flat.

    Not sure where to take it from here? Why is the MarketPosition not updated to Long after calling EnterLong on FAZ?

    Thanks.

    Evgueni

    #2
    Evgueni, MarketPosition should change as soon as the position changes. There are a few other places this can be checked though, like OnPositionUpdate(), or by tracking executions in OnExecution(). If you would like, you can post your code here and we can take a closer look.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks. It was my mistake -- I was indexing into the Positions property incorrectly.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Brevo, Today, 01:45 AM
      0 responses
      3 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      3 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      240 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      384 views
      1 like
      Last Post Gavini
      by Gavini
       
      Started by oviejo, Today, 12:28 AM
      0 responses
      6 views
      0 likes
      Last Post oviejo
      by oviejo
       
      Working...
      X