#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 } }
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!
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
NinjaTrader
Strategy in NT7 DNW.
Collapse
X
-
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:Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by stevec1824, Today, 11:00 AM
|
1 response
2 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by sofortune, Today, 10:05 AM
|
2 responses
6 views
0 likes
|
Last Post
by sofortune
Today, 10:58 AM
|
||
Started by sofortune, 05-10-2024, 10:28 AM
|
6 responses
46 views
0 likes
|
Last Post
by sofortune
Today, 10:07 AM
|
||
Started by ETFVoyageur, Today, 08:54 AM
|
3 responses
31 views
0 likes
|
Last Post
by ETFVoyageur
Today, 09:23 AM
|
||
Started by ETFVoyageur, Today, 02:15 AM
|
3 responses
24 views
0 likes
|
Last Post Today, 09:00 AM |
Comment