SMA = average[10] = (close)
SMA = average[10,0](close)
Ema = average[10,1](close)
https://www.prorealcode.com/documentation/average/
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
defparam drawonlastbaronly = true
if barindex > 30 then
// average!
EMA1 = average [ 20 ,1 ] (close )
//ExponentialAverage!
EMA2 = ExponentialAverage [ 20 ] (close )
// calculated ema
n = 20 // lookback
k = 2 / (n + 1 ) // constant
ema = close [ 0 ] * k + ema[ 1 ] * ( 1 - k ) // 'close'
drawtext ( "EMA1: #EMA1#" ,0 ,0 )anchor (middle ,xshift ,yshift )coloured ("yellow" )
drawtext ( "EMA2: #EMA2#" ,0 ,- 20 )anchor (middle ,xshift ,yshift )coloured ("red" )
drawtext ( "ema : #EMA#" ,0 ,- 40 )anchor (middle ,xshift ,yshift )coloured ("Green" )
endif
return /*
*/ EMA1 coloured ("yellow" )style (line ,5 ) /*
*/ , EMA2 coloured ("red" ) style (dottedline ,3 ) /*
*/ , ema coloured ("Green" ) style (line ,3 )
/**/
1 user thanked author for this post.