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 BarzTrading, Today, 07:25 AM
        2 responses
        27 views
        1 like
        Last Post BarzTrading  
        Started by devatechnologies, 04-14-2024, 02:58 PM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by tkaboris, Today, 08:01 AM
        0 responses
        6 views
        0 likes
        Last Post tkaboris  
        Started by EB Worx, 04-04-2023, 02:34 AM
        7 responses
        163 views
        0 likes
        Last Post VFI26
        by VFI26
         
        Started by Mizzouman1, Today, 07:35 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X