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

DrawRegion query

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

    DrawRegion query

    Hi all;

    I have two MA's crossing and I want to fill the region between them. I am using DrawRegion.

    Problem is defining the 'int startBarsAgo' & 'int endBarsAgo'.

    When the fast ma crosses above the slow ma is the start of the region to be shaded and when the fast ma crosses below the slow ma is the end of the shaded region. The region obviously being between the two ma's.

    Here's the line - DrawRegion("Long zone", CurrentBar, 0, Sma1, Sma2, Color.Empty, shadelong, opacity);

    Do I need to state something earlier like CrossAbove(fastma, slowma) = startbar etc and then use the startbar for startBarsAgo?
    How do I get it to leave one region painted one color eg red for short then when the ma's cross in the opposite direction paint the next region say green. Would this be 'CurrentBar.ToString ()'? I want it to paint as the bars are formed.

    Any examples anyone can point me to please.

    Ben

    #2
    Hi Ben,

    Yes, you could custom track the start bar by storing CurrentBar at the time of a condition. Check out this indicator shared by phoenix for ideas doing this:


    The built in methods MRO(), LRO() are also useful for identifying the number of bars since a condition.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Perfect - If only I'd thought of looking for the obvious first - of course someone else has done this LOL !!!

      Thanks again for your super quick support - have a good weekend.

      Ben.

      Comment


        #4
        I'm glad to help. You do the same!
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sightcareclickhere, Today, 01:55 PM
        0 responses
        1 view
        0 likes
        Last Post sightcareclickhere  
        Started by Mindset, 05-06-2023, 09:03 PM
        9 responses
        258 views
        0 likes
        Last Post ender_wiggum  
        Started by Mizzouman1, Today, 07:35 AM
        4 responses
        18 views
        0 likes
        Last Post Mizzouman1  
        Started by philmg, Today, 01:17 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by cre8able, Today, 01:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X