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 ScottWalsh, Today, 04:29 PM
        0 responses
        4 views
        0 likes
        Last Post ScottWalsh  
        Started by rtwave, 04-12-2024, 09:30 AM
        2 responses
        21 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by tsantospinto, 04-12-2024, 07:04 PM
        5 responses
        69 views
        0 likes
        Last Post tsantospinto  
        Started by cre8able, Today, 03:20 PM
        0 responses
        7 views
        0 likes
        Last Post cre8able  
        Started by Fran888, 02-16-2024, 10:48 AM
        3 responses
        49 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Working...
        X