Notice from the image that the exits occur below the market. how is this possible?
protected override void Initialize()
{
Add(PeriodType.Minute, timeframe2);
Add(PeriodType.Minute, timeframe3);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Rising(SMA(BarsArray[1],50)) == true
&& MACD(BarsArray[2],12, 26, 9).Avg[0] < MddLowVal
&& Rising(MACD(BarsArray[2],12, 26, 9).Diff) == true
&& CUMRSI(2,3)[0] < rsiLow)
{
EnterLong(DefaultQuantity, "Buy");
}
// Condition set 2
if (Falling(SMA(BarsArray[2],50)) == true)
{
ExitLong("Sell", "Buy");
}
}
#region Properties
[Description("RSI High threshold")]
[GridCategory("Parameters")]
public int RsiHigh
{
get { return rsiHigh; }
set { rsiHigh = Math.Max(1, value); }
}
[Description("RSI Low Threshold")]
[GridCategory("Parameters")]
public int RsiLow
{
get { return rsiLow; }
set { rsiLow = Math.Max(1, value); }
}
[Description("Second timeframe")]
[GridCategory("Parameters")]
public int Timeframe2
{
get { return timeframe2; }
set { timeframe2 = Math.Max(10, value); }
}
[Description("Third timeframe")]
[GridCategory("Parameters")]
public int Timeframe3
{
get { return timeframe3; }
set { timeframe3 = Math.Max(60, value); }
}
[Description("MACD High Value limit")]
[GridCategory("Parameters")]
public int MddHighVal
{
get { return mddHighVal; }
set { mddHighVal = Math.Max(1, value); }
}
[Description("MACD Low Value limit")]
[GridCategory("Parameters")]
public int MddLowVal
{
get { return mddLowVal; }
set { mddLowVal = Math.Max(1, value); }
}
[Description("Swing indicator default parameter")]
[GridCategory("Parameters")]
public int SwingStrength
{
get { return swingStrength; }
set { swingStrength = Math.Max(1, value); }
}
#endregion
}
}
Comment