بله اضافعه کن
- User
بله اضافعه کن
Assistant
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.
//@version=5
indicator("RSI with Dual Overbought/Oversold Levels", shorttitle="RSI Dual Zones", overlay=false)
// -----------------------------------------------------------------------------
// Customizable User Inputs
// -----------------------------------------------------------------------------
// RSI period length (usually 14)
int rsiLength = input.int(14, title="RSI Length", minval=1)
// RSI line color
color rsiColor = input.color(color.blue, title="RSI Line Color")
// First set of OB/OS levels (e.g., 70 / 30)
float obLevel1 = input.float(70.0, title="Overbought Level 1", minval=0, maxval=100)
float osLevel1 = input.float(30.0, title="Oversold Level 1", minval=0, maxval=100)
// Colors for Level 1 lines and zones
color obLineColor1 = input.color(color.red, title="Overbought Line Color 1")
color osLineColor1 = input.color(color.green, title="Oversold Line Color 1")
color obZoneColor1 = input.color(color.red, title="Overbought Zone Color 1")
color osZoneColor1 = input.color(color.green, title="Oversold Zone Color 1")
// Transparency for Level 1 zones
int obZoneAlpha1 = input.int(80, title="Overbought Zone Transparency 1", minval=0, maxval=100)
int osZoneAlpha1 = input.int(85, title="Oversold Zone Transparency 1", minval=0, maxval=100)
// Line style for Level 1
string obLineStyle1 = input.string("dashed", title="Overbought Line Style 1", options=["solid", "dashed", "dotted"])
string osLineStyle1 = input.string("dotted", title="Oversold Line Style 1", options=["solid", "dashed", "dotted"])
// Second set of OB/OS levels (e.g., 80 / 20)
float obLevel2 = input.float(80.0, title="Overbought Level 2", minval=0, maxval=100)
float osLevel2 = input.float(20.0, title="Oversold Level 2", minval=0, maxval=100)
// Colors for Level 2 lines and zones
color obLineColor2 = input.color(color.orange, title="Overbought Line Color 2")
color osLineColor2 = input.color(color.lime, title="Oversold Line Color 2")
color obZoneColor2 = input.color(color.orange, title="Overbought Zone Color 2")
color osZoneColor2 = input.color(color.lime, title="Oversold Zone Color 2")
// Transparency for Level 2 zones
int obZoneAlpha2 = input.int(80, title="Overbought Zone Transparency 2", minval=0, maxval=100)
int osZoneAlpha2 = input.int(85, title="Oversold Zone Transparency 2", minval=0, maxval=100)
// Line style for Level 2
string obLineStyle2 = input.string("solid", title="Overbought Line Style 2", options=["solid", "dashed", "dotted"])
string osLineStyle2 = input.string("dashed", title="Oversold Line Style 2", options=["solid", "dashed", "dotted"])
// -----------------------------------------------------------------------------
// Indicator Calculations
// -----------------------------------------------------------------------------
// Calculate RSI value based on closing price
float rsiValue = ta.rsi(close, rsiLength)
// -----------------------------------------------------------------------------
// Plotting the Indicator and Levels
// -----------------------------------------------------------------------------
// Plot the RSI line with customizable color
plot(rsiValue, "RSI", color=rsiColor, linewidth=2)
// Helper function to map line style string to Pine Script style
lineStyleFromString(s) =>
s == "solid" ? hline.style_solid :
s == "dashed" ? hline.style_dashed :
s == "dotted" ? hline.style_dotted :
hline.style_solid
// Plot horizontal lines for Overbought/Oversold levels (Set 1)
hline(obLevel1, "Overbought Level 1", color=obLineColor1, linestyle=lineStyleFromString(obLineStyle1))
hline(osLevel1, "Oversold Level 1", color=osLineColor1, linestyle=lineStyleFromString(osLineStyle1))
// Plot horizontal lines for Overbought/Oversold levels (Set 2)
hline(obLevel2, "Overbought Level 2", color=obLineColor2, linestyle=lineStyleFromString(obLineStyle2))
hline(osLevel2, "Oversold Level 2", color=osLineColor2, linestyle=lineStyleFromString(osLineStyle2))
// Mid-line
hline(50, "Mid-Line (50)", color=color.gray, linestyle=hline.style_dashed)
// -----------------------------------------------------------------------------
// Background Coloring for Zones
// -----------------------------------------------------------------------------
// Overbought Zones
bgcolor(rsiValue > obLevel2 ? color.new(obZoneColor2, obZoneAlpha2) : na, title="OB Zone 2")
bgcolor(rsiValue <= obLevel2 and rsiValue > obLevel1 ? color.new(obZoneColor1, obZoneAlpha1) : na, title="OB Zone 1")
// Oversold Zones
bgcolor(rsiValue < osLevel2 ? color.new(osZoneColor2, osZoneAlpha2) : na, title="OS Zone 2")
bgcolor(rsiValue >= osLevel2 and rsiValue < osLevel1 ? color.new(osZoneColor1, osZoneAlpha1) : na, title="OS Zone 1")
// -----------------------------------------------------------------------------
// Generating Buy/Sell Signals (Crossovers)
// -----------------------------------------------------------------------------
// Buy Signal: When RSI crosses Oversold level from below
bool crossUpOS1 = ta.crossover(rsiValue, osLevel1)
bool crossUpOS2 = ta.crossover(rsiValue, osLevel2)
// Sell Signal: When RSI crosses Overbought level from above
bool crossDownOB1 = ta.crossunder(rsiValue, obLevel1)
bool crossDownOB2 = ta.crossunder(rsiValue, obLevel2)
// -----------------------------------------------------------------------------
// Plotting Shapes for Signals on the Main Chart
// -----------------------------------------------------------------------------
plotshape(crossUpOS1, title="Buy Signal (OS1)", location=location.belowbar, color=osLineColor1, style=shape.triangleup, size=size.small, text="Buy1")
plotshape(crossUpOS2, title="Buy Signal (OS2)", location=location.belowbar, color=osLineColor2, style=shape.triangleup, size=size.small, text="Buy2")
plotshape(crossDownOB1, title="Sell Signal (OB1)", location=location.abovebar, color=obLineColor1, style=shape.triangledown, size=size.small, text="Sell1")
plotshape(crossDownOB2, title="Sell Signal (OB2)", location=location.abovebar, color=obLineColor2, style=shape.triangledown, size=size.small, text="Sell2")
// -----------------------------------------------------------------------------
// Defining Alert Conditions for TradingView
// -----------------------------------------------------------------------------
alertcondition(crossUpOS1 or crossUpOS2, title="RSI Buy Alert", message="RSI crossed above Oversold level.")
alertcondition(crossDownOB1 or crossDownOB2, title="RSI Sell Alert", message="RSI crossed below Overbought level.")
int obZoneAlpha1 = input.int(80, title="Overbought Zone Transparency 1", minval=0, maxval=100)
int osZoneAlpha1 = input.int(85, title="Oversold Zone Transparency 1", minval=0, maxval=100)
string obLineStyle1 = input.string("dashed", title="Overbought Line Style 1", options=["solid", "dashed", "dotted"])
string osLineStyle1 = input.string("dotted", title="Oversold Line Style 1", options=["solid", "dashed", "dotted"])
hline:hline(obLevel1, "Overbought Level 1", color=obLineColor1, linestyle=lineStyleFromString(obLineStyle1))
bgcolor:bgcolor(rsiValue > obLevel2 ? color.new(obZoneColor2, obZoneAlpha2) : na, title="OB Zone 2")
| عنصر | رنگ پیشنهادی | استایل پیشنهادی |
|---|---|---|
| RSI Line | آبی یا بنفش | Solid |
| OB Line 1 | قرمز | Dashed |
| OB Zone 1 | قرمز کمرنگ | 80% شفافیت |
| OS Line 1 | سبز | Dotted |
| OS Zone 1 | سبز کمرنگ | 85% شفافیت |
| OB Line 2 | نارنجی | Solid |
| OB Zone 2 | نارنجی کمرنگ | 80% شفافیت |
| OS Line 2 | سبز لیمویی | Dashed |
| OS Zone 2 | سبز لیمویی کمرنگ | 85% شفافیت |
اگر میخواهید ضخامت خطوط یا سایز سیگنالها هم قابل تنظیم باشد، بفرمایید تا براتون اضافه کنم.