-
Notifications
You must be signed in to change notification settings - Fork 47
/
ExitAlertSTUDY.ts
33 lines (27 loc) · 924 Bytes
/
ExitAlertSTUDY.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# EXITALERT
# DREWGRIFFITH15 (C) 2015
# RSI2 will be used to determine exit.
# Even on a loss, the RSI indicates a lower high sell point.
# I see this as selling at a high for a stop loss.
# 75 for long / 25 for short for Daily chart
# 90 for long / 10 for short for 15min chart
# 85 for long / 15 for short for 30min chart
input side = {DEFAULT LONG, SHORT};
input target = 75;
input rsi_length = 2;
input price = close;
# RSI
def NETCHGAVG = WildersAverage(price - price[1], rsi_length);
def TOTCHGAVG = WildersAverage(AbsValue(price - price[1]), rsi_length);
def CHGRATIO = if TOTCHGAVG != 0 then NETCHGAVG / TOTCHGAVG else 0;
def RSI = Round(50 * (CHGRATIO + 1), NUMBEROFDIGITS = 0);
DEF LMT;
SWITCH (SIDE) {
CASE LONG:
LMT = RSI >= TARGET;
CASE SHORT:
LMT = RSI <= TARGET;
}
PLOT EXIT = LMT;
EXIT.SETDEFAULTCOLOR(CREATECOLOR(255, 255, 255));
EXIT.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.BOOLEAN_ARROW_DOWN);