Double Exponential Moving Average 8-20-63 Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Noldo

//@version=4
//Quoted by Author HighProfit

//Lead-In
strategy("Double Exponential Moving Average 8-20-63 Strategy", 
         shorttitle="DEMA-8-20-63", 
         overlay=true,
         max_bars_back = 5000,
         initial_capital=100000, 
         max_bars_back = 5000,
         default_qty_type=strategy.percent_of_equity, 
         default_qty_value=100, 
         commission_type=strategy.commission.percent, 
         commission_value=0.1,
         pyramiding = 0)

short = input(8, minval=1)
srcShort = input(ohlc4, title="Source Dema 1")

long = input(20, minval=1)
srcLong = input(low, title="Source Dema 2")

long2 = input(63, minval=1)
srcLong2 = input(close, title="Source Dema 3")
e1 = ema(srcShort, short)
e2 = ema(e1, short)
dema1 = 2 * e1 - e2
plot(dema1, color=color.green, linewidth=2)

e3 = ema(srcLong, long)
e4 = ema(e3, long)
dema2 = 2 * e3 - e4
plot(dema2, color=color.blue, linewidth=2)

e5 = ema(srcLong2, long2)
e6 = ema(e5, long2)
dema3 = 2 * e5 - e6
plot(dema3, color=color.black, linewidth=2)

longC  = dema1 > dema2 and dema1 > dema3
shortC = dema1 < dema2 and dema1 < dema3 

alertlong  = longC and  not longC[1]
alertshort = shortC and not shortC[1]


strategy.entry("Long" , strategy.long , when = longC ,comment="Long")
strategy.entry("Short", strategy.short, when = shortC,comment="Short")

// Alerts 

alertcondition(longC  , title='Long' , message=' Buy  Signal ')
alertcondition(shortC , title='Short', message=' Sell Signal ')

