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

Strategy in NT7 DNW.

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

    Strategy in NT7 DNW.

    Works fine in 6.5, and I checked the code breaking changes and can't see anything that would be causing the problem. Any thoughts?

    Code:
     
    #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>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class ChandySARBaseLong830 : Strategy
    {
    #region Variables
    // Wizard generated variables
    private double chandyRounded = 0; // Default setting for ChandyRounded
    private double chandyRemainder = 0; // Default setting for ChandyRemainder
    private double roundUp = 0; // Default setting for RoundUp
    private double roundDown = 0; // Default setting for RoundDown
    // 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>
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    }
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    chandyRounded = Math.Truncate( ChandelierSAR(5, 3.5).Chandelier[0]);
    chandyRemainder = ChandelierSAR(5, 3.5).Chandelier[0] - chandyRounded;
    // Condition set 1
    if (DefaultInput[0] < ChandelierSAR(5, 3.5).Chandelier[0]
    && ToTime(Time[0]) > ToTime(8, 30, 0)
    && ToTime(Time[0]) < ToTime(15, 0, 0))
    {
    roundUp = chandyRemainder <= 0.25 ? chandyRounded + 0.25 : 
    chandyRemainder <= 0.5 ? chandyRounded + 0.5 :
    chandyRemainder <= 0.75 ? chandyRounded + 0.75 :
    chandyRounded +1;
    EnterLongStopLimit(DefaultQuantity, roundUp, roundUp, "");
    Alert("MyAlert0", Priority.High, "", "", 1, Color.White, Color.Black);
    }
    // Condition set 2
    if (DefaultInput[0] > ChandelierSAR(5, 3.5).Chandelier[0]
    && ToTime(Time[0]) > ToTime(8, 30, 0)
    && ToTime(Time[0]) < ToTime(15, 0, 0))
    {
    roundDown = chandyRemainder >= 0.75 ? chandyRounded + 0.75 : 
    chandyRemainder >= 0.5 ? chandyRounded + 0.5 :
    chandyRemainder >= 0.25 ? chandyRounded + 0.25 :
    chandyRounded;
    ExitLongStopLimit(roundDown, roundDown, "", "");
    PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\Alert2.wav");
    }
    // Condition set 3
    if (ToTime(Time[0]) > ToTime(8, 30, 0)
    && ChandelierSAR(5, 3.5).Chandelier[0] < DefaultInput[0]
    && ToTime(Time[0]) < ToTime(8, 31, 0))
    {
    EnterLong(DefaultQuantity, "");
    }
    // Condition set 4
    if (ToTime(Time[0]) >= ToTime(15, 01, 0))
    {
    ExitLong("", "");
    }
    }
    #region Properties
    [Description("")]
    [Category("Parameters")]
    public double ChandyRounded
    {
    get { return chandyRounded; }
    set { chandyRounded = Math.Max(1, value); }
    }
    [Description("")]
    [Category("Parameters")]
    public double ChandyRemainder
    {
    get { return chandyRemainder; }
    set { chandyRemainder = Math.Max(1, value); }
    }
    [Description("")]
    [Category("Parameters")]
    public double RoundUp
    {
    get { return roundUp; }
    set { roundUp = Math.Max(1, value); }
    }
    [Description("")]
    [Category("Parameters")]
    public double RoundDown
    {
    get { return roundDown; }
    set { roundDown = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Do you see any errors in the log tab of the Control Center?

    Is the strategy set to enabled = true as you start it up on the charts for example?

    This is new for NT7 and was not required for NT 6.5 as there were no strategy persistence features yet included.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bingo! Did not see the enabled/disabled option flag. Thank you sir.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by joselube001, 05-10-2024, 12:17 PM
      5 responses
      25 views
      0 likes
      Last Post joselube001  
      Started by bigc0220, 09-18-2018, 09:16 AM
      6 responses
      2,579 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by lorem, 04-25-2024, 09:18 AM
      18 responses
      77 views
      0 likes
      Last Post lorem
      by lorem
       
      Started by DawnTreader, 05-08-2024, 05:58 PM
      21 responses
      81 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by doihaveto13, Today, 12:46 PM
      2 responses
      4 views
      0 likes
      Last Post doihaveto13  
      Working...
      X