-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathA Strategy for Leledec.pine
161 lines (159 loc) · 4.73 KB
/
A Strategy for Leledec.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
Script Name: A Strategy for Leledec
Author: Joy_Bangla
Description: This strategy used Leldec Script from
Then tests what would have happened if one longed or shorted on the major exhaustion.
I used 10% of the initial capital 10,000USD as an example
This is only for educational and entertainment purpose. I do not suggest anyone to use this strategy.
PineScript code:
Pine Script™ strategy
A Strategy for Leledec
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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Joy_Bangla
//@version=4
strategy("A Strategy for Leledec", shorttitle ="Leledec Strategy", overlay=true, commission_value=0.075, initial_capital=10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)
maj = input(true, "Major Leledec Exhausion Bar :: Show")
min=input(false, "Minor Leledec Exhausion Bar :: Show")
leledcSrc = input(close, "Major Leledec Exhausion Bar :: Source")
maj_qual = input(6, "Major Leledec Exhausion Bar :: Bar count no")
maj_len = input(30, "Major Leledec Exhausion Bar :: Highest / Lowest")
min_qual=input(5, "Minor Leledec Exhausion Bar :: Bar count no")
min_len=input(5, "Minor Leledec Exhausion Bar :: Bar count no")
bindexSindex = input(1, "bindexSindex")
closeVal = input(4, "Close")
lele(qual, len) =>
bindex = 0
sindex = 0
bindex := nz(bindex[bindexSindex], 0)
sindex := nz(sindex[bindexSindex], 0)
ret = 0
if close > close[closeVal]
bindex := bindex + 1
bindex
if close < close[closeVal]
sindex := sindex + 1
sindex
if bindex > qual and close < open and high >= highest(high, len)
bindex := 0
ret := -1
ret
if sindex > qual and close > open and low <= lowest(low, len)
sindex := 0
ret := 1
ret
return = ret
return
major = lele(maj_qual, maj_len)
minor=lele(min_qual,min_len)
plotchar(maj ? major == -1 ? high : na : na, char='•', location=location.absolute, color=color.red, transp=0, size=size.large)
plotchar(maj ? major == 1 ? low : na : na, char='•', location=location.absolute, color=color.lime, transp=0, size=size.large)
plotchar(min ? (minor==1?high:na) : na, char='x', location=location.absolute, color=color.red, transp=0, size=size.small)
plotchar(min ? (minor==-1?low:na) : na, char='x', location=location.absolute, color=color.lime, transp=0, size=size.small)
leledecMajorBullish = major==1?low:na
leledecMajorBearish = major==-1?high:na
leledecMinorBullish = minor==1?low:na
leledecMinorBearish = minor==-1?high:na
buySignalBasedOnMajorLeledecOnly = major==1?low:na
sellSignalBasedOnMajorLeldecOnly = minor==-1?high:na
// === INPUT BACKTEST RANGE ===
fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)
fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)
fromYear = input(defval = 2018, title = "From Year", type = input.integer, minval = 2017, maxval = 2030)
thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 11)
thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 30)
thruYear = input(defval = 2030, title = "Thru Year", type = input.integer, minval = 2017, maxval = 2030)
// === INPUT SHOW PLOT ===
showDate = input(defval = true, title = "Show Date Range", type = input.bool)
// === FUNCTION EXAMPLE ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
if (window())
strategy.entry("buy", strategy.long, when=buySignalBasedOnMajorLeledecOnly)
strategy.entry("sell", strategy.short, when=sellSignalBasedOnMajorLeldecOnly)
Expand (84 lines)