Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sma cross strategy

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

    #16
    hello,
    can you help me with the region drawing code..... which code I should use from the link you provided for a sma cross....

    Comment


      #17
      Hello hir04068,

      I've copied the example from the help guide and substituted the SMA.

      Code:
      Draw.Region(this, "tag1", CurrentBar, 0, SMA(7), SMA(14), null, Brushes.Blue, 50);
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Originally posted by NinjaTrader_ChelseaB View Post
        Hello hir04068,

        I've copied the example from the help guide and substituted the SMA.

        Code:
        Draw.Region(this, "tag1", CurrentBar, 0, SMA(7), SMA(14), null, Brushes.Blue, 50);
        hello,
        i used this code
        if (CrossAbove(SMA1, SMA2, 1))
        {
        Draw.ArrowUp(this, "tag1" + CurrentBar, false, 0, (Close[0] + (-3 * (TickSize * 10))) , Brushes.Lime);
        Draw.Region(this, "tag1", CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Blue, 50);
        }

        // Set 2
        if (CrossBelow(SMA1, SMA2, 1))
        {
        Draw.ArrowDown(this, "tag1" + CurrentBar, false, 0, (Close[0] + (3 * (TickSize * 10))) , Brushes.Red);
        Draw.Region(this, "tag1", CurrentBar, 0, SMA(PeriodSlow), SMA(PeriodFast), null, Brushes.Red, 50);
        }
        but i just get blue colour and no red colur when it cross down....

        Comment


          #19
          Hello hir04068,

          Currently you are using the same tag name for two different drawing objects.

          Only one of them is going to be drawn if you are re-using the tag name.

          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Hello,
            I used this code and now its painting 2 color but I think I did something wrong.... can you please chk // Set 1
            if (CrossAbove(SMA1, SMA2, 1))
            {
            Draw.ArrowUp(this, "tag1" + CurrentBar, false, 0, (Close[0] + (-3 * (TickSize * 10))) , Brushes.Lime);
            Draw.Region(this, "tag2" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Blue, 20);
            }

            // Set 2
            if (CrossBelow(SMA1, SMA2, 1))
            {
            Draw.ArrowDown(this, "tag1" + CurrentBar, false, 0, (Close[0] + (3 * (TickSize * 10))) , Brushes.Red);
            Draw.Region(this, "tag3" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Red, 20);
            }


            Attached Files

            Comment


              #21
              Hello hir04068,

              I see that you have set the tag for the Up and Down arrow to the same, was this intentional? It looks like the other tags used are unique.

              This is all I can see that may be incorrect, I also see the Down arrow and Region share the same color where the Up arrow and region do not. Is this related to what you are seeing?


              I look forward to being of further assistance.

              Comment


                #22
                hello,
                I am using this code but I don't get lime color in region area...... can you please chk
                thanks


                protected override void OnBarUpdate()
                {
                if (BarsInProgress != 0)
                return;

                if (CurrentBars[0] < 1)
                return;

                // Set 1
                if ((SMA1[0] + (Close[0] * TickSize)) > SMA2[0])
                {

                Draw.Region(this, "tag1" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Red, 10);
                }

                // Set 2
                if ((SMA1[0] + (Close[0] * TickSize)) < SMA2[0])
                {

                Draw.Region(this, "tag2" , CurrentBar, 0, SMA(PeriodFast), SMA(PeriodSlow), null, Brushes.Lime, 30);
                }
                // Set 3
                if (CrossAbove(SMA1, SMA2, 1))
                {
                Draw.ArrowUp(this, "tag3" + CurrentBar, false, 0, (Close[0] + (-1 * (TickSize * 5))) , Brushes.Lime);
                }

                // Set 4
                if (CrossBelow(SMA1, SMA2, 1))
                {
                Draw.ArrowDown(this, "tag4" + CurrentBar, false, 0, (Close[0] + (1 * (TickSize * 5))) , Brushes.Red);
                }
                }
                Attached Files

                Comment


                  #23
                  Hello hir04068,

                  As a heads up, the file name is SMAregion but the internal name for the script is SMAcross.. which can be confusing.

                  Are you using prints to ensure that the condition to draw the object is evaluating as true?

                  Below is a link to a forum post that demonstrates how to use prints to understand behavior.


                  If a print of the Time[0] is in the same action block of the Draw.Region call that is not appearing, does the time appear in the output window?

                  If not, print all variables and values used in the condition set to the output window.

                  May I have the output from the prints to see on what bars the condition is evaluating as true?

                  Below is a complex script that does region highlighting for multiple moving averages.
                  Rewrite of the MACrossBuilder 1) Various Moving averages: DEMA, EMA, LinReg, HMA, SMA, TEMA, TMA, VWMA, WMA, ZLEMA 2) Various indication options 3) Can output to alerts window 4) Can output to Market Analyzer (+1, 0, &#8208;1 = Cross up, No cross, cross down) 5) Colors region between Moving averages V1.02 Update 10&#8208;31&#8208;17, minor code [&#8230;]



                  The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello hir04068,

                    As a heads up, the file name is SMA region but the internal name for the script is SMA cross.. which can be confusing.

                    Are you using prints to ensure that the condition to draw the object is evaluating as true?

                    Below is a link to a forum post that demonstrates how to use prints to understand behavior.


                    If a print of the Time[0] is in the same action block of the Draw. Region call that is not appearing, does the time appear in the output window?

                    If not, print all variables and values used in the condition set to the output window.

                    May I have the output from the prints to see on what bars the condition is evaluating as true?

                    Below is a complex script that does region highlighting for multiple moving averages.
                    Rewrite of the MACrossBuilder 1) Various Moving averages: DEMA, EMA, LinReg, HMA, SMA, TEMA, TMA, VWMA, WMA, ZLEMA 2) Various indication options 3) Can output to alerts window 4) Can output to Market Analyzer (+1, 0, &#8208;1 = Cross up, No cross, cross down) 5) Colors region between Moving averages V1.02 Update 10&#8208;31&#8208;17, minor code [&#8230;]



                    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                    thanks for the Macross indicator you provided... this is what I wanted...

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    601 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    347 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    103 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    559 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    558 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X