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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    310 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X