-
Notifications
You must be signed in to change notification settings - Fork 2
/
ARR-Pivote-India-Stategy.pine
246 lines (245 loc) · 5.74 KB
/
ARR-Pivote-India-Stategy.pine
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
Script Name: ARR-Pivote-India-Stategy
Author: arameshraju
Description: A pivot point strategy for Indian Intraday users
PineScript code:
Pine Script™ strategy
ARR-Pivote-India-Stategy
Copy code
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
134
135
136
137
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © arameshraju
//Reference credit goes to All
//@version=4
strategy("ARR-Pivote-India-Stategy",shorttitle="ARR-PP-Ind", overlay=true)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © arameshraju
//User Input
showPrevDayHighLow = input(false, title="Show previous day's High & Low(PDH/PDL)", type=input.bool)
showPivoteLine = input(true, title="Show Pivot Point(PP)", type=input.bool)
showPivoteR1Line = input(false, title="Show Pivot Point Resistance (R1)", type=input.bool)
showPivoteS1Line = input(false, title="Show Pivot Point Support (S1)", type=input.bool)
showTypicalPriceLine = input(true, title="Show True Price", type=input.bool)
tradeLong = input(true, title="Trade on Long Entry", type=input.bool)
tradeShort = input(false, title="Trade on Short Entry", type=input.bool)
maxLoss = input(0.5, title="Max Loss on one Trade", type=input.float)
tradeOn=input(title="Trade base Level", type=input.string,
options=["PP", "PDH", "PDL","R1","S1"], defval="PP")
closeHrs = input(13, title="Close all trade @ Hours", type=input.integer)
sessSpec = input("0915-1530", title="Session time", type=input.session)
// Defaults
// Colors
cColor = color.black
rColor = color.red
sColor = color.green
// Line style & Transparency
lStyle = plot.style_line
lTransp = 35
// Get High & Low
getSeries(_e, _timeFrame) => security(syminfo.tickerid, _timeFrame, _e, lookahead=barmerge.lookahead_on)
is_newbar(res, sess) =>
t = time(res, sess)
na(t[1]) and not na(t) or t[1] < t
newbar = is_newbar("375", sessSpec)
// Today's Session Start timestamp
y = year(timenow)
m = month(timenow)
d = dayofmonth(timenow)
// Start & End time for Today
start = timestamp(y, m, d, 09, 15)
end = start + 86400000
PrevDayHigh = getSeries(high[1], 'D')
PrevDayLow = getSeries(low[1], 'D')
PrevDayClose = getSeries(close[1], 'D')
PivoteLine=(PrevDayHigh+PrevDayLow+PrevDayClose) /3
PivoteR1=(PivoteLine*2) -PrevDayLow
PivoteS1=(PivoteLine*2) -PrevDayHigh
orbPrevDayOpen = getSeries(open[1], 'D')
orbPrevDayClose = getSeries(close[1], 'D')
//** True Price
TypicalPrice=(high[1]+low[1]+close[1])/3
//Preview Day High line
_pdh = line.new(start, PrevDayHigh, end, PrevDayHigh, xloc.bar_time, color=color.red, style=line.style_solid, width=2)
line.delete(_pdh[1])
_pdl = line.new(start, PrevDayLow, end, PrevDayLow, xloc.bar_time, color=color.green, style=line.style_solid, width=2)
line.delete(_pdl[1])
_Pp = line.new(start, PrevDayLow, end, PrevDayLow, xloc.bar_time, color=color.green, style=line.style_dashed, width=2)
line.delete(_Pp[1])
//Previous Day Low Line
l_pdh = label.new(start, PrevDayHigh, text="PD", xloc=xloc.bar_time, textcolor=rColor, style=label.style_none)
label.delete(l_pdh[1])
l_pdl = label.new(start, PrevDayLow, text="PD", xloc=xloc.bar_time, textcolor=sColor, style=label.style_none)
label.delete(l_pdl[1])
//Pivote Line
l_pp = label.new(start, PivoteLine, text="PP", xloc=xloc.bar_time, textcolor=color.black, style=label.style_none)
label.delete(l_pp[1])
l_R1 = label.new(start, PivoteR1, text="R1", xloc=xloc.bar_time, textcolor=color.fuchsia, style=label.style_none)
label.delete(l_pp[1])
l_SR = label.new(start, PivoteS1, text="S2", xloc=xloc.bar_time, textcolor=color.navy, style=label.style_none)
label.delete(l_pp[1])
plot(showTypicalPriceLine?TypicalPrice:na , title='TP', color=rColor)
plot(showPrevDayHighLow?PrevDayHigh:na , title=' PDH', color=rColor)
plot(showPrevDayHighLow?PrevDayLow:na, title=' PDL', color=sColor)
plot(showPivoteLine?PivoteLine:na, title=' PP', color=color.black)
plot(showPivoteR1Line?PivoteR1:na, title=' R1', color=color.fuchsia)
plot(showPivoteS1Line?PivoteS1:na, title=' S1', color=color.navy)
// Today's Session Start timestamp
// Start & End time for Today
//endTime = timestamp(t, m, d, 15, 00)
tradeEventPrice= if string("PDH")==tradeOn
PrevDayHigh
else if string("PDL")==tradeOn
PrevDayLow
else if string("R1")==tradeOn
PivoteR1
else if string("S1")==tradeOn
PivoteS1
else if string("TR")==tradeOn
TypicalPrice
else
PivoteLine
//tradeEventPrice=PrevDayHigh
if (open < tradeEventPrice) and ( close >tradeEventPrice ) and ( hour < (closeHrs-2) ) and tradeLong
strategy.entry("buy", strategy.long, 1, when=strategy.position_size <= 0)
if (open > tradeEventPrice) and ( close <tradeEventPrice ) and ( hour < (closeHrs-2) ) and tradeShort
strategy.entry("Sell", strategy.short, 1, when=strategy.position_size <= 0)
mxloss=orbPrevDayClose*maxLoss
strategy.exit("exit", "buy", loss = mxloss)
strategy.exit("exit", "Sell", loss = mxloss)
strategy.close_all(when = hour == closeHrs , comment = "close all entries")
Expand (137 lines)