• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Maxwell123, Today, 12:34 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by memonic, Today, 02:21 AM
      0 responses
      2 views
      0 likes
      Last Post memonic
      by memonic
       
      Started by Guru73, Yesterday, 02:47 AM
      5 responses
      33 views
      0 likes
      Last Post Guru73
      by Guru73
       
      Started by Guru73, Today, 01:35 AM
      0 responses
      2 views
      0 likes
      Last Post Guru73
      by Guru73
       
      Started by i2w8am9ii2, Yesterday, 04:41 PM
      1 response
      11 views
      0 likes
      Last Post Lancer
      by Lancer
       
      Working...
      X