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 Karado58, 11-26-2012, 02:57 PM
      8 responses
      14,825 views
      0 likes
      Last Post Option Whisperer  
      Started by Option Whisperer, Today, 09:05 AM
      0 responses
      1 view
      0 likes
      Last Post Option Whisperer  
      Started by cre8able, Yesterday, 01:16 PM
      3 responses
      11 views
      0 likes
      Last Post cre8able  
      Started by Harry, 05-02-2018, 01:54 PM
      10 responses
      3,204 views
      0 likes
      Last Post tharton3  
      Started by ChartTourist, Today, 08:22 AM
      0 responses
      6 views
      0 likes
      Last Post ChartTourist  
      Working...
      X