forked from hwrdprkns/ThinkOrSwim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPriceTrendSTUDY.ts
45 lines (36 loc) · 1.39 KB
/
PriceTrendSTUDY.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
34
35
36
37
38
39
40
41
42
43
44
45
# PRICETREND
# DREWGRIFFITH15 (C) 2014
DECLARE UPPER;
INPUT TRAIL = 1;
INPUT DISPLACE = 1;
INPUT AGGREGATIONPERIOD = AGGREGATIONPERIOD.DAY;
DEF NEW_HIGH = CLOSE > HIGHEST(HIGH(PERIOD = AGGREGATIONPERIOD), TRAIL)[DISPLACE];
DEF NEW_LOW = CLOSE < LOWEST(LOW(PERIOD = AGGREGATIONPERIOD), TRAIL)[DISPLACE];
DEF GREENPRICE = IF NEW_HIGH THEN YES ELSE IF NEW_LOW THEN NO ELSE NEW_HIGH[1];
DEF REDPRICE = IF NEW_LOW THEN YES ELSE IF NEW_HIGH THEN NO ELSE NEW_LOW[1];
PLOT BULLISH = GREENPRICE;
PLOT NEUTRAL = !GREENPRICE AND !REDPRICE;
PLOT BEARISH = REDPRICE;
PLOT RATING =
IF GREENPRICE THEN 1
ELSE IF REDPRICE THEN .5
ELSE 0;
DEF PAINTBARS = YES;
BULLISH.SETDEFAULTCOLOR(COLOR.UPTICK);
BULLISH.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.BOOLEAN_POINTS);
BULLISH.SETLINEWEIGHT(3);
BULLISH.HIDE();
NEUTRAL.SETDEFAULTCOLOR(COLOR.GRAY);
NEUTRAL.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.BOOLEAN_POINTS);
NEUTRAL.SETLINEWEIGHT(3);
NEUTRAL.HIDE();
BEARISH.SETDEFAULTCOLOR(COLOR.DOWNTICK);
BEARISH.SETPAINTINGSTRATEGY(PAINTINGSTRATEGY.BOOLEAN_POINTS);
BEARISH.SETLINEWEIGHT(3);
BEARISH.HIDE();
RATING.Hide();
RATING.HideBubble();
DEFINEGLOBALCOLOR("BULLISH", COLOR.UPTICK);
DEFINEGLOBALCOLOR("NEUTRAL", COLOR.GRAY);
DEFINEGLOBALCOLOR("BEARISH", COLOR.DOWNTICK);
ASSIGNPRICECOLOR(IF !PAINTBARS THEN COLOR.CURRENT ELSE IF GREENPRICE THEN GLOBALCOLOR("BULLISH") ELSE IF REDPRICE THEN GLOBALCOLOR("BEARISH") ELSE GLOBALCOLOR("NEUTRAL"));