Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Implementing Consecutive Bar Count Above MA in Strategy Builder

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

    Implementing Consecutive Bar Count Above MA in Strategy Builder

    I'm crafting a strategy using NinjaTrader's Strategy Builder and I’ve hit a roadblock. My objective is straightforward: I want to execute an entry when the price has closed above a specific moving average for a consecutive number of bars, defined by the user.

    Here’s the criterion in detail:

    Trigger an entry when ‘X’ number of consecutive bars close above a set moving average.
    The period of the moving average and the value of ‘X’ consecutive bars should be adjustable parameters in the strategy settings.
    Could you guide me on how to configure a counter for consecutive bars above the moving average within Strategy Builder’s interface, avoiding direct NinjaScript coding if possible?

    I appreciate any guidance or sample conditions that align with this framework.

    Warm regards,
    Hezi​

    #2
    Hello Hezi,

    Thanks for your post.

    We have an example of a bar counter in the Strategy Builder at the following link:
    with regard to the attached image: Line A is an indicator Line B is the m period MAX of line A Line C is an average of this indicator A Line D is another average of this indicator A is it possible, possibly using the strategy builder, but without adding a temporary variable, to set on the condition: line C crosses below line D


    It checks for a crossover and then saves the bar on which the crossover occurs, then it compares the current bar with the saved crossover bar to see how many bars have passed. You could use the same ideas in your strategy by saving the first bar that closes above the moving average and using that to see how many bars consecutively close above the moving average.

    The period and value of 'X' consecutive bars may be set up as user-defined values on the "Inputs and Variables" screen of the Strategy Builder. We have an example that takes user input for two different moving average periods here to demonstrate how that might be done:


    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    59 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X