Saeed

Wait 5 sec.

SaeedHYPE / TetherUS PERPETUAL CONTRACTBINANCE:HYPEUSDT.Psaeedforoozeshث//@version=5 indicator("Gold & Crypto 5M/15M ", overlay=true) // --- تنظیمات ورودی --- grp_strat = "تنظیمات استراتژی و تایم‌فریم" emaFastLen = input.int(8, title="دوره EMA سریع (8)", group=grp_strat) emaSlowLen = input.int(21, title="دوره EMA کند (21)", group=grp_strat) trendLen = input.int(100, title="EMA روند پایه (100)", group=grp_strat) rsiLen = input.int(14, title="دوره RSI", group=grp_strat) atrLen = input.int(14, title="دوره ATR", group=grp_strat) grp_rr = "تنظیمات ریسک به ریوارد (R:R)" atrSlMult = input.float(1.2, title="ضریب فاصله حد ضرر (بر پایه ATR)", group=grp_rr) rrTarget1 = input.float(1.5, title="نسبت R:R تارگت اول (مثلاً 1.5)", group=grp_rr) rrTarget2 = input.float(2.5, title="نسبت R:R تارگت دوم (مثلاً 2.5)", group=grp_rr) // --- محاسبات تکنیکال --- fastEma = ta.ema(close, emaFastLen) slowEma = ta.ema(close, emaSlowLen) trendEma = ta.ema(close, trendLen) rsiVal = ta.rsi(close, rsiLen) atrVal = ta.atr(atrLen) // رسم خطوط میانگین plot(fastEma, color=color.new(#00e676, 0), title="Fast EMA", linewidth=1) plot(slowEma, color=color.new(#ff5252, 0), title="Slow EMA", linewidth=1) plot(trendEma, color=color.new(#ffd700, 20), title="Trend EMA 100", linewidth=2) // --- شروط دقیق سیگنال ورود --- longCondition = ta.crossover(fastEma, slowEma) and close > trendEma and rsiVal > 52 and rsiVal < 68 shortCondition = ta.crossunder(fastEma, slowEma) and close < trendEma and rsiVal < 48 and rsiVal > 32 // متغیرهای ذخیره پوزیشن و محاسبه R:R var float entryPrice = na var float slPrice = na var float tp1Price = na var float tp2Price = na var float riskDist = na var string tradeType = "NONE" if (longCondition) entryPrice := close riskDist := atrVal * atrSlMult slPrice := entryPrice - riskDist tp1Price := entryPrice + (riskDist * rrTarget1) tp2Price := entryPrice + (riskDist * rrTarget2) tradeType := "LONG (خرید)" if (shortCondition) entryPrice := close riskDist := atrVal * atrSlMult slPrice := entryPrice + riskDist tp1Price := entryPrice - (riskDist * rrTarget1) tp2Price := entryPrice - (riskDist * rrTarget2) tradeType := "SHORT (فروش)" // --- نمایش برچسب‌های ورود روی کندل --- plotshape(series=longCondition, title="سیگنال خرید", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY\nENTRY", textcolor=color.white, size=size.small) plotshape(series=shortCondition, title="سیگنال فروش", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL\nENTRY", textcolor=color.white, size=size.small) // رسم خطوط سطوح SL و TP روی چارت plot(slPrice, title="Stop Loss", color=color.new(color.red, 30), style=plot.style_linebr, linewidth=1) plot(tp1Price, title="TP1 (R:R 1)", color=color.new(color.green, 30), style=plot.style_linebr, linewidth=1) plot(tp2Price, title="TP2 (R:R 2)", color=color.new(color.teal, 30), style=plot.style_linebr, linewidth=1) // --- جدول نمایش اطلاعات و ریسک به ریوارد (Dashboard) --- var table rrTable = table.new(position=position.top_right, columns=3, rows=5, bgcolor=color.new(color.black, 15), border_width=1, border_color=color.gray) if barstate.islast // ردیف عنوان table.cell(rrTable, 0, 0, "سیگنال فعلی", bgcolor=color.new(color.blue, 40), text_color=color.white, text_size=size.small) table.cell(rrTable, 1, 0, tradeType, bgcolor=tradeType == "LONG (خرید)" ? color.new(color.green, 30) : (tradeType == "SHORT (فروش)" ? color.new(color.red, 30) : color.new(color.gray, 50)), text_color=color.white, text_size=size.small) table.cell(rrTable, 2, 0, "نسبت R:R", bgcolor=color.new(color.blue, 40), text_color=color.white, text_size=size.small) // ردیف قیمت ورود table.cell(rrTable, 0, 1, "نقطه ورود", bgcolor=color.new(color.black, 40), text_color=color.white, text_size=size.small) table.cell(rrTable, 1, 1, na(entryPrice) ? "-" : str.tostring(entryPrice, "#.##"), bgcolor=color.new(color.black, 40), text_color=color.yellow, text_size=size.small) table.cell(rrTable, 2, 1, "Base (1.0)", bgcolor=color.new(color.black, 40), text_color=color.yellow, text_size=size.small) // ردیف حد ضرر table.cell(rrTable, 0, 2, "حد ضرر (SL)", bgcolor=color.new(color.black, 40), text_color=color.white, text_size=size.small) table.cell(rrTable, 1, 2, na(slPrice) ? "-" : str.tostring(slPrice, "#.##"), bgcolor=color.new(color.black, 40), text_color=color.red, text_size=size.small) table.cell(rrTable, 2, 2, "Risk: -1.0R", bgcolor=color.new(color.black, 40), text_color=color.red, text_size=size.small) // ردیف تارگت اول table.cell(rrTable, 0, 3, "تارگت اول (TP1)", bgcolor=color.new(color.black, 40), text_color=color.white, text_size=size.small) table.cell(rrTable, 1, 3, na(tp1Price) ? "-" : str.tostring(tp1Price, "#.##"), bgcolor=color.new(color.black, 40), text_color=color.green, text_size=size.small) table.cell(rrTable, 2, 3, "1 : " + str.tostring(rrTarget1, "#.#"), bgcolor=color.new(color.green, 40), text_color=color.white, text_size=size.small) // ردیف تارگت دوم table.cell(rrTable, 0, 4, "تارگت دوم (TP2)", bgcolor=color.new(color.black, 40), text_color=color.white, text_size=size.small) table.cell(rrTable, 1, 4, na(tp2Price) ? "-" : str.tostring(tp2Price, "#.##"), bgcolor=color.new(color.black, 40), text_color=color.teal, text_size=size.small) table.cell(rrTable, 2, 4, "1 : " + str.tostring(rrTarget2, "#.#"), bgcolor=color.new(color.teal, 40), text_color=color.white, text_size=size.small) // هشدارهای متنی با نمایش دقیق ریسک به ریوارد alertcondition(longCondition, title="هشدار خرید با R:R", message="سیگنال BUY طلا/کریپتو | ورود: {{close}} | تایم: {{interval}}") alertcondition(shortCondition, title="هشدار فروش با R:R", message="سیگنال SELL طلا/کریپتو | ورود: {{close}} | تایم: {{interval}}")