Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ID for different open conditions?

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

    ID for different open conditions?

    Hi,

    Is it possible to use a command that can identify unique "open" positions within a strategy that can possibly open mulitple trades? For example if I have a strategy that has 3 possible conditions that may initiate a trade...is it possible to identify which conditions are "open" at the current time--Such as:

    "Condition 1 is Long"
    "Condition 2 is Flat"
    "Condition 3 is Short"...

    Could a command like "Position.AvgPrice" do this? I know about commands like "Position.MarketPosition" but I believe they will take into consideration all conditions. I know each condition can be given a unique name upon triggering a trade, I just would like to be able to "track" what conditions are "active" an those that are not...thank you in advance.

    #2
    You can probably run your own variable through your conditions to determine the theoretical states of all your orders. When condition 1 becomes long set the variable to 1. If its flat set your variable to 0. If it is short set it to -1. When you call the variable just check the value against the proper value state. Hope that helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thanks for your post. I think I understand but that leads me back to my original question--in order to do so how do I use the " Position.MarketPosition" command(s) for EACH condition within the strategy?

      In other words I'd need to do something like:

      "if(Position.MarketPosition[condition #1] ==
      MarketPosition.Long){set variable or do something...}"

      I was under the impression that the "Position.MarketPosition" command takes ALL conditions into consideration, so for example in a strategy with 4 possible conditions if 1 of those conditions is "long" then "MarketPosition.Long" would be set to "true"...despite the fact that the other 3 positions are flat. I hope that makes sense...

      Comment


        #4
        No. You need to realize you only have ONE position at a time. If you get filled short on one order and then get filled long on another. You are no longer short on condition 1 and long on condition 2. You are just simply long since entering long from a short is a reversal order that will first close out your short position before acquiring the long position.

        If condition1 generates a long order and you get filled, MarketPosition becomes long. When condition2 generates a short and condition1 is "long", MarketPosition becomes short because that is what you have now; a short position.

        Going back to my suggestion. You want to run a variable through the condition to determine what your theoretical state of the different conditions would be.

        So for example.
        Code:
        if (Close[0] > Close[1])
        {
             EnterLong("Condition1");
             condition1State = 1;
        }
        if (Close[0] < Close[1])
        {
             ExitLong("Condition1 Exit", "Condition1");
             condition1State = 0;
        }
        if (condition1State == 1)
             Print("Condition1 is Long");
        else if (condition1State == 0)
             Print("Condition1 is Flat");
        Now this is not perfect logic because of potential issues that might happen. For instance, you might only get partial fills or you might get rejected orders. To address this you can use Position.MarketPosition and Position.Quantity. Check the state and value of those two before submitting an order. Store the info. Run through the check again and see if the MarketPosition reflects the correct direction and if Quantity reflects the proper amount.

        So if you were Short before Condition1, your initial check will tell you MarketPosition = Short and Quantity=100 (or whatever). In your secondary check you will see MarketPosition is now Long and Quantity is 100. This is correct position we should be in so we know everything is correct. If our quantity is less than 100 we know we have a partial fill. If our MarketPosition is still short we know our order was rejected or something happened to it. Does this make sense?

        All in all, MarketPosition is relevant for your OVERALL position. If you want to differentiate between different condition's positions you will need to manually do it.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        598 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        555 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X