Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Only take trades when flat BUT on historical trades

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

    Only take trades when flat BUT on historical trades

    Hello guys,

    Im using PositionAccount.MarketPosition == MarketPosition.Flat on real time trades and is working perfectly. Same is not happening on historical, and I want to simulate my strategy behaviour as if real, but this is not happening. Each time there is a new signal on historical, current position is CLOSED and it goes in the other direction. How I can disable to take a new position if market is not flat but on historical trades?

    #2
    Hello facuevasm,

    Thanks for your first post!

    PositionsAccount would only be modified for trades submitted to the account live. Submitting an order during historical processing will change the strategy's position and will not change the account position.

    You can use the Position object instead of PositionsAccount which will reflect the strategy position and the strategy position will change with each historical or realtime trade that is placed.

    If you want the strategy to ignore creating a historical position, you can ignore historical processing with if (State == State.Historical) return;

    If you want to have the strategy inherit the account position, you can follow the example attached which uses the Unmanaged Approach.

    More information on Strategy vs. Account position and start behaviors are included below.

    Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm

    Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

    If this does not resolve your inquiry, could you elaborate on what you would like the strategy to do with historical and realtime processing?

    We look forward to assisting.
    Attached Files

    Comment


      #3
      Thank you Jim!!! This solved my problem. I just add Position.MarketPosition == MarketPosition.Flat to my condition to go long or short, and now my strategy waits until flat on historical bars until generates a new position. :=) Thanks again!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      55 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      132 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X