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 CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        52 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        29 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        190 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        354 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        273 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X