Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

BarsSinceEntryExecution(0,"",0) in multi time frame

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

    BarsSinceEntryExecution(0,"",0) in multi time frame

    hello, i have some problem with BarsSinceEntryExecution(0,"",0) >3,

    I want to créate ExitLong in case of


    if (BarsInProgress == 0)
    {
    ….

    if (High[0]<High[1]
    && Close[0]<Close[1]
    && Low[0] <Low[1]
    && High[1]<High[2]
    && BarsSinceEntryExecution(0,"CH",0) >3
    )
    {Print("BarsSinceEntryExecution = "+BarsSinceEntryExecution(0,"CH",0));
    ExitLong(0,1,"LL","CH");}

    It doesn´t execute ExitLong , but DOES execute
    Print("BarsSinceEntryExecution = "+BarsSinceEntryExecution(0,"CH",0));


    I hve tried :
    if (High[0]<High[1]
    && Close[0]<Close[1]
    && BarsSinceEntryExecution(0,"CH",0) >3
    )
    {
    EnterLong(0,1,"LL");}

    And it DOES work.


    Anyone could help me?

    Its back testing.

    #2
    Hello margandi,

    Thanks for your post.

    It looks like you are using the exit name of "CH" (ExitLong(0,1,"LL","CH");}) and checking for an entry also named "CH" (BarsSinceEntryExecution(0,"CH",0))

    Try BarsSinceEntryExecution(0,"LL", 0)

    Note, when used as an entry condition, you have to also check for it returning a -1 in case there is no previous entry which will be the case on the first order. Please see the help guide section here: https://ninjatrader.com/support/help...yexecution.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      "CH" is name of entry signal
      "LL"- of exit.
      ExitLong(
      int
      barsInProgressIndex
      ,
      int
      quantity
      ,
      string
      signalName
      ,
      string
      fromEntrySignal
      )
      (ExitLong(0,1,"LL","CH").

      I dont see mistake.

      do you mean that i have to change loke this? :
      ExitLong(
      int
      barsInProgressIndex
      ,
      int
      quantity
      ,
      string
      FROMentrysignal
      ,
      string SIGNALname
      )
      And thank you for reminding to check for returning a -1

      Comment


        #4
        Hello margandi,

        Thanks for your reply.

        You do not have to change, I misread the order of ExitLong(0,1,"LL","CH");
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by inanazsocial, Today, 01:15 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by rocketman7, Today, 02:12 AM
        0 responses
        10 views
        0 likes
        Last Post rocketman7  
        Started by dustydbayer, Today, 01:59 AM
        0 responses
        2 views
        0 likes
        Last Post dustydbayer  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        23 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Working...
        X