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

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 f.saeidi, Today, 08:03 AM
    0 responses
    1 view
    0 likes
    Last Post f.saeidi  
    Started by cre8able, 04-17-2024, 04:16 PM
    7 responses
    63 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Aviram Y, 08-09-2023, 09:04 AM
    11 responses
    299 views
    0 likes
    Last Post arjandezeeuw  
    Started by Christopher Leggit, 02-15-2024, 09:00 AM
    3 responses
    47 views
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by DavidHP, Today, 07:56 AM
    0 responses
    2 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Working...
    X