·Î±×ÀÎ
|
ȸ¿ø°¡ÀÔ
|
ȸ»ç¼Ò°³
|
»çÀÌÆ®¸Ê
Ä¿¹Â´ÏƼ | ¼ö½ÄÀÛ¼º Q&A
ÀÛ¼ºÀÚ :
»ç³ë¼ÒÀÌ
ÀÛ¼ºÀÏ : 2025-06-11 ¿ÀÈÄ 12:00:09 Á¶È¸¼ö : 45
¼ö½Ä ºÎʵ右´Ï´Ù
ÁöÇ¥½Ä ºÎʵ右´Ï´Ù.
//@version=5
indicator("SR MA", overlay = true, timeframe = "", timeframe_gaps = false)
// Simple filter function
simple_filter(float source, int length, bool duel_filter) =>
switch duel_filter
false => ta.wma(source, length)
true => ta.wma(ta.sma(source, length), length)
// Main SR MA function
sr_ma(float source = close, int output_smoothing = 3, int trigger_smoothing = 1, int atr_length = 50, float multiplier = 1, string range_switch = "Body", bool duel_filter = false) =>
candle_top = range_switch != "Body" ? high : math.max(open, close)
candle_bottom = range_switch != "Body" ? low : math.min(open, close)
smooth_top = ta.sma(candle_top, trigger_smoothing)
smooth_bottom = ta.sma(candle_bottom, trigger_smoothing)
tr = candle_top - candle_bottom
atr = ta.sma(tr, atr_length)
var float sr_ma = na
var float current_range = na
var float top_range = na
var float bottom_range = na
flag = smooth_top > top_range or smooth_bottom < bottom_range or na(current_range)
if flag
sr_ma := source
current_range := atr * multiplier
top_range := sr_ma + current_range
bottom_range := sr_ma - current_range
out = simple_filter(sr_ma, output_smoothing, duel_filter)
smooth_top_range = simple_filter(top_range, output_smoothing, duel_filter)
smooth_bottom_range = simple_filter(bottom_range, output_smoothing, duel_filter)
[out, smooth_top_range, smooth_bottom_range]
// === Inputs ===
source = input.source(close, "Source", group = "Settings")
output_smoothing = input.int(100, "Length", minval = 0, group = "Settings") + 1
use_double = input.bool(true, "Double Filter", group = "Settings")
smoothing = input.int(4, "Trigger Smoothing", minval = 0, group = "Settings") + 1
atr_length = input.int(200, "ATR Length", minval = 1, group = "Settings")
multiplier = input.float(6, "Range Multiplier", minval = 0, step = 0.125, group = "Settings")
range_switch = input.string("Body", "Range Style", ["Body", "Wick"], group = "Settings")
// === Color Inputs ===
bullish_color = input.color(color.rgb(33, 255, 120), "Bullish Color", group = "Color")
bearish_color = input.color(color.rgb(255, 33, 33), "Bearish Color", group = "Color")
neutral_color = input.color(color.rgb(137, 137, 137), "Neutral Color", tooltip = "This doubles as the solid color.", group = "Color")
// === Calculate SR MA & Ranges ===
[sr_ma, top_range, bottom_range] = sr_ma(source, output_smoothing, smoothing, atr_length, multiplier, range_switch, use_double)
// === MA Color Logic ===
ma_delta_neutral = sr_ma - nz(sr_ma[1]) == 0
ma_delta_bullish = sr_ma - nz(sr_ma[1]) > 0
ma_delta_bearish = sr_ma - nz(sr_ma[1]) < 0
ma_color = ma_delta_neutral ? neutral_color : ma_delta_bullish ? bullish_color : bearish_color
// === Plot SR MA and Ranges ===
alpha = color.new(color.red, 100)
ma = plot(sr_ma, "SR MA", ma_color, 4)
top = plot(top_range, "Top Range", ma_color, 2)
bottom = plot(bottom_range, "Bottom Range", ma_color, 2)
fill(ma, top, top_value = top_range, bottom_value = sr_ma, bottom_color = color.new(ma_color, 80), top_color = alpha)
fill(ma, bottom, top_value = sr_ma, bottom_value = bottom_range, top_color = color.new(ma_color, 80), bottom_color = alpha)
// === Detect Color Change ===
var color prev_color = na
color_change = ma_color != prev_color and not na(prev_color)
prev_color := ma_color
color_change_to_bullish = color_change and ma_color == bullish_color
color_change_to_bearish = color_change and ma_color == bearish_color
// === Visual Markers ===
plotshape(color_change_to_bullish, title="MA Color Change to Bullish", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="Bullish")
plotshape(color_change_to_bearish, title="MA Color Change to Bearish", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="Bearish")
// === Alerts for Color Changes ===
alertcondition(color_change_to_bullish, title="SR MA Color Changed to Bullish", message="SR MA color changed to Bullish (Uptrend)")
alertcondition(color_change_to_bearish, title="SR MA Color Changed to Bearish", message="SR MA color changed to Bearish (Downtrend)")
Áú¹® ºÎʵ右´Ï´Ù
Àü·« ¼ö½Ä ºÎʵ右´Ï´Ù
°ü·Ã ±Û ¸®½ºÆ®
ÇöÀç±Û
¼ö½Ä ºÎʵ右´Ï´Ù
»ç³ë¼ÒÀÌ
2025.06.11
45
Re : ¼ö½Ä ºÎʵ右´Ï´Ù
¿¹½º½ºÅ¹
2025.06.11
40