+1 888 340 6572

Mov Avg X 2-20

From MultiCharts

Article/Author: Stocks&Commodities Magazine, Traders Tips, 12/1996

Mov Avg X 2-20 Signal Code:

INPUTS: 
PRICE(CLOSE), 
AVGLEN(20), 
STPPNTS(10);

VARS: 
AVGVAL(0), 
BUYSTP(0), 
SELLSTP(0);

AVGVAL = XAVERAGE(PRICE, AVGLEN);

{BUY/SELL ENTRY SETUP}

IF LOWEST(LOW, 2) > AVGVAL AND LOW 1 BAR AGO CROSSES ABOVE AVGVAL AND MARKETPOSITION <> 1 THEN BEGIN
	BUYSTP = HIGHEST(HIGH, 2) + STPPNTS POINTS;
	CONDITION1 = TRUE;
END;

IF HIGHEST(HIGH, 2) < AVGVAL AND HIGH 1 BAR AGO CROSSES BELOW AVGVAL AND MARKETPOSITION <> -1 THEN BEGIN
	SELLSTP = LOWEST(LOW, 2) -  STPPNTS POINTS;
	CONDITION2 = TRUE;
END;

{BUY/SELL ENTRY ORDERS}

IF LOWEST(LOW, 2) > AVGVAL AND CONDITION1 THEN
	BUY NEXT BAR AT BUYSTP STOP;
IF HIGHEST(HIGH, 2) < AVGVAL AND CONDITION2 THEN
	SELL NEXT BAR AT SELLSTP STOP;

{LONG/SHORT EXITS}

SELL NEXT BAR AT AVGVAL STOP;
BUYTOCOVER NEXT BAR AT AVGVAL STOP;

IF MARKETPOSITION <> 0 THEN BEGIN
	CONDITION1 = FALSE;
	CONDITION2 = FALSE;
END;