-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathmr mani.lua
More file actions
69 lines (56 loc) · 2.3 KB
/
mr mani.lua
File metadata and controls
69 lines (56 loc) · 2.3 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
instrument { name = "Vdubs Mr Mani", overlay = true, icon="indicators:ATR" }
input_group {
"front.ind.dpo.generalline",
up_color = input { default = "#58FF44", type = input.color },
down_color = input { default = "#57A1D0", type = input.color },
width = input { default = 1, type = input.line_width }
}
fn = input (averages.ema, "front.newind.average", input.string_selection, averages.titles)
local avg = averages [fn]
--ema signal 1
src0 = close
len0 = 13
ema0 = ema(src0, len0)
rising1 = ema0[0] > ema0[1] and ema0[1] > ema0[2]
falling1 = ema0[2] > ema0[1] and ema0[1] > ema0[0]
--
direction = iff(rising1, 1,iff(falling1, -1, 0 ))
plot_color = iff(direction > 0 , up_color,iff( direction < 0, down_color , na))
plot(ema0, 'EMA', plot_color , width, -1, style.solid_line, na_mode.continue)
--ema signal 2
src02 = close
len02 = 21
ema02 = ema(src02, len02)
rising2 = ema02[0] > ema02[1] and ema02[1] > ema02[2]
falling2 = ema02[2] > ema02[1] and ema02[1] > ema02[0]
direction2 = iff(rising2, 1,iff(falling2, -1, 0 ))
plot_color2 = iff(direction2 > 0 , up_color,iff( direction2 < 0, down_color , na))
plot(ema02, 'EMA Signal 2', plot_color2 , width, -1, style.solid_line, na_mode.continue)
--ema signal out
fast = 5
slow = 8
avg0 = (low + close)/2
avg1 = (high + close)/2
vh1 = ema(highest(avg0, fast), 5)
vl1 = ema(lowest(avg1, slow), 8)
--print(vl1)
e_ema1 = ema(close, 1)
e_ema2 = ema(e_ema1, 1)
e_ema3 = ema(e_ema2, 1)
tema = 1 * (e_ema1 - e_ema2) + e_ema3
--print(tema)
e_e1 = ema(close, 8)
e_e2 = ema(e_e1, 5)
dema = 2 * e_e1 - e_e2
--print(dema)
signal = iff(tema > dema , max (vh1, vl1) , min (vh1, vl1))
--print(signal)
is_call = tema > dema and signal > low and (signal-signal[1] > signal[1]-signal[2])
is_put = tema < dema and signal < high and (signal[1]-signal > signal[2]-signal[1])
period = 30
plot_shape(iff(is_call and direction > 0 , 1, na), "long", shape_style.triangleup, shape_size.large, 'green', shape_location.belowbar,0,'BUY', 'green')
plot_shape(iff(is_put and direction < 0, 1, na) , "short", shape_style.triangledown, shape_size.large, 'red', shape_location.abovebar,0,'SELL', 'red')
plot (hma (src0, period), "HMA", '#FF00FF', 2)
--
--vh1 = ema(highest(avg(low, close), fast), 5)
--vl1 = ema(lowest(avg(high, close), slow), 8)