Mov Avg - Supp/Res
From MultiCharts
Article/Author: "Simple Moving Average with Resistance & Support", Dennis L. Tilley, S&C Magazine, Traders Tips, 09/1998
Mov Avg - Supp/Res Signal Code:
INPUTS:
PRICE(CLOSE),
LENGTH(10), F(8);
VARS:
AVGVAL(0),
S(0),
R(0),
SC(0),
RC(0);
AVGVAL = AVERAGE(PRICE, LENGTH);
RC = RC + 1;
SC = SC + 1;
IF CURRENTBAR > 1 THEN BEGIN
IF CLOSE CROSSES BELOW AVGVAL AND CLOSE > S* (1+(F/100)) AND R <> 0 THEN BEGIN
SELL NEXT BAR AT MARKET;
S = LOW;
SC = 0;
END
ELSE BEGIN
IF CLOSE CROSSES BELOW S AND R <> 0 THEN BEGIN
SELL NEXT BAR AT MARKET;
S = LOW;
SC = 0;
END;
END;
IF CLOSE CROSSES ABOVE AVGVAL AND CLOSE < R / (1+(F/100)) AND S <> 0 THEN BEGIN
BUY NEXT BAR AT MARKET;
R = HIGH;
RC = 0;
END
ELSE BEGIN
IF CLOSE CROSSES ABOVE R AND S <> 0 THEN BEGIN
BUY NEXT BAR AT MARKET;
R = HIGH;
RC = 0;
END;
END;
IF CLOSE > AVGVAL THEN BEGIN
IF HIGH >= R THEN BEGIN
R = HIGH;
RC = 0;
END;
END;
IF CLOSE < AVGVAL THEN BEGIN
IF LOW <= S OR S = -1 THEN BEGIN
S = LOW;
SC = 0;
END;
END;
END;