Код:
#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
{
///
/// Enter the description of your strategy here
///
[Description("Enter the description of your strategy here")]
public class MyCustomStrategy222 : Strategy
{
#region Variables
// Wizard generated variables
private double price = 0; // Цена с которой сравнивать
private bool up = true; // Напрвление, если выше up = ture, ниже up = false
// User defined variables (add any user defined variables below)
#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;
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
// Condition set 1
if(Up)
if (Close[1] >= price)
{
Alert("MyAlert0", Priority.High, "", @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert1.wav", 0, Color.White, Color.Black);
}
else if(Close[1] <= price)
{
Alert("MyAlert0", Priority.High, "", @"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert1.wav", 0, Color.White, Color.Black);
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public double Price
{
get { return price; }
set { price = Math.Max(0, value); }
}
[Description("")]
[GridCategory("Parameters")]
public bool Up
{
get { return up; }
set { up = value; }
}
#endregion
}
}