Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-time frame question: how to retrieve BIP position quantity

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

    Multi-time frame question: how to retrieve BIP position quantity

    Hi NT team

    I have a multi-time frame strategy.

    Add(PeriodType.Minute, 60); // BIP 1
    Add(PeriodType.Minute, 30); // BIP 2
    Add(PeriodType.Minute, 10); // BIP 3

    for each BarsInProgress (BIP) I have an entry and exit calculations logic. All BIP should generally enter and exit independently of each other.

    I have for example the following entry orders for BIP1:

    if (myLimit31 == null)
    {
    myLimit31 = EnterLongLimit(2,true,EntrySize,Limit1,"EL30-1");
    }

    if (myLimit32 == null)
    {
    myLimit32 = EnterLongLimit(2,true,EntrySize,Limit2,"EL30-2");
    }

    if (myLimit33 == null)
    {
    myLimit33 = EnterLongLimit(2,true,EntrySize,Limit3,"EL30-3");
    }

    Now if I would like to exit only the positions from entry orders EL30-1 to EL30-3, but not any other position entered on any other BIP timeframe. How would I do this?

    I have tried with Positions[2].Quantity (not working):
    ExitOrder30 = ExitLongStopLimit(Positions[2].Quantity, Lows[2][0] - 0.01,Lows[2][0] - 0.01,"XL30+" + CurrentBar,"");

    Can I try something with "EL30*" whereby all orders which start with "EL30" will be exited? Obviously I could also add an entry counter per BIP, but I thought there is probably a better solution.

    Thank you
    whotookmynickname

    #2
    Originally posted by whotookmynickname View Post
    Hi NT team

    I have a multi-time frame strategy.

    Add(PeriodType.Minute, 60); // BIP 1
    Add(PeriodType.Minute, 30); // BIP 2
    Add(PeriodType.Minute, 10); // BIP 3

    for each BarsInProgress (BIP) I have an entry and exit calculations logic. All BIP should generally enter and exit independently of each other.

    I have for example the following entry orders for BIP1:

    if (myLimit31 == null)
    {
    myLimit31 = EnterLongLimit(2,true,EntrySize,Limit1,"EL30-1");
    }

    if (myLimit32 == null)
    {
    myLimit32 = EnterLongLimit(2,true,EntrySize,Limit2,"EL30-2");
    }

    if (myLimit33 == null)
    {
    myLimit33 = EnterLongLimit(2,true,EntrySize,Limit3,"EL30-3");
    }

    Now if I would like to exit only the positions from entry orders EL30-1 to EL30-3, but not any other position entered on any other BIP timeframe. How would I do this?

    I have tried with Positions[2].Quantity (not working):
    ExitOrder30 = ExitLongStopLimit(Positions[2].Quantity, Lows[2][0] - 0.01,Lows[2][0] - 0.01,"XL30+" + CurrentBar,"");

    Can I try something with "EL30*" whereby all orders which start with "EL30" will be exited? Obviously I could also add an entry counter per BIP, but I thought there is probably a better solution.

    Thank you
    whotookmynickname
    What is the error message in your log?

    Comment


      #3
      Thanks koganam for trying to help. There is no error message, as there is no error. I just want to know what the best solution is to what I am trying to achieve.

      NT team, can you help?

      Comment


        #4
        Hello whotookmynickname,

        I am not sure what you mean by "Positions[2].Quantity (not working)". Positions[] 0 - 3 should all return the same information since they are all the same instrument.

        So if you do
        Code:
        ExitOrder30 = ExitLongStopLimit(Positions[2].Quantity, Lows[2][0] - 0.01,Lows[2][0] - 0.01,"XL30+" + CurrentBar,"");
        It should submit an order to put your Strategy in a flat position after the order is filled. If you have submitted other orders and you do not want those order to be exited as well, you would have to check the orders, or create a variable to know how many order to exit out.

        Let me know if you have any questions.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC

          Thank you. With the "Positions[2].Quantity (not working)" I meant exactly what you described as this is not the solution to my problem.

          "If you have submitted other orders and you do not want those order to be exited as well, you would have to check the orders, or create a variable to know how many order to exit out."
          I think this suggestion points to a solution where I have a variable such as PositionSizeCounter30 for each BIP and then use this variable in the exit orders. This is what I also had in mind but wanted to make sure that there is no other way to achieve this such as "Exit all positions from entry orders which start with "EL30"" or anything else like this.

          If you quickly agree, I will enter such positionsizecounter variables in my code.

          whotookmynickname

          Comment


            #6
            Hello whotookmynickname,

            I would say it that it is the easiest/best solution that I can think of to be able to achieve what you would like.
            JCNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X