Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Testing first strategy

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

    Testing first strategy

    Total newbie here, to both NT and C#. Trying to test a simple strategy to ensure I understand the concepts. Just want it to draw a dot when the condition is met. I bring up a daily chart using a Yahoo connection, apply the strategy. Doesn't seem to be working. Thanks for help.

    ps....wish you ran more "Intro to Ninjascript" online classes. Hard to come by.

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    ///<summary>
    /// Indicates Three Lower Closes
    ///</summary>
    [Description("Indicates Three Lower Closes")]
    publicclass ThreeLowerClosesTest : Strategy
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    #endregion
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose =
    true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] < Close[1]
    && Close[
    1] < Close[2]
    && Close[
    2] < Close[3])
    {
    DrawDot(
    "My dot" + CurrentBar, false, 0, 0, Color.Blue);
    }
    }
    #region Properties
    #endregion
    }
    }
    #region Wizard settings, neither change nor remove

    #2
    Originally posted by ntfarmer View Post
    Total newbie here, to both NT and C#. Trying to test a simple strategy to ensure I understand the concepts. Just want it to draw a dot when the condition is met. I bring up a daily chart using a Yahoo connection, apply the strategy. Doesn't seem to be working. Thanks for help.

    ps....wish you ran more "Intro to Ninjascript" online classes. Hard to come by.

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    ///<summary>
    /// Indicates Three Lower Closes
    ///</summary>
    [Description("Indicates Three Lower Closes")]
    publicclass ThreeLowerClosesTest : Strategy
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    #endregion
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose = true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] < Close[1]
    && Close[1] < Close[2]
    && Close[2] < Close[3])
    {
    DrawDot("My dot" + CurrentBar, false, 0, 0, Color.Blue);
    }
    }
    #region Properties
    #endregion
    }
    }
    #region Wizard settings, neither change nor remove
    Your dots are beeing drawn at price level 0. And with autoscale set to false you simply don't see them.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X