Код:
#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;
//using System.Timers;
#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 A0 : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
//private System.Timers.Timer aTimer;
private IOrder entryOrder = null;
private System.Windows.Forms.Timer aTimer;
///
/// This method is used to configure the strategy and is called once before any strategy method is called.
///
protected override void Initialize()
{
CalculateOnBarClose = true;
//aTimer = new System.Timers.Timer();
aTimer = new System.Windows.Forms.Timer();
aTimer.Interval = 5000;
//aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Tick += new EventHandler(OnTimerTick);
aTimer.Enabled = true;
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
}
protected override void OnTermination()
{
//aTimer.Enabled = false;
//aTimer.Stop();
if (aTimer != null)
{
aTimer.Enabled = false;
aTimer = null;
}
//aTimer.Dispose();
Print("Exit: " + DateTime.Now.ToString());
}
/*
public void OnTimedEvent(object source, ElapsedEventArgs e)
{
DateTime date1 = new DateTime(2008, 5, 1, 8, 30, 52);
Print(DateTime.Now.ToString());
}
*/
private void OnTimerTick(object sender, EventArgs e)
{
Print(DateTime.Now.ToString());
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}