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

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
    JimNinjaTrader Customer Service

    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 arvidvanstaey, Today, 02:19 PM
      4 responses
      10 views
      0 likes
      Last Post arvidvanstaey  
      Started by samish18, 04-17-2024, 08:57 AM
      16 responses
      56 views
      0 likes
      Last Post samish18  
      Started by jordanq2, Today, 03:10 PM
      2 responses
      8 views
      0 likes
      Last Post jordanq2  
      Started by traderqz, Today, 12:06 AM
      10 responses
      18 views
      0 likes
      Last Post traderqz  
      Started by algospoke, 04-17-2024, 06:40 PM
      5 responses
      47 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X