답변완료
안녕하세요. 코딩 수정 부탁드립니다!
Inputs:
factor (3), // SuperTrend ATR 배수
AtrPeriod (14), // SuperTrend ATR 기간
shortLen (12), // EMA 단기 기간
longLen (26); // EMA 장기 기간
Vars:
src (0),
trv (0),
atrv (0),
upperBand (0),
lowerBand (0),
prevUB (0),
prevLB (0),
dir (0),
supertrend (0),
emaShort (0),
emaLong (0);
// === SuperTrend 계산 ===
if CurrentBar > 1 then {
src = (High + Low) / 2;
trv = MaxList(High - Low,
MaxList(Abs(High - Close[1]),
Abs(Low - Close[1])));
atrv = EMA(trv, AtrPeriod);
upperBand = src + factor * atrv;
lowerBand = src - factor * atrv;
prevUB = upperBand[1];
prevLB = lowerBand[1];
if (lowerBand <= prevLB and Close[1] >= prevLB) then
lowerBand = prevLB;
if (upperBand >= prevUB and Close[1] <= prevUB) then
upperBand = prevUB;
if Close > upperBand then
dir = 1;
else if Close < lowerBand then
dir = -1;
if dir == 1 then
supertrend = lowerBand;
else
supertrend = upperBand;
}
// === EMA 계산 ===
emaShort = EMA(Close, shortLen);
emaLong = EMA(Close, longLen);
// === 상태 기반 진입·청산 ===
// 롱 진입: 포지션 없고 EMA > & 가격 > SuperTrend
if MarketPosition == 0
and emaShort > emaLong
and Close > supertrend then {
Buy("LongEntry");
}
// 롱 청산: 롱 보유 중 EMA < & 가격 < SuperTrend
if MarketPosition > 0
and emaShort < emaLong
and Close < supertrend then {
ExitLong("LongExit");
}
// 숏 진입: 포지션 없고 EMA < & 가격 < SuperTrend
if MarketPosition == 0
and emaShort < emaLong
and Close < supertrend then {
Sell("ShortEntry");
}
// 숏 청산: 숏 보유 중 EMA > & 가격 > SuperTrend
if MarketPosition < 0
and emaShort > emaLong
and Close > supertrend then {
ExitShort("ShortExit");
}
담당자님 안녕하세요. 항상 고생많으십니다.
현재 스위칭 진입,청산 전략을 사용하고 있습니다.
예를 들어 매수 후 매도 청산 -> 다음봉에서 다시 매도진입 이런식으로 되는데
혹시 청산하면서 그 봉에서 바로 스위칭 진입하는 코딩으로 만들어 주실 수 있으실까요??
매수 후 매도 청산 -> 그 봉에 종가에서 바로 매도 진입
매도 후 매수 청산 -> 그 봉에 종가에서 바로 매수 진입
이렇게 부탁드리겠습니다! 감사합니다.
2025-08-06
207
글번호 193054
시스템
답변완료
지표 질문입니다
1.
var1=highest(H,20);
var2=lowest(L,20);
plot1(var1);
plot2(var2);
이 수식을 실행하면 선 두 개가 실행되는데
var1 선 우측 위에 var2 바닥 포함 var1 천정까지 캔들수(양봉,음봉,도지) 표시하는 수식
var2 선 우측 아래 var1 천정 포함 var2 바닥까지 캔들수(양봉,음봉,도지) 표시하는 수식
2.
'봉세기 갯수' 버튼을 클릭해서
2025/04/09 바닥에서 2025/07/31 천정까지 드래깅하면
77봉(45,31,1) 이라고 표출됩니다
여기에 한 개 추가하여 양봉 덩어리 갯수 22개를 추가하여 77봉(45,31,1,22) 로 표출
3.
'봉세기 갯수' 버튼을 클릭해서
2025/03/26 천정에서 2025/04/09 바닥까지 드래깅하면 11봉(4.7,0)이 출력됩니다
여기에 1개 추가하여 음봉 덩어리 갯수 3개를 포함하여 11봉(4.7,0,3)) 로 표출
4.
검색식에서 음봉+연속 2양 익일 시가 상승 출발 종목을 검색하는 수식 부탁드립니다
그리고 수식을 이용하여 아이엠증권 예스트레이더 차트에서 그 종목을 검색하는 프로세스를 설명해주시면 감사하겠습니다
감사합니다
2025-08-06
182
글번호 193051
지표
답변완료
어떻게 고쳐야 할까요?
차트상 매수(빨간삼각형), 매도(파란삼각형) 신호와 무관하게 신호가 나타납니다. 수정 부탁 드림니다.
input : length(15);
input : show_levl(true);
var : up(0),dn(0),A(0),emaValue(0),correction(0),zlma(0);
var : signalUp(False),signalDn(False),zlma_color(0),ema_col(0);
var : TOP(0),BTM(0),box(0),tx(0),tx1(0),check_signals(False);
up = Black;
dn = Blue;
#var box1 = box(na) // Variable to store the box
a = atr(200);
emaValue = ema(close, length);
correction = close + (close - emaValue);
zlma = ema(correction, length);
signalUp = CrossUp(zlma, emaValue);
signalDn = CrossDown(zlma, emaValue);
zlma_color = iff(zlma > zlma[3] , up , iff(zlma < zlma[3] , dn , Nan));
ema_col = iff(emaValue < zlma , up , dn);
if signalUp Then
{
Top = zlma;
BTM = zlma-A;
var3 = (Top+BTM)/2;
}
else if signalDn Then
{
Top = zlma+A;
BTM = zlma;
var3 = (Top+BTM)/2;
}
check_signals = signalUp or signalDn;
if CrossDown(high, BTM) and emaValue > zlma Then
{
Buy("b");
}
if CrossUp(low, Top) and emaValue < zlma Then
{
ExitLong("bx");
}
2025-08-06
217
글번호 193042
시스템
답변완료
문의드립니다,
Input : shortPeriod(12), longPeriod(26), Period(9);
Inputs: RSILength(10), OverSold(30);
Var : MACD1(0,Data1),MACD2(0,Data2),R(0,Data1);
MACD1 = data1(MACD(shortPeriod, longPeriod));
MACD2 = data2(MACD(shortPeriod, longPeriod));
R = Data1(RSI(RSILength));
If MACD2 > 0 and Crossup(R, OverSold) Then
Buy ("RSI");
if MarketPosition == 1 Then
{
if CrossDown(MACD1,0) or CrossDown(MACD2,0) Then
ExitLong();
}
위 수식을 다음과같이 변경 문의드립니다.
1.data2 macd oscillator 골든시 data1매수
2.data2 macd oscillator 골든이후 data1 rsi bull oscillator 매수신호시 data1매수식
3.data1 rsi bull oscillator (70)매도시 or data2 macd oscillator 매도시 매도식
늘감사드립니다
2025-08-06
187
글번호 193041
시스템
답변완료
문의드립니다.
1.아래의 트레이딩뷰수식을 변환부탁드립니다.
2 위1번에서 차트는 과거봉 500개까지 밴드가 그려지는 것으로 보이는데, 과거봉 5000개까지 확장적용하려면 어떻게 해야 하는지요?
=====================
indicator("Nadaraya-Watson Envelope [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Envelope", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
h = input.float(8.,'Bandwidth', minval = 0)
mult = input.float(1.6., minval = 0)
src = input(close, 'Source')
repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations')
//Style
upCss = input.color(color.teal, 'Colors', inline = 'inline1', group = 'Style')
dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Gaussian window
gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2)))
//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
n = bar_index
var ln = array.new_line(0)
if barstate.isfirst and repaint
for i = 0 to 499
array.push(ln,line.new(na,na,na,na))
//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.
if barstate.isfirst and not repaint
for i = 0 to 499
w = gauss(i, h)
coefs.push(w)
den := coefs.sum()
out = 0.
if not repaint
for i = 0 to 499
out += src[i] * coefs.get(i)
out /= den
mae = ta.sma(math.abs(src - out), 499) * mult
upper = out + mae
lower = out - mae
//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
nwe = array.new<float>(0)
if barstate.islast and repaint
sae = 0.
//Compute and set NWE point
for i = 0 to math.min(499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to math.min(499,n - 1)
w = gauss(i - j, h)
sum += src[j] * w
sumw += w
y2 := sum / sumw
sae += math.abs(src[i] - y2)
nwe.push(y2)
sae := sae / math.min(499,n - 1) * mult
for i = 0 to math.min(499,n - 1)
if i%2
line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss)
line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss)
if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae
label.new(n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae
label.new(n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center)
y1 := nwe.get(i)
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = table.new(position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if repaint
tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small)
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
plot(repaint ? na : out + mae, 'Upper', upCss)
plot(repaint ? na : out - mae, 'Lower', dnCss)
//Crossing Arrows
plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor = upCss, size = size.tiny)
plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor = dnCss, size = size.tiny)
//-----------------------------------------------------------------------------}
==================
매번 감사드립니다. 수고하세요!!!
2025-08-06
204
글번호 193040
지표