//@version=6
indicator(title="Moving Average Exponential", shorttitle="EMA",
overlay=true, timeframe="", timeframe_gaps=true)
len = input.int(9, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500,
display = display.data_window)
out = ta.ema(src, len)
plot(out, title="EMA", color=color.blue, offset=offset)
// Buy en Sell signalen (1 keer tonen per overgang wanneer de hele
candlestick boven of onder de EMA sluit)
var bool lastBuySignal = false
var bool lastSellSignal = false
buyCondition = ta.barssince(close < out) > 0 and close > out and low >
out and not lastBuySignal
sellCondition = ta.barssince(close > out) > 0 and close < out and high <
out and not lastSellSignal
ma(source, length, MAtype) =>
switch MAtype
"SMA" => ta.sma(source, length)
"SMA + Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// Smoothing MA plots
smoothingMA = enableMA ? ma(out, maLengthInput, maTypeInput) : na
smoothingStDev = isBB ? ta.stdev(out, maLengthInput) * bbMultInput : na
plot(smoothingMA, "EMA-based MA", color=color.yellow, display =
enableMA ? display.all : display.none, editable = enableMA)
bbUpperBand = plot(smoothingMA + smoothingStDev, title = "Upper
Bollinger Band", color=color.green, display = isBB ? display.all :
display.none, editable = isBB)
bbLowerBand = plot(smoothingMA - smoothingStDev, title = "Lower
Bollinger Band", color=color.green, display = isBB ? display.all :
display.none, editable = isBB)
fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) :
na, title="Bollinger Bands Background Fill", display = isBB ? display.all :
display.none, editable = isBB)