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

MA cross indicator

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

    MA cross indicator

    I would like to be able to place two MAs of any type on a chart and have an indicator of some type show all the cross locations. Could be an arrow showing crossover/crossbelow or even a color change in bar. Is this difficult or even in the archives somewhere?
    Thanks.

    #2
    Bill, we don't usually code out indicators for customers, but I've had this one laying around, so here it is. You can import it by going to File -> Utilities -> Import NinjaScript, and then if you would like to view the code and/or edit it, you can go to Tools -> Edit NinjaScript -> then select ShowMACrosses.

    EDIT: Not sure if you're using 6.5 or 7, so I've attached both.
    Attached Files
    Last edited by NinjaTrader_Austin; 08-11-2010, 02:47 PM.
    AustinNinjaTrader Customer Service

    Comment


      #3
      I realize you don't provide that service, and certainly appreciate your taking the time to forward that to me. I'll give it a try. Thanks.

      Comment


        #4
        how can one have just the arrows plot and not the actual moving average lines?

        Comment


          #5
          rsmtrade,

          If you do not want to edit the indicator's code what you can try is just to set the plot colors to transparent when you add the indicator onto the chart.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Austin View Post
            Bill, we don't usually code out indicators for customers, but I've had this one laying around, so here it is. You can import it by going to File -> Utilities -> Import NinjaScript, and then if you would like to view the code and/or edit it, you can go to Tools -> Edit NinjaScript -> then select ShowMACrosses.

            EDIT: Not sure if you're using 6.5 or 7, so I've attached both.
            Hi Austin,

            The indicator is wonderful. I use 4 MAs, viz. 13,26,39,52 and I follow 3 MA Crossing strategy. Is it possible to add one more MA in the existing one and get the desired result?

            If so, can you be kind enough to guide me as to how to do that?

            Thanks in advance.

            Comment


              #7
              bsb1967, it sure is possible to add in another MA for the crosses, but you'd have to decide how you define the cross. With 3 MA's, you could have the fast crossing the medium, fast crossing the slow, and medium crossing the slow and vice versa for all of those, so it isn't as simple as saying "put an arrow here when "it" crosses".
              AustinNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Austin View Post
                bsb1967, it sure is possible to add in another MA for the crosses, but you'd have to decide how you define the cross. With 3 MA's, you could have the fast crossing the medium, fast crossing the slow, and medium crossing the slow and vice versa for all of those, so it isn't as simple as saying "put an arrow here when "it" crosses".
                Hi Austin,

                Yes, I follow, fast x medium, fast x slow, medium x slow. The visual effect helps me keep less strain on my eyes, therefore I would prefer back ground and bar colors, if plotting arrows is quite complicated, in this case.

                Comment


                  #9
                  3 MA Crossing

                  Originally posted by NinjaTrader_Austin View Post
                  bsb1967, it sure is possible to add in another MA for the crosses, but you'd have to decide how you define the cross. With 3 MA's, you could have the fast crossing the medium, fast crossing the slow, and medium crossing the slow and vice versa for all of those, so it isn't as simple as saying "put an arrow here when "it" crosses".
                  Hello Austin,

                  Thanks for giving me some inspiration. I tried, being a novice, to develop a 3 MA Crossing indicator based on the one you have given for NT6.5.

                  This is my output and have also attached an image of 4 Min. chart. I would appreciate if you feel any fine tuning and corrections required in this code.

                  I can't understand the function of "false" .

                  Healthy And Wealthy Weekend.

                  if(CrossAbove(FastPlot, MediumPlot, 1)&& CrossAbove(FastPlot, SlowPlot, 1)|| CrossAbove(MediumPlot,SlowPlot,1))
                  {
                  BackColor = Color.Blue;
                  BarColor = Color.Blue;

                  DrawArrowUp("up arrow" + CurrentBar, true, 1, MediumPlot[0] - 2 * TickSize, Color.Green);
                  }
                  else if(CrossBelow(FastPlot, MediumPlot, 1)&& CrossBelow(FastPlot, SlowPlot, 1)|| CrossBelow(MediumPlot,SlowPlot,1))
                  {
                  BackColor = Color.Red;
                  BarColor = Color.Red;

                  DrawArrowDown("down arrow" + CurrentBar, true, 1, MediumPlot[0] - 2 * TickSize, Color.Red);
                  }
                  }
                  Attached Files
                  Last edited by psb1967; 01-30-2011, 12:46 AM.

                  Comment


                    #10
                    psb1967, the code looks good. Which "false" function are you referring to? If you are talking about the parameter after the arrow tag, that is simply the autoscale parameter. If you set it to true, it will be drawn on the chart no matter which price it is drawn at. If it is set to false, then the arrow will only be displayed if the chart includes the arrow location in its current scaling scheme.
                    AustinNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Austin View Post
                      psb1967, the code looks good. Which "false" function are you referring to? If you are talking about the parameter after the arrow tag, that is simply the autoscale parameter. If you set it to true, it will be drawn on the chart no matter which price it is drawn at. If it is set to false, then the arrow will only be displayed if the chart includes the arrow location in its current scaling scheme.
                      Thanks Austin. I should have mentioned it in my previous reply itself, I forgot since I was excited to see the output of my first indicator; I am curious to know whether its possible to enable complete bar coloring and backcoloring, instead of just one line appearing on the chart when the crossings happen!!!

                      Comment


                        #12
                        psb, it is definitely possible to set the background color and bar color.
                        Code:
                        BackColor = Color.Green;
                        BarColor = Color.Blue;
                        AustinNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Austin View Post
                          psb, it is definitely possible to set the background color and bar color.
                          Code:
                          BackColor = Color.Green;
                          BarColor = Color.Blue;
                          Hi Austin,

                          These codes I have already placed but getting only one vertical bar. What I want is, all the bars to display respective colors in conjunction with Crossings.

                          Comment


                            #14
                            This will entirely depend on your conditions used to color the bars psb - if those are true the Back and BarColor would 'hit'.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Bertrand View Post
                              This will entirely depend on your conditions used to color the bars psb - if those are true the Back and BarColor would 'hit'.
                              Thanks Bertrand. I will check again. However, the code I had mentioned in my previous post is the one I am following, based on that only I have been trying to get the bars and back colors changed.

                              With these codes, BarColor = Color.Blue; & BackColor = Color.Blue; I am getting only one vertical line displayed. It would be helpful if both bars and back colors can be made to display to the entire region, with respect to the conditions.

                              Nice day.

                              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