Code: Select all
{Sys - 5 Ch Breakout}
{5 Bar Channel breakout with a 45 bar MA trend filter.
Applied on a 60 min intrady Nifty Future.}
inputs: hibar(5), lowbar(5), MovAvg(45), exitbar(18), Tradeunits(8);
vars: ma(0);
{calculate the 45 bar moving average}
ma = Average(close, MovAvg);
{The buy and sell conditions with Moving Average Filter}
if close > ma then buy Tradeunits contracts at highest(high, hibar) stop;
if close < ma then sell Tradeunits contracts at lowest(low, lowbar) stop;
{The Exit conditions}
if marketposition = 1 then exitlong at lowest(low, exitbar) stop;
if marketposition = -1 then exitshort at highest(high, exitbar) stop;
if lastbaronchart then exitlong;
if lastbaronchart then exitshort;