답변완료
질문 부탁드립니다
수고하십니다
질문 몇 가지 부탁드립니다
질문1)
if Bdate != Bdate[1] Then
Condition3 = False;
if condition3==False and countif(h>aa[0] and h>aa[1]...and h>aa[20],50)>1 Then
{
condition3=true;
find(1)
}
위의 식에서 h>aa[0] and h>aa[1]...and h>aa[20] 처럼 길어질때 반복문으로 검색식을 만들수 있을까요
질문2)
if (h>l*1.08) then
{
...
condition1=false;
if countif(h>aa[0] and h>aa[1]...and h>aa[20],50)>1 Then condition1=true;
}
countif(h>aa[0] and ...h>aa[20],50)>1 을 condition1 에 포함시키고자 하는데
반복문으로 만들고 싶습니다
질문3)
텍스트 관련 질문인데요
newline 을 변수화 하려고 하는데요
예를들어
nl=newline;
txt1[0]=text_new(sd[0],st[0],aa[0],nl+NumToStr(h,0)+nl+NumToStr(h,0)+nl+NumToStr(l,0)));
이렇게 표현하고자 하는데 연산자 앞뒤 두 데이터의 형태가 같아야 합니다 라는 에러가 나오네요. newline 은 변수에 대입이 안되나요?
그리고
text_setstring 에서요
For cnt = 49 DownTo 1
{
aa[cnt] = aa[cnt-1];
sd[cnt] =sd[cnt-1];st[cnt] =st[cnt-1];
txt1[cnt]=txt1[cnt-1];
Text_SetString(txt1[cnt],newline+NumToStr(cnt,0));
}
aa[0] = value1;
sd[0] = sDate;
st[0] = sTime;
txt1[0]=text_new(sd[0],st[0],aa[0],newline+NumToStr(aa[cnt],0)
+newline+NumToStr(sd[cnt],0)+newline+
NumToStr(cnt,0));
text_setstring() 안에 txt1 의 내용 전체가 들어가야 모든 조건만족봉에서
텍스트가 나타나기에, (위 식처럼 하면 가장 최근봉에만 표시됨)
txt1 내용이 바뀔때마다 매번 setstring 내용도 같이 변경을 해줘야하는데요
혹시
var1=newline+NumToStr(aa[cnt],0)+newline+NumToStr(sd[cnt],0)+newline+NumToStr(cnt,0);
for cnt=49 downto 1
{
txt1[cnt]=txt1[cnt-1];
Text_SetString(txt1[cnt],var1);
}
txt1[0]=text_new(sd[0],st[0],aa[0],var1);
이런 흐름으로 텍스트 함수 내용의 일부를 변수화 시킬 수있을까요?
일반 변수가 안된다면 논리형 변수로 할 수 있을까요?
감사합니다
2025-06-11
229
글번호 191594
검색
답변완료
수식 부탁드립니다
지표식 부탁드립니다.
//@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
293
글번호 191593
지표