Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Running multiple strategies on the same security

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

    Running multiple strategies on the same security

    Hi,

    I have two strategies for trading the same security (eg: EURUSD on a short term and on a long term strategy). I want them to work independently, without knowledge or consideration as to what the other strategy is doing. Ie, I don't mind doubling my risk, or having my two strategies make equal, opposing trades (since they'll close out at different times anyway).

    My problem is that I use "Position.MarketPosition == MarketPosition.Flat" as a condition to ensure that each strategy handles only one trade at a time.

    As a result, when strategy A is long EURUSD, strategy B cannot trade, since the account is not "flat" EURUSD. This is because Position.MarketPosition == MarketPosition.Flat is a reference to the account position.

    In light of these facts, it becomes clear that Position.MarketPosition == MarketPosition.Flat is not a valid mode of position control when running two strategies side by side trading the same security.

    I would like to know how I can programme my two strategies to run side by side on the same security without one interrupting the other. Is it possible? As alternatives to "Position.MarketPosition == MarketPosition.Flat", I have tried using Position.Quantity and Variables0-9 to determine if the strategy has traded, but neither seems to work (since Variable0 is undefined at the beginning of a loop, and for some strange reason, position.quantity work).

    #2
    Also, if there is no way to prevent the strategies from clashing, I might have to consider opening a separate IB account so that the issue does not arise. Will I be able to use the same NT license for both IB accounts? Am hoping to find a solution though!

    Comment


      #3
      skyholder84, NinjaTrader strategies are completely independent of each other. As such, they cannot read position information from other strategies. Since NinjaScript is based off of C#, you are able to code up a position tracker however you wish, from writing to a file and then reading that file in your other strategy, the whole way to a full-featured MySQL database that tracks all orders, fills, and positions.

      So it is possible, but not in a direct fashion.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Would I be able to say, set a different order quantity for each strategy to act as a control?

        Illustration:

        Strategy A trades only 1 contract
        Strategy B trades 2 contracts

        The control logic would go like this:

        If(StrategyAGeneralConditions = True
        && Position.Quantity != 1
        && Position.Quantity != 3)

        {EnterLong(20000, "LS1");}

        - If Position Quantity is 0, neither strategy has traded, and Strategy A is good to go.
        - If Position Quantity is 2, only Strategy B has traded, and Strategy A is also good to go.
        - If Position Quantity is 3, both strategies have traded, and Strategy A is blocked from further trading (Of course, a similar measure will be written in Strategy B)

        Hence, as long as Position.Quantity != 1, my strategy can "deduce" that it hasn't traded.

        Can I use the Position.Quantity function as a control in this way?

        Comment


          #5
          Hi skyholder84,

          Your net account position will reflect activity for both strategies, but all the properties you're using only apply within the strategy instance that access them. If you check MarketPosition, you're checking that strategies position rather than the account position.

          There are only a handful of account level properties you can access. The rest are specific to the strategy instance calling them.
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Kaledus, Today, 01:29 PM
          0 responses
          3 views
          0 likes
          Last Post Kaledus
          by Kaledus
           
          Started by PaulMohn, Today, 12:36 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by yertle, Yesterday, 08:38 AM
          8 responses
          36 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by rdtdale, Today, 01:02 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          3 responses
          18 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X