OPEN-SOURCE SCRIPT

XAUUSD Pro Strategy

235
//version=5
indicator("XAUUSD RR Buy Sell Indicator", overlay=true, max_labels_count=500, max_boxes_count=100)

// ===== INPUT =====
rr = input.float(2.0, "Risk Reward", step=0.1)
sl_pips = input.int(300, "Stop Loss (points)")
show_boxes = input.bool(true, "Show Entry SL TP Box")

// ===== EMA =====
ema9 = ta.ema(close, 9)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)

plot(ema9, color=color.yellow)
plot(ema50, color=color.blue)
plot(ema200,color=color.red)

// ===== TREND =====
bull = ema50 > ema200
bear = ema50 < ema200

// ===== ENTRY CONDITIONS =====
buyCond = bull and close > ema9 and close[1] < ema9
sellCond = bear and close < ema9 and close[1] > ema9

// ===== PRICE CALC =====
buyEntry = close
buySL = buyEntry - sl_pips * syminfo.mintick
buyTP = buyEntry + (buyEntry - buySL) * rr

sellEntry = close
sellSL = sellEntry + sl_pips * syminfo.mintick
sellTP = sellEntry - (sellSL - sellEntry) * rr

// ===== DRAW =====
if buyCond
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)
if show_boxes
box.new(bar_index, buyEntry, bar_index + 5, buySL, bgcolor=color.new(color.red,80))
box.new(bar_index, buyTP, bar_index + 5, buyEntry, bgcolor=color.new(color.green,80))

if sellCond
label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white)
if show_boxes
box.new(bar_index, sellSL, bar_index + 5, sellEntry, bgcolor=color.new(color.red,80))
box.new(bar_index, sellEntry, bar_index + 5, sellTP, bgcolor=color.new(color.green,80))

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.