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


Plotting simple dots on MA crossover

  • Filter
  • Time
  • Show
Clear All
new posts

    Plotting simple dots on MA crossover

    I've been sifting through all the thumbnails of the NT7 shared indicators to get a working example, but there is not a single instance of someone successfully drawing a dot at the crossover of 2 moving averages.

    Can someone please give a code snippet example of how to print a dot at the intersection of 2 MA crossovers.

    Attached is a picture in another platform of what I would like to do. Just put dots at the crossover of 2 averages.
    The script code for this is very simple one line and it just works flawlessly.

    plot(cross(ma1, ma2) ? ma2 : na, color = (ma2 - ma1 > 0 ? fuchsia : blue) , style = circles, linewidth = 3)

    The C# equivalent to this is proving to be quite a bit more involved. I've got the math figured out and am 70% there. Just trying to figure out why CrossAbove() and DrawDot() don't really behave.

    Below is the basics of what I've been trying without luck. 2nd pic attached.
    It just plots a dot at the fast MA line, but only to the far right and it keeps redrawing.
    How do I get the dots to just plot and then stay at the crossover points like in the first picture?

    if (codots != false)
    if (CrossAbove(Values[1], Values[0], chanlen))
    //DrawDot("Bull Dot", true, 0, Values[0][0], Color.Blue);
    DrawDot("Bull Dot", true, 1, Values[0][0], Color.Blue);



    Can someone provide a few lines of code to point me in the right direction. I see there's a few MACDBB type indicators based on ascending/descending slope in the sharing area but they don't have an example of what I need.

    I'm hoping this is a very basic thing to do, but can't find a single code example Googling around.
    Attached Files

    Hello cpuzz,

    Thanks for your post and welcome to the forums!

    We have a working reference sample that will demonstrate the drawing of objects using the cross conditions here:

    I think you have the code you need by using the if (CrossAbove()) method.

    Your DrawDot code is correct except for the "tag" name.

    If you use the same tag name for each object what happens is that the first object is removed from the chart and the new object is drawn as there can only be one unique name per object. In this mode then only the latest dot would be drawn.

    If you use a unique tag name for each dot, then each dot will remain on the chart. An easy way to create a unique name is to add the CurrentBar number to it, for example: DrawDot("Bull Dot"+CurrentBar, true, 1, Values[0][0], Color.Blue); If you were to look at the property of each dot drawn you would see a tag name (examples) of Bull Dot2345, Bull Dot19812.

    Paul H.NinjaTrader Customer Service


      Hello cpuzz, how are you?

      Regarding your indicator Wave Trend Oscillator - NinjaTrader Ecosystem​ ... Is it possible to plot dots a little bit faster?
      Can you code it for me? Or give me instructions how to code in order to plot dots a little bit faster. I use proprietary renko bars, and it's plotting one bar late.

      Thank you!


        ty trying to download wave trend osc, but does not show up in my indicator file ????????ty vm


          Hello tbillm,

          To import a NinjaScript into NinjaTrader 8 do the following:
          1. Download the script to your desktop, keep it in the compressed .zip file.
          2. From the Control Center window select Tools -> Import -> NinjaScript...
          3. Click the Desktop icon on the left to navigate to the desktop
          4. Select the downloaded .zip file -> then click Open
          5. NinjaTrader will then confirm if the import has been successful.
          Critical *Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.

          Below is a link to the help guide on importing NinjaScripts.

          If the import is successful, ​the indicator will be listed with the name WaveTrendV2 in the Indicators window in the Available list.
          Chelsea B.NinjaTrader Customer Service


          Latest Posts


          Topics Statistics Last Post
          Started by canarydaytrading, Today, 12:14 PM
          6 responses
          Last Post canarydaytrading  
          Started by 12VMan, Today, 04:14 PM
          0 responses
          1 view
          Last Post 12VMan
          by 12VMan
          Started by jpkulkarni, Today, 03:58 PM
          1 response
          Last Post NinjaTrader_Emily  
          Started by stephan06, Today, 03:56 PM
          0 responses
          Last Post stephan06  
          Started by RookieTrader, Today, 06:16 AM
          3 responses
          Last Post NinjaTrader_Gaby