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 Christopher_R, Today, 12:29 AM
        0 responses
        9 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        8 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X