Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

[ad_1]
//==========================
// input
//==========================
fastEMA = input.int(9, “Fast EMA”)
SlowEMA = input.int(21, “SlowEMA”)
trendEMA = input.int(200, “TrendEMA”)
rsiLen = input.int(14, “RSI length”)
atrLen = input.int(14, “ATR length”)
useVWAP = input.bool(true, “Use VWAP filter”)
useATR = input.bool(true, “Use ATR filter”)
minATR = input.float(0.20, “MinATR”, step=0.01)
slATR = input.float(1.0, “SL ATR multiplier”, step=0.1)
tp1ATR = input.float(1.0, “TP1 ATR multiplier”, step=0.1)
tp2ATR = input.float(2.0, “TP2 ATR multiplier”, step=0.1)
tp3ATR = input.float(3.0, “TP3 ATR multiplier”, step=0.1)
showEMA = input.bool(true, “Show EMA”)
showLevels = input.bool(true, “Show take profit/stop loss levels”)
//==========================
// calculate
//==========================
emaFast = ta.ema(off, fastEMA)
emaSlow = ta.ema(Close, SlowEMA)
emaTrend = ta.ema(closing price, trendEMA)
rsiVal = ta.rsi(off, rsiLen)
atrVal = ta.atr(atrLen)
vwapVal = ta.vwap(close)
//==========================
// filter
//==========================
bullTrend = closing price > emaTrend and emaFast > emaSlow
bearTrend = closing price < emaTrend and emaFast < emaSlow
vwapBull = off > vwapVal
vwapBear = close < vwapVal
atrOK = atrVal >= minATR
buySignal = bullTrend and ta.crossover(emaFast, emaSlow) and rsiVal > 55 and (not using VWAP or vwapBull) and (not using ATR or atrOK)
sellSignal = bearTrend and ta.crossunder(emaFast, emaSlow) and rsiVal < 45 and (without using VWAP or vwapBear) and (without using ATR or atrOK)
//==========================
//level variable
//==========================
var float item price = na
var floating stop = na
var float take1 = na
var float take2 = na
var float take3 = na
var line entryLine = na
var line slLine = na
var line tp1Line = na
var line tp2Line = na
var line tp3Line = na
var tag entryLbl = na
var label slLbl = na
Variable label tp1Lbl = na
var tag tp2Lbl = na
var tag tp3Lbl = na
//==========================
// Clear old drawings
//==========================
cleardraw() =>
if not na(entryLine)
row.delete(entryLine)
if not na(slLine)
line.delete(slLine)
if not na(tp1Line)
line.delete(tp1Line)
if not na(tp2Line)
line.delete(tp2Line)
if not na(tp3Line)
line.delete(tp3Line)
if not na(entryLbl)
tag.delete(entryLbl)
if not na(slLbl)
label.delete(slLbl)
if not na(tp1Lbl)
tag.delete(tp1Lbl)
if not na(tp2Lbl)
tag.delete(tp2Lbl)
if not na(tp3Lbl)
tag.delete(tp3Lbl)
//==========================
//Create buy levels
//==========================
If buy signal
cleardraw()
Entry Price:= Close
Stop Loss:= Entry Price- (atrVal * slATR)
take1 := entrance price + (atrVal * tp1ATR)
take2 := entrance price + (atrVal * tp2ATR)
take3 := entrance price + (atrVal * tp3ATR)
If display level
EntryLine := line.new(bar_index,entryPrice,bar_index + 20,entryPrice,extend=extend.none,width=2)
slLine := line.new(bar_index, stopLoss, bar_index + 20, stopLoss,extend=extend.none, width=2)
tp1Line := line.new(bar_index, take1, bar_index + 20, take1,extend=extend.none, width=2)
tp2Line := line.new(bar_index, take2, bar_index + 20, take2,extend=extend.none, width=2)
tp3Line := line.new(bar_index, take3, bar_index + 20, take3,extend=extend.none, width=2)
EntryLbl := label.new(bar_index + 20, EntryPrice, “Buy”, style=label.style_label_left, textcolor=color.white, color=color.new(color.green, 0))
slLbl := label.new(bar_index + 20, stopLoss, “SL”, style=label.style_label_left, textcolor=color.white, color=color.new(color.red, 0))
tp1Lbl := label.new(bar_index + 20, take1, “TP1”, style=label.style_label_left, textcolor=color.white, color=color.new(color.blue, 0))
tp2Lbl := label.new(bar_index + 20, take2, “TP2”, style=label.style_label_left, textcolor=color.white, color=color.new(color.blue, 0))
tp3Lbl := label.new(bar_index + 20, take3, “TP3”, style=label.style_label_left, textcolor=color.white, color=color.new(color.blue, 0))
//==========================
// Create sell levels
//==========================
If sell signal
cleardraw()
Entry Price:= Close
Stop Loss:= Entry Price + (atrVal * slATR)
take1 := EntryPrice – (atrVal * tp1ATR)
take2 := Entry price- (atrVal * tp2ATR)
take3 := EntryPrice – (atrVal * tp3ATR)
If display level
EntryLine := line.new(bar_index,entryPrice,bar_index + 20,entryPrice,extend=extend.none,width=2)
slLine := line.new(bar_index, stopLoss, bar_index + 20, stopLoss,extend=extend.none, width=2)
tp1Line := line.new(bar_index, take1, bar_index + 20, take1,extend=extend.none, width=2)
tp2Line := line.new(bar_index, take2, bar_index + 20, take2,extend=extend.none, width=2)
tp3Line := line.new(bar_index, take3, bar_index + 20, take3,extend=extend.none, width=2)
EntryLbl := label.new(bar_index + 20, EntryPrice, “SELL”, style=label.style_label_left, textcolor=color.white, color=color.new(color.red, 0))
slLbl := label.new(bar_index + 20, stopLoss, “SL”, style=label.style_label_left, textcolor=color.white, color=color.new(color.red, 0))
tp1Lbl := label.new(bar_index + 20, take1, “TP1”, style=label.style_label_left, textcolor=color.white, color=color.new(color.blue, 0))
tp2Lbl := label.new(bar_index + 20, take2, “TP2”, style=label.style_label_left, textcolor=color.white, color=color.new(color.blue, 0))
tp3Lbl := label.new(bar_index + 20, take3, “TP3”, style=label.style_label_left, textcolor=color.white, color=color.new(color.blue, 0))
//==========================
// draw EMA
//==========================
plot(showEMA?emaFast:na, “Fast EMA”, color=color.green, linewidth=2)
plot(showEMA?emaSlow:na, “slow EMA”, color=color.orange, linewidth=2)
plot(showEMA?emaTrend:na, “trendEMA”, color=color.red, linewidth=2)
//==========================
// signal mark
//==========================
plotshape(buySignal, title=”Buy Signal”, text=”Buy”, style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.small)
plotshape(sellSignal, title=“Sell Signal”, text=“Sell”, style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)
//==========================
// alert
//==========================
Alertcondition(buySignal, title=”Buy Alert”, message=”XAUUSD Gold Buy Signal”)
Alertcondition(sellSignal, title=”Sell Alert”, message=”XAUUSD Gold Sell Signal”)
[ad_2]
Source link