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

Print Triangle at MA Crossover

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

    Print Triangle at MA Crossover

    Hi.

    I've set up two moving averages of pivot points at 3 bars and 5 bars. When they crossover, I'd like to print a triangle (red for when the shorter ma crosses below the longer ma, green for when the shorter crosses above the longer).

    I haven't seen anything on this in the Ninjascript tutorials and haven't yet found anything similar in the forum, but still looking ....

    If anyone can help, it would be much appreciated.

    Thanks !

    #2
    Hi cutter,

    Drawing triangles can be done with either the DrawTriangleUp() or DrawTriangleDown() method.

    Code:
    if (CrossAbove(SMA(5), SMA(20), 1))
    {
         DrawTriangleUp("Fast-x-Slow", 0, Low[0] - 2 * TickSize, Color.Green);
    }
    There will be some reference samples up for draw methods up shortly. In the meantime you can view the help file for more draw methods you can use. Go to the index and look into the D section.
    Last edited by NinjaTrader_JoshP; 09-14-2007, 10:18 AM.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh, thank you much !

      Comment


        #4
        Hi. I have this working, thank you !

        Right now, it only prints a triangle on the most recent crossover. Once a new crossover occurs, the previous crossover marker drops off.

        I would like to have the crossover markers be persistent, meaning to display anywhere in chart history where there is a crossover, not just the most recent one. Can you offer any guidance for this?

        Thanks much !

        Comment


          #5
          Make the tag name unique.

          For example:

          DrawTriangleUp("Fast-x-Slow" + CurrentBar, 0, Low[0] - 2 * TickSize, Color.Green);
          RayNinjaTrader Customer Service

          Comment


            #6
            Ray, this worked for me, thanks !

            Comment


              #7
              ok, a minor glitch ....

              if the ma's cross while a bar is in the middle of printing, the crossover marker appears (which is good) .... but while still mid-bar, if the ma's move back apart, the crossover marker remains, even if the bars closes without an ma crossover.

              how can I make the crossover marker go away if the crossover does not hold?

              (if i remove and then reapply the indicator, the spurious markers do not come back)

              thanks !

              Comment


                #8
                Run your indicator with CalculateOnBarClose set to true or if you want it to update tick by tick, you wil need to add some code to remove the draw object.

                RayNinjaTrader Customer Service

                Comment


                  #9
                  Thank you Ray, will give it a shot and post results.

                  Comment


                    #10
                    Originally posted by cutter View Post
                    Hi.

                    I've set up two moving averages of pivot points at 3 bars and 5 bars.
                    Hello!

                    Could You kindly explain how to set up moving averages of pivot points at 3 bars and 5 bars ? (or could You share Your indicator code)

                    Kindly regards.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    238 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    384 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Started by oviejo, Today, 12:28 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post oviejo
                    by oviejo
                     
                    Started by pechtri, 06-22-2023, 02:31 AM
                    10 responses
                    125 views
                    0 likes
                    Last Post Leeroy_Jenkins  
                    Working...
                    X