-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource-Code
More file actions
133 lines (105 loc) · 6.65 KB
/
Source-Code
File metadata and controls
133 lines (105 loc) · 6.65 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zeubetella
//@version=5
indicator("RISOTTO", overlay = false)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rsi_group = "RSI Parameters"
var_group = "VAR Parameters"
ott_group = "OTT Parameters"
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
X1 = input(100, title = "RSI Length", group = rsi_group)
X2 = input(50, title = "VAR Length", group = var_group)
X4 = input(30, title = "OTT Period", group = ott_group)
X3 = input(0.2, title = "OTT Percent", group = ott_group)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//#region VAR
f_var(data,u1) =>
a = 9
b = data > data[1] ? data - data[1] : 0
c = data < data[1] ? data[1] - data : 0
d = math.sum(b , a)
e = math.sum(c , a)
f = nz((d - e) / (d + e))
g = math.abs(f)
h = 2 / (u1 + 1)
x = ta.sma(data , u1)
vidya = 0.0
vidya :=
u1==1 ? data : na(vidya[1]) ? x :
g * h * (data - nz(vidya[1])) + nz(vidya[1])
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//#endregion VAR
//#region OTT
OTT(source, length, percent) =>
MAVG = f_var(source, length)
fark = MAVG * percent * 0.01
longStop = MAVG - fark
longStopPrev = nz(longStop[1], longStop)
longStop := MAVG > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = MAVG + fark
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := MAVG < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and MAVG > shortStopPrev ? 1 : dir == 1 and MAVG < longStopPrev ? -1 : dir
MT = dir == 1 ? longStop : shortStop
OTT = MAVG > MT ? MT * (200 + percent) / 200 : MT * (200 - percent) / 200
out = nz(OTT[2])
//#endregion OTT
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot1 = f_var(ta.rsi(close,X1),X2) + 1000
plot2 = OTT(f_var(ta.rsi(close,X1),X2) + 1000 , X4, X3)
plot(plot1, color= color.new(#1fe5ff, 0), title = "SUPPORT")
plot(plot2, color= color.rgb(217, 0, 255), title = "RISOTTO")
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bar_cond0 = ta.barssince(ta.crossover(plot2 , plot1))
bar_cond1 = ta.barssince(ta.crossunder(plot2 , plot1))
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
rawNumberforTable1 = 5
//
var string TableGroup1 = "Table | Settings"
//
string Table1PosInYaxis = input.string("bottom",
title = "Table Position",
inline = "1",
options = ["top", "middle", "bottom"],
group = TableGroup1)
//
string Table1PosInXaxis = input.string("right",
" / ",
inline = "1",
options = ["left", "center", "right"],
group = TableGroup1)
//
var table table1 = table.new(Table1PosInYaxis + "_" + Table1PosInXaxis,
2,
rawNumberforTable1 + 1,
frame_color = color.rgb(0, 0, 0),
frame_width = 1,
border_color = color.rgb(0, 0, 0),
border_width = 1)
//
textstyleFORtable1 = input.string(size.small,
"Text Size",
options=[size.small, size.normal, size.large],
group = TableGroup1)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if plot1 > plot2
table.cell(table1, 0, 0, "BUY", text_halign = text.align_center, text_size = textstyleFORtable1, bgcolor = color.white)
if plot1 < plot2
table.cell(table1, 0, 0, "SELL", text_halign = text.align_center, text_size = textstyleFORtable1, bgcolor = color.yellow)
//
if plot1 > plot2
table.cell(table1, 0, 1, str.tostring(bar_cond1) + " Candle", text_halign = text.align_center, text_size= textstyleFORtable1, bgcolor = color.white)
if plot1 < plot2
table.cell(table1, 0, 1, str.tostring(bar_cond0) + " Candle", text_halign = text.align_center, text_size= textstyleFORtable1, bgcolor = color.yellow)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// @dg_factor hocama katkısınndan ötürü teşekkür ederim.
// thank you to Mr. @dg_factor for his contribution.
// Giriş Sinyalleri
signals = input.bool(defval=true, title="Signals")
plotshape(signals ? bar_cond1==0 ? plot1 : na : na, title='BUY', text='BUY', location=location.absolute, style=shape.circle, size=size.tiny, color=#00ff00, textcolor=#00ff00, editable=false)
plotshape(signals ? bar_cond0==0 ? plot2 : na : na, title='SELL', text='SELL', location=location.absolute, style=shape.circle, size=size.tiny, color=#ff0000, textcolor=#ff0000, editable=false)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// kod bitiş, afiyet olsun.
// end of the code, bon appetit.