Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 TheWhiteDragon, 01-21-2019, 12:44 PM
    5 responses
    551 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by rtwave, 04-12-2024, 09:30 AM
    5 responses
    37 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by funk10101, Today, 12:02 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by GLFX005, Today, 03:23 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by nandhumca, Yesterday, 03:41 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X