Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with my first NT script.

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

    Need help with my first NT script.

    Hi,

    The goal for the script is to plot a dot on the SMA every time the price crosses it.
    It seems though it is not doing that on some down bars (please see attached chart).
    I am sure it is something simple and hope somebody can help me out.
    Here are the relevant parts of the script:

    #region Variables
    private int myInput0 = 1; // Default setting for MyInput0
    #endregion

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Dot, "Plot0"));
    Overlay = true;
    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    double curH = High[0];
    double curL = Low[0];
    if ((SMA(13)[0] > curL) && (SMA(13)[0] < curH))
    {
    Plot0.Set(SMA(13)[0]);
    }
    }

    #region Properties
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion

    Thanks!!
    Attached Files

    #2
    Sorry about this but I think I figured it out why the dots are missing on some down bars.. they are simply hidden by the down bar. I just made the dot size 3 and can see it. Is there a way the dots can be brought to the foreground?

    Comment


      #3
      I think maybe this might help you, try it:

      if ((Close[0]>SMA(13)[0] && Close[1]<SMA(13)[0]) || (Close[0]<SMA(13)[0] && Close[1]>SMA(13)[0]))
      {
      // Plot or other thing else
      }
      Last edited by pstrusi; 09-10-2013, 06:09 AM.

      Comment


        #4
        Hello gg2NT,

        Glad to hear that it is working.

        You can change them dots to be in the foreground by changing the Z-Order of the object.

        To adjust the z-order:
        1. Select the chart object by left clicking on it (you will now see small black squares on the object)
        2. Hold down the "Shift" key on your keyboard and roll the mouse scroll wheel to change the z-order of the object. The current position out of the total number of levels in the z-scale will be displayed.

        The following link will direct you to the portion of the NinjaTrader Help Guide for additional information.


        Unfortunately, changing this via code is not supported but you may view the following thread that goes over how you may try to accomplish this.


        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          That did it.. thanks very much, JC!

          Comment


            #6
            Thanks very much for your reply, pstrusi!
            I like your logic, it's different than my approach and it gives me other ideas..
            I am looking for a dot any time any part of the bar body is crossing the SMA..

            Comment


              #7
              Any time, good luck with your first Algo

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              580 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              336 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
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              552 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X