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 NullPointStrategies, Today, 05:17 AM
        0 responses
        20 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        119 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X