답변완료
부탁드립니다
수식이 맞는지 확인 부탁합니다
input : len(100), th(3.0); // ZigZag 기준 변동폭(%)
var :
i(0),
dir(0),
ptCnt(0),
zzIdx(0),
zzPrice(0),
zzDir(0),
rise1(0), rise2(0),
valid(false);
// 배열 변수는 'Array :' 키워드를 사용하여 별도로 선언해야 합니다.
// 여기서 100은 배열의 최대 크기입니다. len의 최대값에 따라 적절히 조정하세요.
Array : zigzagPt[100](0);
Array : zigzagIdx[100](0);
// ZigZag 포인트 탐지
for i = 1 to len - 1 begin
if dir = 0 then begin // 초기 방향 설정
if H[i] > H[0] * (1 + th / 100.0) then begin // 상승 방향 시작
dir = 1;
zzPrice = H[i];
zzIdx = i;
zzDir = 1; // 상승
zigzagPt[0] = zzPrice;
zigzagIdx[0] = zzIdx;
ptCnt = 1;
end
else if L[i] < L[0] * (1 - th / 100.0) then begin // 하락 방향 시작
dir = -1;
zzPrice = L[i];
zzIdx = i;
zzDir = -1; // 하락
zigzagPt[0] = zzPrice;
zigzagIdx[0] = zzIdx;
ptCnt = 1;
end;
end
else if dir = 1 then begin // 현재 상승 중
if L[i] < zzPrice * (1 - th / 100.0) then begin // 하락 반전
dir = -1;
zzPrice = L[i];
zzIdx = i;
zzDir = -1;
if ptCnt < 100 then begin // 배열 범위 체크: 100은 zigzagPt 배열의 최대 크기
zigzagPt[ptCnt] = zzPrice;
zigzagIdx[ptCnt] = zzIdx;
ptCnt = ptCnt + 1; // <-- 이 부분을 수정했습니다. (이전 49줄 에러 관련)
end;
end;
end
else if dir = -1 then begin // 현재 하락 중
if H[i] > zzPrice * (1 + th / 100.0) then begin // 상승 반전
dir = 1;
zzPrice = H[i];
zzIdx = i;
zzDir = 1;
if ptCnt < 100 then begin // 배열 범위 체크: 100은 zigzagPt 배열의 최대 크기
zigzagPt[ptCnt] = zzPrice;
zigzagIdx[ptCnt] = zzIdx;
ptCnt = ptCnt + 1; // <-- 이 부분을 수정했습니다. (이전 62줄 에러 관련)
end;
end;
end;
end;
// 5파 시작점 (4파 저점) 탐색 조건
// 최소 5개의 ZigZag 포인트가 있어야 조건 검증 가능 (ptCnt >= 5)
// zigzagPt[0], zigzagPt[1], zigzagPt[2], zigzagPt[3], zigzagPt[4]까지 필요
if ptCnt >= 5 then begin
// 상승 5파동 구조 검증
if zigzagPt[0] < zigzagPt[1] and
zigzagPt[1] > zigzagPt[2] and
zigzagPt[2] < zigzagPt[3] and
zigzagPt[3] > zigzagPt[4] then begin
// 주어진 조건 1, 2, 3 적용
if (zigzagPt[1] < zigzagPt[2] and // 조건 1a (1파 고점 < 2파 저점 - 사용자 조건)
zigzagPt[2] < zigzagPt[3] and // 조건 1b (2파 저점 < 3파 고점)
zigzagPt[2] > zigzagPt[0] and // 조건 2 (2파 저점 > 1파 시작점)
zigzagPt[1] <= zigzagPt[4]) then begin // 조건 3 (1파 고점 <= 4파 저점)
valid = true;
end;
end;
end;
if valid then
find(1); // 조건 만족 시 검색
2025-05-22
178
글번호 191059
종목검색
답변완료
추가분봉 데이터영역 문의
안녕하세요
건수를 적게잡고 종목추가를 하면 빠르게추가돼고 건수를 1000이상 설정하면
너무 오래걸립니다 제공돼는 건수가 10000바로 알고있읍니다
동일한 차트영역에 1분봉,60분봉 ,120분봉추가하는데 data봉이 너무늦게열립니다
주기차이가 있어 늦게열리는가 봅니다 시스템트레이딩할때 바 건수는 상관없나요
수식에 data 건수를 삽입가능하신지 문의 드립니다
input : short(12),long(26),sig(9),신고신저기간(100),최근N봉(20);
input : 진입시작시간(230000),당일청산시간(020000),손절틱(100),감시틱(70),되돌림틱(20);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0);
var : macdv(0,Data1),macds(0,Data1);
var : macdv1(0,Data2),macds1(0,Data2);
var : macdv2(0,Data3),macds2(0,Data3);
var : NH(False,Data1),NL(False,Data1);
macdv = data1(macd(short,long));
macds = data1(Ema(macdv,sig));
macdv1 = data2(macd(short,long));
macds1 = data2(Ema(macdv1,sig));
macdv2 = data3(macd(short,long));
macds2 = data3(Ema(macdv2,sig));
NH = Data1(CountIf(H > highest(H,신고신저기간)[1],최근N봉) >= 1);
NL = Data1(countif(L < lowest(L,신고신저기간)[1],최근N봉) >= 1);
if sDate != sDate[1] Then
SetStopEndofday(당일청산시간);
if Bdate != Bdate[1] Then
SetStopEndofday(0);
var : Tcond(False);
if (sdate != sDate[1] and sTime >= 당일청산시간) or
(sdate == sDate[1] and sTime >= 당일청산시간 and sTime[1] < 당일청산시간) Then
Tcond = false;
if (sdate != sDate[1] and sTime >= 진입시작시간) or
(sdate == sDate[1] and sTime >= 진입시작시간 and sTime[1] < 진입시작시간) Then
Tcond = true;
if Tcond == true Then
{
if MarketPosition <= 0 and
NL == true and
CrossUp(MACDV,0) and
MACDV1 > 0 and
MACDV2 > 0 and
macdv > macds and
macdv1 > macds1 and
macdv2 > macds2 Then
Buy("b");
if MarketPosition >= 0 and
NH == true and
CrossDown(MACDV,0) and
MACDV1 < 0 and
MACDV2 < 0 and
macdv < macds and
macdv1 < macds1 and
macdv2 < macds2 Then
Sell("s");
if MarketPosition == 1 and (CrossDown(MACDV1,MACDS1) or CrossDown(MACDV2,MACDS2)) Then
ExitLong("bx");
if MarketPosition == -1 and (CrossUp(MACDV1,MACDS1) or CrossUp(MACDV2,MACDS2)) Then
ExitShort("sx");
if MarketPosition == 1 Then
{
if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*감시틱 Then
ExitLong("btrx",AtStop,highest(H,BarsSinceEntry)-PriceScale*되돌림틱);
}
if MarketPosition == -1 Then
{
if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*감시틱 Then
ExitShort("strx",AtStop,lowest(L,BarsSinceEntry)+PriceScale*되돌림틱);
}
}
SetStopLoss(PriceScale*손절틱,PointStop);
감사합니다
2025-05-21
222
글번호 191055
시스템
답변완료
부탁드립니다
수고하십니다
아래수식을 예스로 부탁드립니다
//@version=2
study("Fractal Adaptive Moving Average",shorttitle="FRAMA",overlay=true)
price = input(hl2)
len = input(defval=10,minval=1)
FC = input(defval=1,minval=1)
SC = input(defval=150,minval=1)
len1 = len/2
w = log(2/(SC+1))
H1 = highest(high,len1)
L1 = lowest(low,len1)
N1 = (H1-L1)/len1
H2 = highest(high,len)[len1]
L2 = lowest(low,len)[len1]
N2 = (H2-L2)/len1
H3 = highest(high,len)
L3 = lowest(low,len)
N3 = (H3-L3)/len
dimen1 = (log(N1+N2)-log(N3))/log(2)
dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
alpha1 = exp(w*(dimen-1))
oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
oldN = (2-oldalpha)/oldalpha
N = (((SC-FC)*(oldN-1))/(SC-1))+FC
alpha_ = 2/(N+1)
alpha = alpha_<2/(SC+1)?2/(SC+1):(alpha_>1?1:alpha_)
out = (1-alpha)*nz(out[1]) + alpha*price
plot(out,title="FRAMA",color=blue,transp=0)
2025-05-21
236
글번호 191054
지표
답변완료
문의드립니다.
아래의 트레이딩뷰 수식을 변환부탁드립니다.
===========================
// Settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
supertrendAtrPeriod         =input.int (defval =10 ,step =1 ,title ="ATR Length",group ="Supertrend")
supertrendAtrMultiplier       =input.float (defval =2.7 ,step =0.1 ,title ="ATR Multiplier",group ="Supertrend")
//  Heikin Ashi Candles
haOpen =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,open )
haHigh =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,high )
haLow =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,low )
haClose =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,close )
plotcandle (haOpen <haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Green Candles',color =green ,wickcolor =green ,bordercolor =green ,display =display.pane )
plotcandle (haOpen >=haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Red Candles',color =red ,wickcolor =red ,bordercolor =red ,display =display.pane )
plot (display =display.status_line ,series =haOpen ,color =green )
plot (display =display.status_line ,series =haHigh ,color =green )
plot (display =display.status_line ,series =haLow ,color =red )
plot (display =display.status_line ,series =haClose ,color =red )
//  HA Supertrend
haTrueRange =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,ta.atr (supertrendAtrPeriod ))// math.max(haHigh - haLow, math.abs(haHigh - haClose[1]), math.abs(haLow - haClose[1]))
haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange )
haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange )
float trendingUp =na
float trendingDown =na
direction =0
trendingUp :=haClose [1 ]>trendingUp [1 ]?math.max (haSupertrendUp ,trendingUp [1 ]):haSupertrendUp
trendingDown :=haClose [1 ]<trendingDown [1 ]?math.min (haSupertrendDown ,trendingDown [1 ]):haSupertrendDown
direction :=haClose >trendingDown [1 ]?1 :haClose <trendingUp [1 ]?-1 :nz (direction [1 ],1 )
supertrend =direction ==1 ?trendingUp :trendingDown
supertrendUp =ta.change (direction )<0
supertrendDown =ta.change (direction )>0
//  Plots, Lines, and Labels
bodyMiddle =plot ((haOpen +haClose )/2 ,display =display.none )
downTrend =plot (direction <0 ?supertrend :na ,"Down Trend",color =red ,style =plot.style_linebr )
upTrend =plot (direction <0 ?na :supertrend ,"Up Trend",color =green ,style =plot.style_linebr )
fill (bodyMiddle ,upTrend ,lightGreen ,fillgaps =false )
fill (bodyMiddle ,downTrend ,lightRed ,fillgaps =false )
=========================
첨부된 그림처럼 빨강선과 녹색선을 표현하고자 합니다.
atr길이와 atr배수을 변경할수 있게 부탁드립니다.
수식이 길어서 전략은 삭제하고 라인만 나타나보이게 올렸으니 감안하여 부족한 부분이 있다면 보완해주셔서 변환해주시면 더욱 감사하겠습니다.
오늘도 감사합니다. 수고하세요!!!
2025-05-21
290
글번호 191045
지표