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

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 traderqz, Today, 09:44 AM
              2 responses
              4 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by stafe, 04-15-2024, 08:34 PM
              8 responses
              40 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by rocketman7, Today, 09:41 AM
              2 responses
              6 views
              0 likes
              Last Post rocketman7  
              Started by rocketman7, Today, 02:12 AM
              7 responses
              31 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by guillembm, Yesterday, 11:25 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X