-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMovingAverage.pinescript
More file actions
130 lines (112 loc) · 5.16 KB
/
MovingAverage.pinescript
File metadata and controls
130 lines (112 loc) · 5.16 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
//@version=5
//=============================================================================================
// Creator: Woverine
//
// Source Code: https://github.com/RyKaj/PineScript/tree/main
//
// Purpose:
// Ability to toggle and customize colour display
// - SMA 20, 50, 100, 200, 500
// - ESMA 20, 50, 100, 200, 500
// - Golden Cross (SMA 50 & 200 )
// - Death Cross (SMA 50 & 200 )
// - SMA Trendline
// - EMA Trendline
//
//=============================================================================================
indicator(title='Wonverine - Lines', shorttitle='MA', overlay=true)
// Plot colors
// https://chir.ag/projects/name-that-color/#6195ED
// https://kodify.net/tradingview/colours/basic-colours/
// color colorAquaIsland = #B2DFDB
// color colorAzureRadiance = #0094ff
// color colorBlack = #363A45
color colorBlazeOrange = #ff6a00
color colorBlue = #2196F3
color colorBlueChill = #088A8D
// color colorBlushPink = #fd7fe6
// color colorBurntSienna = #EF5350
// color colorCandelLight = #FCD917
color colorCoral = #FF7F50
// color colorCyan = #17FFFF
color colorDeathCross = #e32636
// color colorFreshEggplant = #800080
color colorFruitSalad = #4CAF50
color colorGoldenCross = #61ed77
// color colorGoldenCross = #61ed77
// color colorJapaneseLaurel = #008000
// color colorGreen = #4CAF50
color colorJungleGreen = #39ff14
// color colorKeyLimePie = #BCBB26
color colorLilacBush = #9575cd
// color colorLime = #00E676
// color colorParsley = #0E4813
// color colorPastelPink = #FFCDD2
// color colorPurple = #9C27B0
color colorRed = #FF5252
// color colorRobinEggBlue = #00C9C9
color colorRoseBudCherry = #880e4f
// color colorRusticRed = #4E0404
color colorSaratoga = #505010
// color colorSpringGreen = #00E676
// color colorStarship = #F2F131
// color colorTamarillo = #991515
// color colorTeal = #00897B
// color colorTealBlue = #055355
// color colorTrendyGreen = #86851b
// color colorWhite = #FFFFFF
color colorYellow = #ffff00
// Durations
int days20 = 20
int days50 = 50
int days100 = 100
int days200 = 200
int days500 = 500
// Simple Moving Average
float sma20 = ta.sma( close, days20 )
float sma50 = ta.sma( close, days50 )
float sma100 = ta.sma( close, days100 )
float sma200 = ta.sma( close, days200 )
float sma500 = ta.sma( close, days500 )
// Expodental Moving Average
float ema20 = ta.ema( close, days20 )
float ema50 = ta.ema( close, days50 )
float ema100 = ta.ema( close, days100 )
float ema200 = ta.ema( close, days200 )
float ema500 = ta.ema( close, days500 )
plot( sma20, color=color.new( colorFruitSalad, transp=0 ), title='SMA(20)' )
plot( sma50, color=color.new( colorYellow, transp=0 ), title='SMA(50)' )
plot( sma100, color=color.new( colorBlueChill, transp=0 ), title='SMA(100)' )
plot( sma200, color=color.new( colorRed, transp=0 ), title='SMA(200)' )
plot( sma500, color=color.new( colorRoseBudCherry, transp=0 ), title='SMA(500)' )
plot( ema20, color=color.new( colorBlueChill, transp=0 ), title='EMA20' )
plot( ema50, color=color.new( colorBlazeOrange, transp=0 ), title='EMA50' )
plot( ema100, color=color.new( colorLilacBush, transp=0 ), title='EMA100' )
plot( ema200, color=color.new( colorSaratoga, transp=0 ), title='EMA200' )
plot( ema500, color=color.new( colorCoral, transp=0 ), title='EMA500' )
//--------------------------------------------------------------------------------
// SMA Cross
//--------------------------------------------------------------------------------
// Golden Cross
plot( ta.crossover( sma50, sma200 ) ? sma200 : na, title='SMA Golden Cross', style=plot.style_cross, color=color.new( colorGoldenCross, transp=0 ), linewidth=5 )
// Death Cross
plot( ta.crossover( sma200, sma50 ) ? sma50 : na, title='SMA Death Cross', style=plot.style_cross, color=color.new( colorDeathCross, transp=0 ), linewidth=5 )
//--------------------------------------------------------------------------------
// EMA Death Cross
//--------------------------------------------------------------------------------
// Golden Cross
plot( ta.crossover( ema50, ema200 ) ? ema200 : na, title='EMA Golden Cross', style=plot.style_cross, color=color.new( colorGoldenCross, transp=0 ), linewidth=5 )
// Death Cross
plot( ta.crossover( ema200, ema50 ) ? ema50 : na, title='EMA Death Cross', style=plot.style_cross, color=color.new( colorDeathCross, transp=0 ), linewidth=5 )
//--------------------------------------------------------------------------------
// Trend color ema
// ema trend direction trigger For Singals 1 & 2
//--------------------------------------------------------------------------------
var smaPlot = input( true, title='Show SMA on chart' )
float smaLength = ta.sma( close, input.int( 8, minval=1, title='SMA Length' ) )
color smaColor = smaLength > smaLength[1] ? colorJungleGreen : smaLength < smaLength[1] ? colorRed : colorBlue
plot( smaLength and smaPlot ? smaLength : na, title='SMA Trend', color=smaColor, linewidth=1 )
var emaPlot = input( true, title='Show EMA on chart' )
float emaLength = ta.ema( close, input.int(8, minval=1, title='EMA Length' ) )
color emaColor = emaLength > emaLength[1] ? colorJungleGreen : emaLength < emaLength[1] ? colorRed : colorBlue
plot( emaLength and emaPlot ? emaLength : na, title='EMA Trend', color=emaColor, linewidth=1 )