+1 888 340 6572

Mov Avg X 2-20

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

Download: 2_20ema.ela

File Includes:
Signal - Mov Avg X 2-20
Indicator - Mov Avg X 2-20

Category: Strategy > Derivative Moving Average

Description:

Inputs:

Signal Mov Avg X 2-20 ELA 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}
EXITLONG NEXT BAR AT AVGVAL STOP;
EXITSHORT NEXT BAR AT AVGVAL STOP;

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