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 algospoke, 04-17-2024, 06:40 PM
      6 responses
      48 views
      0 likes
      Last Post algospoke  
      Started by arvidvanstaey, Today, 02:19 PM
      4 responses
      11 views
      0 likes
      Last Post arvidvanstaey  
      Started by samish18, 04-17-2024, 08:57 AM
      16 responses
      61 views
      0 likes
      Last Post samish18  
      Started by jordanq2, Today, 03:10 PM
      2 responses
      9 views
      0 likes
      Last Post jordanq2  
      Started by traderqz, Today, 12:06 AM
      10 responses
      21 views
      0 likes
      Last Post traderqz  
      Working...
      X