Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceExitExecution

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

    BarsSinceExitExecution

    Hello Ninja Experts:

    I am trying to implement BarsSinceExitExecution but does not work.

    ---------------------------
    Code:
    if ((BarsSinceExitExecution(0,"L1",0) >=2 || BarsSinceExitExecution(0,"L1",0) == -1) && (Closes[0][0] > SMA(10)[0]))
    {
    EnterLong(1, "L1");
    }
      
    
    if (( Position.MarketPosition == MarketPosition.Long) && (Closes[0][0] < SMA(10)[0]))
    {
    ExitLong("XL1", "L1");
    }
    -------------------------------


    Also, tried with Exit Signal:
    ​if ((BarsSinceExitExecution(0,"XL1​",0) >=2 || BarsSinceExitExecution(0,"XL1​",0) == -1) && (Closes[0][0] > SMA(10)[0]))​

    I did spend considerable time and have gone through all the posts in this forum but I am unable to find the root cause.

    Appreciate your help!

    Thanks.
    Last edited by NRITV; 04-08-2025, 12:57 PM.

    #2
    Hello NRITV,

    In the code you provided you used 0 as the index for the bars in progress in BarsSinceExitExecution but your entries are being submitted on 1, do you see this work if you use 1 instead of 0? You also should use a Print statement to see wah the value is that is returned from BarsSinceExitExecution.

    Comment


      #3
      NinjaTrader_Jesse Jesse Thank YOU!

      EnterLong(1, "L1");

      1 represents a lot/qty. Please help me understand. I will try with 1 and let you know.​

      Comment


        #4
        Hello NRITV,

        The 1 in that case is bar series number 1 meaning BarsInProgress 1. if you have a multi series script that would be the first added series. You have a primary and then can add series so 1 is not the primary but the first series you added in code.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        86 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        125 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        64 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        117 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X