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 aligator, 01-06-2022, 12:14 PM
        4 responses
        231 views
        0 likes
        Last Post john_44573  
        Started by reynoldsn, Today, 05:56 PM
        0 responses
        2 views
        0 likes
        Last Post reynoldsn  
        Started by bortz, 11-06-2023, 08:04 AM
        51 responses
        1,986 views
        0 likes
        Last Post aligator  
        Started by dmking, 11-12-2019, 12:31 PM
        4 responses
        4,145 views
        0 likes
        Last Post jasonw
        by jasonw
         
        Started by roblogic, Today, 04:31 PM
        0 responses
        10 views
        0 likes
        Last Post roblogic  
        Working...
        X