The entry criteria is something like this:
If today's closing price > SMA(21)
&
If weekly MACD is already in a crossover
In eSignal, writing the code was pretty simple like this:
Code: Select all
xSMA = sma(21);
var nSma = xSMA.getValue(0);
weeklyMacd = macd(8, 16, 11,inv("W"));
weeklyMacdSignal = macdSignal(8, 16, 11,inv("W"));
if(weeklyMacdSignal.getValue(0) < weeklyMacd.getValue(0))
{
if(Strategy.isLong() == false && close(0) >= nSma) {
Strategy.doLong("Long", Strategy.MARKET , Strategy.NEXTBAR, 100);
}
}
Now I can't figure out how to calculate weekly MACD in MC just like these lines are doing:
Code: Select all
weeklyMacd = macd(8, 16, 11,inv("W"));
weeklyMacdSignal = macdSignal(8, 16, 11,inv("W"));