{
SetStopLoss("", CalculationMode.Ticks, StopLoss, false);
CalculateOnBarClose = true;
++Variable1;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] > Open[0]
&& Close[0] > EMA(EMA1)[0]
&& Open[0] < EMA(EMA1)[0]
&& Position.MarketPosition == MarketPosition.Flat
&& Open[0] < EMA(EMA2)[0]
&& Close[0] > EMA(EMA2)[0]
&& Open[0] < EMA(EMA3)[0]
&& Close[0] > EMA(EMA3)[0]
&& Variable1 < Fail_Times)
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (BarsSinceEntry() > WaitUntil
&& Close[1] < EMA(14)[1]
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong("", "");
}
// Condition set 3
if (Close[0] < EMA(EMA1)[0]
&& Open[0] > EMA(EMA1)[0]
&& Position.MarketPosition == MarketPosition.Flat
&& Open[0] > EMA(EMA2)[0]
&& Close[0] < EMA(EMA2)[0]
&& Open[0] > EMA(EMA3)[0]
&& Close[0] < EMA(EMA3)[0]
&& Close[0] < Open[0]
&& Variable1 < Fail_Times)
{
EnterShort(DefaultQuantity, "");
}
// Condition set 4
if (BarsSinceEntry() > WaitUntil
&& Close[1] > EMA(14)[1]
&& Position.MarketPosition == MarketPosition.Short)
{
ExitShort("", "");
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int LookBack
{
get { return lookBack; }
set { lookBack = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int WaitUntil
{
get { return waitUntil; }
set { waitUntil = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int EMA1
{
get { return eMA1; }
set { eMA1 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int EMA2
{
get { return eMA2; }
set { eMA2 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int StopLoss
{
get { return stopLoss; }
set { stopLoss = Math.Max(100, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int EMA3
{
get { return eMA3; }
set { eMA3 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Fail_Times
{
get { return fail_Times; }
set { fail_Times = Math.Max(2, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int EMALength
{
get { return eMALength; }
set { eMALength = Math.Max(10, value); }
}
#endregion
}
}
Comment