-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathethiopia.pine
80 lines (52 loc) · 2.12 KB
/
ethiopia.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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mojomajor
//@version=4
// Thomas Ranker
strategy("EthioFibSma", overlay=true, default_qty_type=strategy.percent_of_equity, pyramiding=0,default_qty_value=50, initial_capital=5000, currency='EUR', slippage=1, commission_type=strategy.commission.percent, commission_value=0.05)
// 0,1,2,3,5,8,13,21,34,55
range1 = 21
range2 = 34
range3 = 55
shapeSize = 10
green = #078930
yellow = #fcdd09
red = #da121a
sma1 = sma(close,range1)
sma2 = sma(close,range2)
sma3 = sma(close,range3)
plot(sma1,color=green, linewidth=1)
plot(sma2, color=yellow, linewidth=2)
plot(sma3, color=red, linewidth=3)
myrsi = rsi(close, range3)
//plot(myrsi)
smaTolerancePc = 1.05
isunderlongsma = close <= sma3 * smaTolerancePc
isoverlongsma = close >= sma3 * (2-smaTolerancePc)
isoverbought = myrsi > 60
isoversold = myrsi < 40
// closes higher than day before
rising = close[1]>close
falling = close[1]<close
// opens higher that the day before
bear = open>open[1]
bull = open<open[1]
body_bottom = close<open ? close : open
body_top = close>open ? close : open
upper_wick_length = high - body_top
body_length = body_top - body_bottom
lower_wick_length = low - body_bottom
//longlowerwick = low-
longCondition = crossover(sma1, sma2) and isunderlongsma
plotshape(longCondition,title="long",text='long',color=#ffffff, style=shape.arrowup,location=location.belowbar)
plotarrow(longCondition ? 1 : na, colorup=green, colordown=red, transp=40)
strategy.risk.max_drawdown(50, strategy.percent_of_equity)
// other exit trade: close price under some sma
otherShortCondition = close < sma3
shortCondition = (crossunder(sma1, sma2) and isoverlongsma) or otherShortCondition
//plotshape(shortCondition,title="short",text='short',color=#ffffff, style=shape.arrowdown,location=location.abovebar)
//plotarrow(shortCondition ? -1 : na, colorup=green, colordown=red, transp=40)
if (longCondition)
strategy.entry("Long Entry", strategy.long)
if (shortCondition)
strategy.close("Long Entry", shortCondition)
//strategy.entry("Short Entry", strategy.short)