#region Using declarations using System; using System.IO; 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 { /// /// Enter the description of your strategy here /// [Description("Enter the description of your strategy here")] public class TEST01 : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) private const string testFile = "F:\\Program Files (x86)\\NinjaTrader 7\\SP500_Futures.txt"; #endregion /// /// This method is used to configure the strategy and is called once before any strategy method is called. /// protected override void Initialize() { CalculateOnBarClose = true; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); } /// /// Called on each bar update event (incoming tick) /// protected override void OnBarUpdate() { string str; StreamWriter sw = new StreamWriter( testFile, true ); DateTime now = DateTime.Now; double currentAsk = GetCurrentAsk(); double currentBid = GetCurrentBid(); double currentAskVolume = GetCurrentAskVolume(); double currentBidVolume = GetCurrentBidVolume(); /* str = String.Format( "{0}{1}{2},{3}{4}{5},{6},0,1,1,Sell,{7},{8},10", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond, currentAsk, currentBid ); */ str = now.Year.ToString(); if( now.Month < 10 ) str = str + "0" + now.Month.ToString(); else str = str + now.Month.ToString(); if( now.Day < 10 ) str = str + "0" + now.Day.ToString() + ","; else str = str + now.Day.ToString() + ","; if( now.Hour < 10 ) str = str + "0" + now.Hour.ToString(); else str = str + now.Hour.ToString(); if( now.Minute < 10 ) str = str + "0" + now.Minute.ToString(); else str = str + now.Minute.ToString(); if( now.Second < 10 ) str = str + "0" + now.Second.ToString() + ","; else str = str + now.Second.ToString() + ","; if( now.Millisecond < 10 ) str = str + "00" + now.Millisecond.ToString() + ","; else if( 10 <= now.Millisecond && now.Millisecond < 100 ) str = str + "0" + now.Millisecond.ToString() + ","; else str = str + now.Millisecond.ToString() + ","; str = str + "0,1,1,Sell," + currentAsk.ToString() + "," + currentBid.ToString() + ",10"; sw.Flush(); sw.WriteLine( str ); sw.Close(); } #region Properties [Description("")] [GridCategory("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion } }