답변완료
수식도움 부탁드립니다.
아래수식에서 타주기 5분은 어떤 오류가 있는지 출력이 되지 않는데,
점검 부탁드립니다.
15분/1분은 정상출력됨
///////////
input : 분1(15),분2(5),length(1),mult(2),useClose(true);
var : ATrv(0),longStop(0),longStopprev(0),shortStop(0),shortStopPrev(0);
var : ATrv2(0),longStop2(0),longStopprev2(0),shortStop2(0),shortStopPrev2(0);
var : dir(1),dir1(0), dir2(1),dir21(0);;
var : truehighv(0),TrueLowv(0),hsatr(0) ;
var : truehighv2(0),TrueLowv2(0),hsatr2(0) ;
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : xClose1(0),xOpen1(0),xHigh1(0),xLow1(0);
var : xClose2(0),xOpen2(0),xHigh2(0),xLow2(0);
var : xClose12(0),xOpen12(0),xHigh12(0),xLow12(0);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0),ii(0),ii2(0);
var : sum(0),longStop1(0),shortStop1(0),hv(0),lv(0);
var : sum2(0),longStop12(0),shortStop12(0),hv2(0),lv2(0);
var : longcolor(Crimson),shortcolor(Blue),tx(0);
Array : TrueRangev[100](0),AccumValue[100](0);
Array : TrueRangev2[100](0),AccumValue2[100](0);
Array : oo[100](0),hh[100](0),ll[100](0),cc[100](0),hsc[100](0);
Array : oo2[100](0),hh2[100](0),ll2[100](0),cc2[100](0),hsc2[100](0);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
///
TF1 = TM%분1;
TF2 = TM%분2;
///
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and 분1 > 1 and TM >= TM[1]+분1) or
(Bdate == Bdate[1] and 분1 == 1 and TM > TM[1]) Then
{
ii = ii +1;
For cnt = 99 DownTo 1
{
TrueRangev[cnt] = TrueRangev[cnt-1];
oo[cnt] = oo[cnt-1];
hh[cnt] = hh[cnt-1];
ll[cnt] = ll[cnt-1];
cc[cnt] = cc[cnt-1];
hsc[cnt] = hsc[cnt-1];
AccumValue[cnt] = AccumValue[cnt-1];
}
AccumValue[0] = AccumValue[0]+1;
oo[0] = o;
hh[0] = h;
ll[0] = l;
Xopen1 = xopen[1];
Xhigh1 = xhigh[1];
Xlow1 = xlow[1];
Xclose1 = xclose[1];
longStop1 = longStop[1];
ShortStop1 = shortStop[1];
dir1 = dir[1];
var1 = 0;
var2 = 0;
}
if hh[0] > 0 and h > hh[0] Then
hh[0] = h;
if ll[0] > 0 and l < ll[0] Then
ll[0] = l;
cc[0] = c;
if ii == 1 then
{
xOpen = oo[0];
xClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
xHigh = MaxList(hh[0], xOpen, xClose);
xLow = MinList(ll[0], xOpen,xClose);
}
else
{
xClose = (oo[0]+hh[0]+ll[0]+cc[0])/4;
xOpen = (xOpen1 + xClose1)/2 ;
xHigh = MaxList(hh[0], xOpen, xClose) ;
xLow = MinList(ll[0], xOpen, xClose) ;
}
hsc[0] = xclose ;
if ii > 1 Then
{
If xClose1 > xHigh then
TrueHighv = xClose1;
else
TrueHighv = xHigh;
If xClose1 < xLow then
TrueLowv = xClose1;
else
TrueLowv = xLow;
TrueRangev[0] = TrueHighv - TrueLowv;
}
if ii > 2 Then
{
if TrueRangev[length-1] > 0 Then
{
sum = 0;
For cnt = 0 to length-1
{
sum = sum + TrueRangev[cnt];
}
hsatr = sum/length;
}
atrv = mult * hsatr;
hv = 0;
lv = 0;
For cnt = 0 to length-1
{
if useClose == true Then
{
if hv == 0 or (hv > 0 and hsc[cnt] > hv) Then
hv = hsc[cnt];
if lv == 0 or (lv > 0 and hsc[cnt] < lv) Then
lv = hsc[cnt];
}
Else
{
if hv == 0 or (hv > 0 and hh[cnt] > hv) Then
hv = hh[cnt];
if lv == 0 or (lv > 0 and ll[cnt] < lv) Then
lv = ll[cnt];
}
}
longStop = hv - atrv;
longStopPrev = longStop1;
longStop = iff(hsc[1] > longStopPrev , max(longStop, longStopPrev) , longStop);
shortStop = lv + atrv;
shortStopPrev = shortStop1;
shortStop = iff(hsc[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop);
dir = iff(hsc[0] > shortStopPrev , 1 ,iff(hsc[0] < longStopPrev , -1 , dir1));
}
######
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분2 > 1 and TF2 < TF2[1]) or
(Bdate == Bdate[1] and 분2 > 1 and TM >= TM[1]+분2) or
(Bdate == Bdate[1] and 분2 == 1 and TM > TM[1]) Then
{
ii2 = ii2 +1;
For cnt = 99 DownTo 1
{
TrueRangev2[cnt] = TrueRangev2[cnt-1];
oo2[cnt] = oo2[cnt-1];
hh2[cnt] = hh2[cnt-1];
ll2[cnt] = ll2[cnt-1];
cc2[cnt] = cc2[cnt-1];
hsc2[cnt] = hsc2[cnt-1];
AccumValue2[cnt] = AccumValue2[cnt-1];
}
AccumValue2[0] = AccumValue2[0]+1;
oo2[0] = o;
hh2[0] = h;
ll2[0] = l;
Xopen2 = xopen12[1];
Xhigh2 = xhigh12[1];
Xlow2 = xlow12[1];
Xclose2 = xclose12[1];
longStop12 = longStop2[1];
ShortStop12 = shortStop2[1];
dir21 = dir2[1];
var3 = 0;
var4 = 0;
}
if hh2[0] > 0 and h > hh2[0] Then
hh2[0] = h;
if ll2[0] > 0 and l < ll2[0] Then
ll2[0] = l;
cc2[0] = c;
if ii2 == 1 then
{
xOpen2 = oo2[0];
xClose2 = (oo2[0]+hh2[0]+ll2[0]+cc2[0])/4;
xHigh2 = MaxList(hh2[0], xOpen2, xClose2);
xLow2 = MinList(ll2[0], xOpen2,xClose2);
}
else
{
xClose2 = (oo2[0]+hh2[0]+ll2[0]+cc2[0])/4;
xOpen2 = (xOpen12 + xClose12)/2 ;
xHigh2 = MaxList(hh[0], xOpen2, xClose2) ;
xLow2 = MinList(ll[0], xOpen2, xClose2) ;
}
hsc2[0] = xclose2 ;
if ii2 > 1 Then
{
If xClose12 > xHigh2 then
TrueHighv2 = xClose12;
else
TrueHighv2 = xHigh2;
If xClose12 < xLow2 then
TrueLowv2 = xClose12;
else
TrueLowv2 = xLow2;
TrueRangev2[0] = TrueHighv2 - TrueLowv2;
}
if ii2 > 2 Then
{
if TrueRangev2[length-1] > 0 Then
{
sum2 = 0;
For cnt = 0 to length-1
{
sum2 = sum2 + TrueRangev2[cnt];
}
hsatr2 = sum2/length;
}
atrv2 = mult * hsatr2;
hv2 = 0;
lv2 = 0;
For cnt = 0 to length-1
{
if useClose == true Then
{
if hv2 == 0 or (hv2 > 0 and hsc2[cnt] > hv2) Then
hv2 = hsc2[cnt];
if lv2 == 0 or (lv2 > 0 and hsc2[cnt] < lv2) Then
lv2 = hsc2[cnt];
}
Else
{
if hv2 == 0 or (hv2 > 0 and hh2[cnt] > hv2) Then
hv2 = hh2[cnt];
if lv2 == 0 or (lv2 > 0 and ll2[cnt] < lv2) Then
lv2 = ll2[cnt];
}
}
longStop2 = hv2 - atrv2;
longStopPrev2 = longStop12;
longStop2 = iff(hsc2[1] > longStopPrev2 , max(longStop2, longStopPrev2) , longStop2);
shortStop2 = lv2 + atrv2;
shortStopPrev2 = shortStop12;
shortStop2 = iff(hsc2[1] < shortStopPrev2 , min(shortStop2, shortStopPrev2) , shortStop2);
dir2 = iff(hsc2[0] > shortStopPrev2 , 1 ,iff(hsc2[0] < longStopPrev2 , -1 , dir21));
}
}
///////////////
var : ATrvv(0),lS(0),lSprev(0),sS(0),sSPrev(0);
var : hscv(0),dirv(1);
var : th(0),TL(0),TRv(0),hsatrv(0) ;
var : xC(0),xO(0),xH(0),xL(0);
if index == 0 then
{
xO = open;
xC = (O+H+L+C)/4;
xH = MaxList( high, xO, xC);
xL = MinList( low, xO,xC);
}
else
{
xC = (O+H+L+C)/4;
xO = (xO[1] + xC[1])/2 ;
xH = MaxList(High, xO, xC) ;
xL = MinList(Low, xO, xC) ;
}
////////
If xC[1] > xH then
TH = xC[1];
else
TH = xH;
If xC[1] < xL then
TL = xC[1];
else
TL = xL;
TRv = TH - TL;
hsatrv = ma(TRv,length);
hscv = xC;
atrvv = mult * hsatrv;
lS = IFf(useClose , highest(hscv, length) , highest(xH,length)) - atrvv;
lSPrev = lS[1];
lS = iff(hscv[1] > lSPrev , max(lS, lSPrev) , lS);
sS = IFf(useClose , lowest(hscv, length) , lowest(xL,length)) + atrvv;
sSPrev = sS[1];
sS = iff(hscv[1] < sSPrev , min(sS, sSPrev) , sS);
dirv = iff(hscv > sSPrev , 1 ,iff(hscv < lSPrev , -1 , dirv));
/////////////////
IF dir == 1 Then
{
plot1(longStop,"Long Stop",longColor);
NoPlot(2);
}
Else
{
NoPlot(1);
plot2(shortStop,"Short Stop",shortColor);
}
//////////////
IF dirv == 1 Then
{
plot3(lS,"1분Long Stop",plum);
NoPlot(4);
}
Else
{
NoPlot(3);
plot4(sS,"1분Short Stop",lime);
}
//////
IF dir2 == 1 Then
{
plot5(longStop2 ,"5분Long Stop",orange);
NoPlot(6);
}
Else
{
NoPlot(5);
plot6(shortStop2,"5분Short Stop",Cyan);
}
2022-12-08
767
글번호 164422
지표
답변완료
수식부탁합니다
그림처럼 a지점이 TL13 이기도 하고 TL12이기도 합니다
새로운TL13이 발생하든 아니든 한 변수로 리턴하고 싶습니다
1.저[1,1]과 저[2,1] 사이의 캔들 중 가장 큰 고가를 Pinkline 으로 리턴 가능할까요?
2.다른 방벙이 있다면 그 또한 부탁합니다.
3.답 좀....
if MarketPosition == 1 매수포지션
if MarketPosition == -1 매도포지션
if MarketPosition == 0 무포지션
if MarketPosition <= 0 ?
if MarketPosition >= 0 ?
4.crossdown(mav5,mav20) and c<redline
이 조건이 하나의 캔들로 완성이 되면 작동이 안되는지요?
감사합니다~
input:length(6);
Var:j(0),jj(0),HH(0),LL(0),최종고가(0),최종저가(0),최종꼭지점(""),처리구분(""),
TL1(0),Text1(0),TL2(0),TL3(0),TL4(0),TL5(0),TL12(0),TL13(0),TL14(0),TL15(0),T(0),고점변곡(""),저점변곡("");
var : clr1(0),clr2(0),BE(0),SE(0);
Array:고[10,4](0),저[10,4](0); // 1:가격,2:Index,3:sDate,4:sTime
#==========================================#
HH = IFF(0==1,C,H);
LL = IFF(0==1,C,L);
If Index == 0 Then
{
고[1,1] = HH;
저[1,1] = LL;
}
Condition1 = Highest(HH,length) == HH and 최종고가 <> HH;
Condition2 = Lowest (LL,length) == LL and 최종저가 <> LL;
처리구분 = "";
If Condition1 and Condition2 Then // 기간고점과 기간저점 동시 발생
{
If 최종꼭지점 == "저점" Then
{
If 저[1,1] > LL Then 처리구분 = "저점처리";
Else 처리구분 = "고점처리";
}
Else If 최종꼭지점 == "고점" Then
{
If 고[1,1] < HH Then 처리구분 = "고점처리";
Else 처리구분 = "저점처리";
}
}
Else If Condition1 Then 처리구분 = "고점처리";
Else If Condition2 Then 처리구분 = "저점처리";
#==========================================#
If 처리구분 == "고점처리" Then
{
T = 1;
최종고가 = HH; // 신규고점을 체크하기 위해 저장
If 최종꼭지점 == "저점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
고[j,jj] = 고[j-1,jj];
}
}
고[1,1] = HH;
고[1,2] = Index;
고[1,3] = sDate;
고[1,4] = sTime;
TL1 = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
If 1 == 1 Then
{
Text1 = Text_New(고[1,3],고[1,4],고[1,1],NumToStr(고[1,1],2));
Text_SetStyle(Text1, 0, 1);
Text_SetColor(Text1,Red);
}
TL_SetSize(TL1,1);
TL_SetColor(TL1,Gray);
}
Else If 고[1,1] < HH Then // 1번 고점보다 높은 고가 출현
{
고[1,1] = HH;
고[1,2] = Index;
고[1,3] = sDate;
고[1,4] = sTime;
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
// 시작점은 변동없고 끝점의 위치가 현재 봉으로 연장된 것임
If 1 == 1 Then
{
Text_SetLocation(Text1,고[1,3],고[1,4],고[1,1]);
Text_SetString(Text1,NumToStr(고[1,1],2));
}
}
최종꼭지점 = "고점";
}
#==========================================#
If 처리구분 == "저점처리" Then
{
T = -1;
최종저가 = LL;
If 최종꼭지점 == "고점" then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
저[j,jj] = 저[j-1,jj];
}
}
저[1,1] = LL;
저[1,2] = Index;
저[1,3] = sDate;
저[1,4] = sTime;
TL1 = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
If 1 == 1 Then
{
Text1 = Text_New(저[1,3],저[1,4],저[1,1],NumToStr(저[1,1],2));
Text_SetStyle(Text1, 0, -1);
Text_SetColor(Text1,Blue);
}
TL_SetSize(TL1,1);
TL_SetColor(TL1,Gray);
}
Else If 저[1,1] > LL then
{
저[1,1] = LL;
저[1,2] = Index;
저[1,3] = sDate;
저[1,4] = sTime;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
If 1 == 1 Then
{
Text_SetLocation(Text1,저[1,3],저[1,4],저[1,1]);
Text_SetString(Text1,NumToStr(저[1,1],2));
}
}
최종꼭지점 = "저점";
}
if T == -1 and T[1] != -1 Then
{
TL12 = TL_New(고[2,3],고[2,4],고[2,1],sdate,stime,고[2,1]);
TL_Delete(TL13);
TL13 = TL_New(고[1,3],고[1,4],고[1,1],Sdate,Stime,고[1,1]);
TL_SetExtRight(TL13,true);
TL_SetSize(TL13,2);
TL_SetColor(TL12,clr1);
TL_SetSize(TL12,2);
clr1 = Pink;
TL_SetColor(TL13,Pink);
}
if T == 1 and T[1] != 1 Then
{
TL14= TL_New(저[2,3],저[2,4],저[2,1],sdate,stime,저[2,1]);
TL_Delete(TL15);
TL15= TL_New(저[1,3],저[1,4],저[1,1],sdate,stime,저[1,1]);
TL_SetExtRight(TL15,true);
TL_SetColor(TL14,clr2);
TL_SetSize(TL14,2);
clr2 = LightBlue;
TL_SetColor(TL15,clr2);
TL_SetSize(TL15,2);
}
2022-12-11
825
글번호 164421
지표
답변완료
문의드립니다
indicator("Nadaraya-Watson Envelope [LuxAlgo]",overlay=true,max_bars_back=1000,max_lines_count=500,max_labels_count=500)
length = input.float(500,'Window Size',maxval=500,minval=0)
h = input.float(8.,'Bandwidth')
mult = input.float(3.)
src = input.source(close,'Source')
up_col = input.color(#39ff14,'Colors',inline='col')
dn_col = input.color(#ff1100,'',inline='col')
disclaimer = input(false, 'Hide Disclaimer')
//----
n = bar_index
var k = 2
var upper = array.new_line(0)
var lower = array.new_line(0)
lset(l,x1,y1,x2,y2,col)=>
line.set_xy1(l,x1,y1)
line.set_xy2(l,x2,y2)
line.set_color(l,col)
line.set_width(l,2)
if barstate.isfirst
for i = 0 to length/k-1
array.push(upper,line.new(na,na,na,na))
array.push(lower,line.new(na,na,na,na))
//----
line up = na
line dn = na
//----
cross_up = 0.
cross_dn = 0.
if barstate.islast
y = array.new_float(0)
sum_e = 0.
for i = 0 to length-1
sum = 0.
sumw = 0.
for j = 0 to length-1
w = math.exp(-(math.pow(i-j,2)/(h*h*2)))
sum += src[j]*w
sumw += w
y2 = sum/sumw
sum_e += math.abs(src[i] - y2)
array.push(y,y2)
mae = sum_e/length*mult
for i = 1 to length-1
y2 = array.get(y,i)
y1 = array.get(y,i-1)
up := array.get(upper,i/k)
dn := array.get(lower,i/k)
lset(up,n-i+1,y1 + mae,n-i,y2 + mae,up_col)
lset(dn,n-i+1,y1 - mae,n-i,y2 - mae,dn_col)
if src[i] > y1 + mae and src[i+1] < y1 + mae
label.new(n-i,src[i],'▼',color=#00000000,style=label.style_label_down,textcolor=dn_col,textalign=text.align_center)
if src[i] < y1 - mae and src[i+1] > y1 - mae
label.new(n-i,src[i],'▲',color=#00000000,style=label.style_label_up,textcolor=up_col,textalign=text.align_center)
cross_up := array.get(y,0) + mae
cross_dn := array.get(y,0) - mae
alertcondition(ta.crossover(src,cross_up),'Down','Down')
alertcondition(ta.crossunder(src,cross_dn),'Up','Up')
//----
var tb = table.new(position.top_right, 1, 1
, bgcolor = #35202b)
if barstate.isfirst and not disclaimer
table.cell(tb, 0, 0, 'Nadaraya-Watson Envelope [LUX] Repaints'
, text_size = size.small
, text_color = #cc2f3c)
위수식을(엔벨로프) 예스트레이드수식의로 변경부탁드립니다
미리감사드립니다~~
2022-12-07
1119
글번호 164419
지표