Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NBarsDown not working properly.

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

    NBarsDown not working properly.

    Hi,

    I am trying to plot an indicator with NBarsDown.
    If previous 2 consecutive bars are down and current bar is up then it should print a dot on the current bar.
    I am using the following syntax:

    pullBack = NBarsDown (2,true,false,false)[1];
    if (Close [0] > Open [0])
    {
    if (pullBack == 1)
    {
    DrawDot ("BuySign" + CurrentBar,false, 0, Low[0],Color.Green);
    }
    }

    This code works at one place but not at other which is strange. Can someone explain if I am missing something here?

    Thanks
    Vinay
    Attached Files

    #2
    Hello Vinay,

    Thank you for reporting the behavior.

    I created a script and added prints to demonstrate the behavior.

    (This can be very helpful when trying to understand the cause of a behavior. Below is a link to a forum post that demonstrates.
    http://ninjatrader.com/support/forum...979#post510979)

    I've reported this and I will be looking further into it.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 01-07-2018, 02:38 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Vinay,

      Thank you for your patience.

      I've got more information for you now.

      The NBarsDown is looking for consecutive lower closes.

      This means that if we are looking a span of 2 bars, both bars need to have the close less than the bar before it.

      So with an offset of 1 bar ago, this would require the previous bar's close to be less than the close of 2 bars ago, and the close of 2 bars ago must be less than the close of 3 bars ago.

      The print condition would look like this:
      Code:
      if (Close[1] < Close[2] && Close[2] < Close[3] && Close[2] < Open[2] && Close[1] < Open[1])
      	Print(string.Format("{0} | condition set 1", Time[0]));
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by helpwanted, Today, 03:06 AM
      1 response
      12 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      9 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      5 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      387 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X