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 rocketman7, Today, 01:00 AM
      0 responses
      1 view
      0 likes
      Last Post rocketman7  
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      27 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 04-23-2024, 09:53 PM
      2 responses
      74 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      193 views
      0 likes
      Last Post Hasadafa  
      Working...
      X