// This source code is subject to the terms of the Mozilla Public License 2.0 at…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mohanee
//@version=4 strategy(title="RSI W Pattern strategy", pyramiding=2, shorttitle="RSI W Pattern", overlay = false)
//Strategy Rules //ema20 is above ema50 //RSI5 making W pattern in oversold area or just below 70 level , you can define the value for parameter buyRsiEntry --- dont go beyond 70 //Exit when RSI reaches 75
len = input(title="RSI Period", minval=1, defval=5) buyRsiEntry = input(title="look for W pattern bottom edges well below RSI level (BUY) ", minval=10, defval=65, maxval=70) //numberOfBars = input(title="Number of Bars in W pattern ", minval=4, defval=4, maxval=6)
emaL = input(title="Long Term EMA", minval=1, defval=50, maxval=200) emaS = input(title="Short Term EMA", minval=1, defval=20, maxval=200)
stopLoss = input(title="Stop Loss %", minval=1, defval=8, maxval=10)
//rsiWp1=false
myRsi = rsi(close,len)
//longEmaVal=ema(close,emaL) //shortEmaVal=ema(close,emaS)
entryEma=ema(close,5) // This is used as filetr for BUY
isEma20AboveEma50=ema(close,emaS)>ema(close,emaL) ? true : false
//W Pattern //rsiWp1 = myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3] and myRsi[3]<myRsi[4] //This is published one rsiWp1 = myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3] and myRsi[3]<myRsi[4] and (low[1]<=low[4] or low[3]<=low[4] ) // looking for recent low
//rsiWp1 = myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3] and myRsi[3]<myRsi[4] //Ths one has 92% win rate and 4.593 prfit factor
//long condition filters
//1. ema20 > ema50
//2. Rsi5 has W pattern
//3. current RSI <= 65 (parameter buyRsiEntry) (dont go beyond 70 , becuase that is already overbought area)
//4. current price low/close is below 5 ema --- looking for pullback -- Optional
longCondition = isEma20AboveEma50 and rsiWp1 and (myRsi<=buyRsiEntry and myRsi>=30)
//and (low<entryEma or close<entryEma) --- if this optional required , add it to above condition
patternText=" W "
barcolor(longCondition?color.yellow:na)
//initial entry strategy.entry("RSI_W_LE", comment="Buy" , long=true, when=longCondition )
//legging in to existing strategy.entry("RSI_W_LE",comment="Add", long=true, when=strategy.position_size>0 and crossover(myRsi,10 ))
//calculate stoploss value stopLossValue=strategy.position_avg_price - (strategy.position_avg_price*stopLoss/100)
rsiPlotColor=longCondition ?color.yellow:color.purple
plot(myRsi, title="RSI", linewidth=2, color=color.purple) // plot(myRsi, title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple) //plot(myRsi[1], title="RSI", linewidth=2, color=rsiWp1==true?color.yellow:color.purple) //plot(myRsi[2], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple) //plot(myRsi[3], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple) //plot(myRsi[4], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)
hline(40, title="Middle Line", color=color.blue, linestyle=hline.style_dashed) obLevel = hline(75, title="Overbought", color=color.red, linestyle=hline.style_dashed) osLevel = hline(30, title="Oversold", color=color.purple, linestyle=hline.style_dashed) fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)
plotshape( longCondition ? myRsi[1] : na, offset=-1, title="W Pattern", text=patternText, style=shape.labelup, location=location.absolute, color=color.purple, textcolor=color.yellow, transp=0 )
bgcolor(strategy.position_size>0?color.green:na, transp=40, title='In Long Position')
//take profit or close when RSI reaches 75
takeProfit=crossover(myRsi,75)
//close when RSi reaches profit level strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size,when=crossover(myRsi,75) and close>strategy.position_avg_price )
//close everything when stoploss hit
longCloseCondition=close<(strategy.position_avg_price - (strategy.position_avg_price*stopLoss/100) ) //or crossunder(myRsi,30)
strategy.close("RSI_W_LE", comment="SL Exit", qty=strategy.position_size,when=longCloseCondition )
سلام دوست عزیز،
ممنون که کدت رو ارسال کردی! من کد استراتژی "RSI W Pattern Strategy" رو بهدقت بررسی کردم و در ادامه تحلیل جامعی از کارایی، نقاط قوت، ضعف و مناسب بودن این استراتژی برای لانگ و شورت (اگرچه در حال حاضر فقط لانگ پیادهسازی شده) ارائه میکنم.
این استراتژی یک استراتژی خرید (لانگ) مبتنی بر الگوی W در RSI(5) هست که در کنار این الگو از EMA(20) و EMA(50) برای تأیید روند صعودی استفاده میکند. همچنین دو شرط خروج تعریف شده:
myRsi > myRsi[1]myRsi >= 30myRsi[1] < myRsi[2]myRsi[2] > myRsi[3]myRsi[3] < myRsi[4]low[1] <= low[4] یا low[3] <= low[4] – پایینترین نقطه در Wlow < entryEma or close < entryEma در حال حاضر کامنت شده است. اگر فعال شود، میتواند به عنوان فیلتر قوی برای ورود در کشیدگیها عمل کند.قیمت میانگین - stopLoss% برسد، موقعیت بسته میشوداستفاده از الگوی W در RSI(5):
فیلتر EMA(20) > EMA(50):
خروج اتوماتیک در RSI=75:
پتانسیل اضافه شدن به موقعیت قبلی (Pyramiding):
فاقد استراتژی شورت:
Rsi(5) بسیار حساس است:
حد ضرر درصدی ثابت (بدون استفاده از ATR یا Volatility):
عدم وجود بکتست قابل اتکا:
نیاز به بهینهسازی الگوی W:
افزودن استراتژی شورت:
shortCondition = not isEma20AboveEma50 and rsiMp1 and (myRsi >= 70)
strategy.entry("RSI_M_SE", short=true, when=shortCondition)
استفاده از ATR برای SL و TP:
بهینهسازی الگوی W:
low[2] باید بین low[1] و low[3] باشدافزودن فیلتر حجم (Volume):
افزودن فیلتر زمانی:
| بخش | وضعیت | توضیح |
|---|---|---|
| کارایی برای لانگ | ✅ عالی | سیگنالهای خوبی در روند صعودی و منطقه اشباع فروش ایجاد میکند |
| کارایی برای شورت | ❌ نیاز به توسعه | باید الگوی M و فیلترهای معکوس اضافه شوند |
| قابلیت استفاده در بازارهای مختلف | ⚠️ با محدودیت | در بازارهای پر نوسان مثل رمزارزها ممکن است سیگنالهای نویزی داشته باشد |
| نیاز به بهینهسازی | ✅ بله | به خصوص در تشخیص دقیقتر W و SL/TP |
| نرخ موفقیت | 🤷♂️ نیاز به تست | بدون بکتست نمیتوان ارزیابی دقیق داشت |
اگر قصد دارید این استراتژی را برای لانگ و شورت توسعه دهید، میتونم کمک کنم تا نسخه شورت را هم به کد اضافه کنیم. همچنین اگر داده بکتست دارید یا میخواهید یک سیستم کاملاً اتوماتیک و قابل معامله داشته باشید، میتونیم بهینهسازی کنیم.
اگر میخواهید، کد شورت شده این استراتژی رو هم براتون بنویسم.
اگر سوالی داشتی یا میخواهی یک نسخه بهینهشده داشته باشی، فقط بگو! 😊
و اگر میخواهی این استراتژی رو روی داده واقعی تست کنی، کافیه یه بکتست با تاریخ مشخص ارائه بدی تا نرخ موفقیت و فاکتور سودش رو هم ببینیم.