protected override void Initialize()
{
Add(RSI45LOW55HIGH(7, 3));
Add(MACD(12, 26, 9));
Add(RSI45LOW55HIGH(7, 3));
Add(MACD(12, 26, 9));
SetProfitTarget("Long Market Entry", CalculationMode.Ticks, 4);
SetStopLoss("Long Market Entry", CalculationMode.Ticks, 8, false);
SetProfitTarget("Short Market Entry", CalculationMode.Ticks, 4);
SetStopLoss("Short Market Entry", CalculationMode.Ticks, 8, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 2)
&& RSI45LOW55HIGH(7, 3).Avg[0] > 45
&& MACD(12, 26, 9).Diff[0] >= 0.1
&& Position.Quantity == 0
&& RSI45LOW55HIGH(7, 3)[0] > RSI45LOW55HIGH(7, 3)[1])
{
EnterLong(DefaultQuantity, "Long Market Entry");
ExitLong("Long Exit", "Long Market Entry");
}
// Condition set 2
if (CrossAbove(MACD(12, 26, 9).Avg, MACD(12, 26, 9), 2)
&& RSI45LOW55HIGH(7, 3).Avg[0] < 55
&& MACD(12, 26, 9).Diff[0] <= -0.1
&& Position.Quantity == 0)
{
EnterShort(DefaultQuantity, "Short Market Entry");
ExitShort("Short Exit", "Short Market Entry");
}
}
Comment