Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Building a Strategy with nBarsDown

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

    Building a Strategy with nBarsDown

    Hello,

    I am having some trouble building a strategy with nBarsDown. I tried using a user input of value = 1 for true (when I tried to use a bool with this indicator it said Type of left expression and right expression do not match).

    Essentially, I am trying to get the strategy to enter a long trade when there are 4 consecutive bars down.

    I have attached a pic of the strategy builder and some of the code it generated.

    Thanks!
    Lois

    Click image for larger version

Name:	Capture.PNG
Views:	109
Size:	10.6 KB
ID:	1200754

    Value = 1;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    NBarsDown1 = NBarsDown(Close, 4, true, true, true);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (NBarsDown1[0] == Value)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");

    #2
    Hi, thanks for posting. Use the Misc>Numeric value instead on the right side of the condition builder.

    Kind regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    61 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    32 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    44 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    58 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    47 views
    0 likes
    Last Post CarlTrading  
    Working...
    X