Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detect Strategy position independently from Market position

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

    Detect Strategy position independently from Market position

    Hi,

    I am running on the same instrument two different strategies: one enters only long, the other enters only short. Only 1 contract is traded for each of them.
    In some cases it could happen that both have an open position, therefore MarketPosition = Flat, but Strategy1 = Long and Strategy2 = Short.
    The information about the 2 strategies is correctly reported in the "Strategies" Tab: 1L and 1S.

    My question is the following: is there a way to detect in my script what the Strategy Position is?

    I know about Position.MarketPosition, but Position.StrategyPosition or something equivalent is missing as far as I know. Is there any other option to get the Strategy Position, without having to follow every entry and exit within the script?

    Thank you
    Martin

    #2
    Hello,

    Thank you for your inquiry.

    The position of an account and the position of a strategy are separate., and the performance reports for accounts and strategies are also separate.To reference the strategy position, you would use Position.MarketPosition. For the account position, you would use PositionAccount.

    Running multiple strategies at a time on the same instrument and account will often cause the strategy instance's position to be out of sync with the account position.
    The Account Position will reflect all strategy-generated trades, but each Strategy position would only reflect positions generated by the strategy itself.

    For a strategy to effectively manage your account position, the strategy position and the account position would need to stay synchronized.
    Furthermore, a strategy cannot close orders submitted outside the strategy.

    This can have unintended consequences, and it is a better practice to consolidate the logic of all strategies into a single script.
    If you wish to trade the same instrument with multiple strategies at the same time, consider running them on separate accounts instead to prevent unwanted account positions.

    Please let us know if we may be of any further assistance.

    Comment


      #3
      Originally posted by martin70 View Post
      I am running on the same instrument two different strategies: one enters only long, the other enters only short.


      Same instrument?

      Good God, man, don't do that!

      It's a mistake, and will cost you dearly, sooner or later.

      Two suggestions:

      1. Use two different accounts.

      2. Setup a locking mechanism such that strategies can
      only enter a trade in their direction if they have acquired
      the lock. If the 2nd strategy can't acquire the lock, then
      that entry signal is ignored. The locking strategy should
      release the lock as soon as its position goes flat.

      Using #1 is easier, using #2 takes some coding skills.



      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X