// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// buy high, sell low
/// </summary>
[Description("buy high, sell low")]
public class marco : Strategy
{
#region Variables
// Wizard generated variables
// 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 = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (SMA(14)[1] > SMA(14)[2]
&& Close[2] > Open[2]
&& Close[1] < Open[1]
&& Low[0] > Low[1]
&& GetCurrentAsk() == High[1])
{
EnterLong(DefaultQuantity, "long");
}
// Condition set 2
if (SMA(14)[1] < SMA(14)[2]
&& Close[2] < Open[2]
&& Close[1] > Open[1]
&& High[0] < High[1]
&& GetCurrentBid() == Low[1])
{
EnterShort(DefaultQuantity, "");
}
// Condition set 3
if (GetCurrentBid() == Low[1])
{
ExitLong("stoploss", "");
}
// Condition set 4
if (GetCurrentAsk() == High[1])
{
ExitShort("stoploss", "");
}
}
Comment