Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Counting and Averaging Bars between Crossover

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

    Counting and Averaging Bars between Crossover

    Hello,

    The end goal of this would be able to calculate the average range between each crossover. The first step in accomplishing this would be to find the average number of candles inbetween crossovers.

    I have been trying to find a way to count the number of bars between crossovers of two MAs. I would then need either a way to print the values or automatically average them.

    For example the 10 SMA would cross the 20 SMA. The number of bars between that point in time and the point at which they cross again is counted.

    This value would then be either printed in a document so I could average them using a calculator/excel or averaged in NinjaTrader.

    Is there an easy way to do this? Or is there another method to find the ATR of a crossover?

    Thanks

    #2
    Loren,

    Yes, this is possible.

    A rough design plan.

    You would need to have a few variables.

    1. barcount
    2. previousCrossPrice
    3. currentCrossPrice

    Increment the bar count bar by bar

    When you have a cross, compute the range by taking the absolute different between the previousCrossPrice and the currentCrossPrice. Then print that computation, along with the barCount, clear the barCount.

    hope this helps.
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X