예스스탁
예스스탁 답변
2024-09-25 11:36:50
안녕하세요
예스스탁입니다.
피라미딩을 다른진입신호만 허용으로 설정하고 적용하시면 됩니다.
var : src(0);
src = close;
input : length1(2),percent1(1);
input : mav1(6);//"1:SMA", "2:EMA", "3:WMA", "4:TMA", "5:VAR", "6:WWMA1", "7:ZLEMA1", "8:TSF1"]);
var : valpha(0),vUD11(0),vdd11(0),vUD1(0),vdd1(0),vCMO1(0),varv1(0);
var : wwalpha1(0),WWMA1(0);
var : zxLag1(0),zxEMAData1(0),ZLEMA1(0);
var : lrc1(0),LRs1(0),TSF1(0),mav1g(0);
valpha=2/(length1+1);
vUD11=iff(src>src[1] , src-src[1] , 0);
vdd11=iff(src<src[1] , src[1]-src , 0);
vUD1=AccumN(vUD11,9);
vdd1=AccumN(vdd11,9);
vCMO1= iff(isnan((vUD1-vdd1)/(vUD1+vdd1)) == true,0,(vUD1-vdd1)/(vUD1+vdd1));
varv1 =0.0;
varv1 = iff(isnan(valpha*abs(vCMO1)*src) ==true,0,valpha*abs(vCMO1)*src)+(1-valpha*abs(vCMO1))*iff(isnan(varv1[1])==true,0,varv1[1]);
wwalpha1 = 1/ length1;
WWMA1 = 0.0;
WWMA1 = wwalpha1*src + (1-wwalpha1)*iff(isnan(WWMA1[1])==true,0,WWMA1[1]);
zxLag1 = iff(length1/2==round(length1/2,0) , length1/2 , (length1 - 1) / 2);
zxEMAData1 = (src + (src - src[zxLag1]));
ZLEMA1 = ema(zxEMAData1, length1);
TSF1 = LRL(src, length1)+LRs(src, length1);
if mav1== 1 Then #SMA
{
mav1g = ma(src,length1) ;
}
if mav1== 2 Then #EMA
{
mav1g = ema(src, length1);
}
if mav1== 3 Then #WMA
{
mav1g = wma(src, length1);
}
if mav1== 4 Then #TMA
{
mav1g = ma(ma(src, Ceiling(length1 / 2)), floor(length1 / 2) + 1);
}
if mav1== 5 Then #VAR
{
mav1g = varv1;
}
if mav1== 6 Then #WWMA1
{
mav1g = WWMA1;
}
if mav1== 7 Then #ZLEMA1
{
mav1g = ZLEMA1;
}
if mav1== 8 Then #TSF1
{
mav1g = TSF1;
}
var : fark1(0),longStop1(0),longStop1Prev(0),shortStop1(0),shortStop1Prev(0);
var : dir1(0),MT1(0),OTT1(0),OTT1C(0);
fark1=mav1g*percent1*0.01;
longStop1 = mav1g - fark1;
longStop1Prev = iff(isnan(longStop1[1]) == true, longStop1,longStop1[1]);
longStop1 = iff(mav1g > longStop1Prev , max(longStop1, longStop1Prev) , longStop1);
shortStop1 = mav1g + fark1;
shortStop1Prev = iff(isnan(shortStop1[1]) == true, shortStop1,shortStop1[1]);
shortStop1 = iff(mav1g < shortStop1Prev , min(shortStop1, shortStop1Prev) , shortStop1);
dir1 = 1;
dir1 = iff(isnan(dir1[1])==true,dir1,dir1[1]);
dir1 = iff(dir1 == -1 and mav1g > shortStop1Prev , 1 , IFf(dir1 == 1 and mav1g < longStop1Prev , -1 , dir1));
MT1 = iff(dir1==1 , longStop1 , shortStop1);
OTT1= iff(mav1g>MT1 , MT1*(200+percent1)/200 , MT1*(200-percent1)/200 );
OTT1C = IFf(OTT1[2] > OTT1[3] , green ,red);
var11 = mav1g;
var12 = IFf(isnan(OTT1[2]) == true,0,OTT1[1]);
input : length2(2),percent2(2);
input : mav2(6);//"1:SMA", "2:EMA", "3:WMA", "4:TMA", "5:VAR", "6:WWMA2", "7:ZLEMA2", "8:TSF2"]);
var : valpha2(0),vUD21(0),vdd21(0),vUD2(0),vdd2(0),vCMO2(0),varv2(0);
var : wwalpha2(0),WWMA2(0);
var : zxLag2(0),zxEMAData2(0),ZLEMA2(0);
var : lrc2(0),LRs2(0),TSF2(0),mav2g(0);
valpha2=2/(length2+1);
vUD21=iff(src>src[1] , src-src[1] , 0);
vdd21=iff(src<src[1] , src[1]-src , 0);
vUD2=AccumN(vUD21,9);
vdd2=AccumN(vdd21,9);
vCMO2= iff(isnan((vUD2-vdd2)/(vUD2+vdd2)) == true,0,(vUD2-vdd2)/(vUD2+vdd2));
varv2 =0.0;
varv2 = iff(isnan(valpha2*abs(vCMO2)*src) ==true,0,valpha2*abs(vCMO2)*src)+(1-valpha2*abs(vCMO2))*iff(isnan(varv2[1])==true,0,varv2[1]);
wwalpha2 = 1/ length2;
WWMA2 = 0.0;
WWMA2 = wwalpha2*src + (1-wwalpha2)*iff(isnan(WWMA2[1])==true,0,WWMA2[1]);
zxLag2 = iff(length2/2==round(length2/2,0) , length2/2 , (length2 - 1) / 2);
zxEMAData2 = (src + (src - src[zxLag2]));
ZLEMA2 = ema(zxEMAData2, length2);
TSF2 = LRL(src, length2)+LRs(src, length2);
if mav2== 1 Then #SMA
{
mav2g = ma(src,length2) ;
}
if mav2== 2 Then #EMA
{
mav2g = ema(src, length2);
}
if mav2== 3 Then #WMA
{
mav2g = wma(src, length2);
}
if mav2== 4 Then #TMA
{
mav2g = ma(ma(src, Ceiling(length2 / 2)), floor(length2 / 2) + 1);
}
if mav2== 5 Then #VAR
{
mav2g = varv2;
}
if mav2== 6 Then #WWMA2
{
mav2g = WWMA2;
}
if mav2== 7 Then #ZLEMA2
{
mav2g = ZLEMA2;
}
if mav2== 8 Then #TSF2
{
mav2g = TSF2;
}
var : fark2(0),longStop2(0),longStop2Prev(0),shortStop2(0),shortStop2Prev(0);
var : dir2(0),MT2(0),OTT2(0),OTT2C(0);
fark2=mav2g*percent2*0.01;
longStop2 = mav2g - fark2;
longStop2Prev = iff(isnan(longStop2[1]) == true, longStop2,longStop2[1]);
longStop2 = iff(mav2g > longStop2Prev , max(longStop2, longStop2Prev) , longStop2);
shortStop2 = mav2g + fark2;
shortStop2Prev = iff(isnan(shortStop2[1]) == true, shortStop2,shortStop2[1]);
shortStop2 = iff(mav2g < shortStop2Prev , min(shortStop2, shortStop2Prev) , shortStop2);
dir2 = 1;
dir2 = iff(isnan(dir2[1])==true,dir2,dir2[1]);
dir2 = iff(dir2 == -1 and mav2g > shortStop2Prev , 1 , IFf(dir2 == 1 and mav2g < longStop2Prev , -1 , dir2));
MT2 = iff(dir2==1 , longStop2 , shortStop2);
OTT2= iff(mav2g>MT2 , MT2*(200+percent2)/200 , MT2*(200-percent2)/200 );
OTT2C = IFf(OTT2[2] > OTT2[3] , green ,red);
var21 = mav2g;
var22 = IFf(isnan(OTT2[2]) == true,0,OTT2[1]);
input : length3(2),percent3(3);
input : mav3(6);//"1:SMA", "2:EMA", "3:WMA", "4:TMA", "5:VAR", "6:WWMA3", "7:ZLEMA3", "8:TSF3"]);
var : valpha3(0),vUD31(0),vdd31(0),vUD3(0),vdd3(0),vCMO3(0),varv3(0);
var : wwalpha3(0),WWMA3(0);
var : zxLag3(0),zxEMAData3(0),ZLEMA3(0);
var : lrc3(0),LRs3(0),TSF3(0),mav3g(0);
valpha3=2/(length3+1);
vUD31=iff(src>src[1] , src-src[1] , 0);
vdd31=iff(src<src[1] , src[1]-src , 0);
vUD3=AccumN(vUD31,9);
vdd3=AccumN(vdd31,9);
vCMO3= iff(isnan((vUD3-vdd3)/(vUD3+vdd3)) == true,0,(vUD3-vdd3)/(vUD3+vdd3));
varv3 =0.0;
varv3 = iff(isnan(valpha3*abs(vCMO3)*src) ==true,0,valpha3*abs(vCMO3)*src)+(1-valpha3*abs(vCMO3))*iff(isnan(varv3[1])==true,0,varv3[1]);
wwalpha3 = 1/ length3;
WWMA3 = 0.0;
WWMA3 = wwalpha3*src + (1-wwalpha3)*iff(isnan(WWMA3[1])==true,0,WWMA3[1]);
zxLag3 = iff(length3/2==round(length3/2,0) , length3/2 , (length3 - 1) / 2);
zxEMAData3 = (src + (src - src[zxLag3]));
ZLEMA3 = ema(zxEMAData3, length3);
TSF3 = LRL(src, length3)+LRs(src, length3);
if mav3== 1 Then #SMA
{
mav3g = ma(src,length3) ;
}
if mav3== 2 Then #EMA
{
mav3g = ema(src, length3);
}
if mav3== 3 Then #WMA
{
mav3g = wma(src, length3);
}
if mav3== 4 Then #TMA
{
mav3g = ma(ma(src, Ceiling(length3 / 2)), floor(length3 / 2) + 1);
}
if mav3== 5 Then #VAR
{
mav3g = varv3;
}
if mav3== 6 Then #WWMA3
{
mav3g = WWMA3;
}
if mav3== 7 Then #ZLEMA3
{
mav3g = ZLEMA3;
}
if mav3== 8 Then #TSF3
{
mav3g = TSF3;
}
var : fark3(0),longStop3(0),longStop3Prev(0),shortStop3(0),shortStop3Prev(0);
var : dir3(0),MT3(0),OTT3(0),OTT3C(0);
fark3=mav3g*percent3*0.01;
longStop3 = mav3g - fark3;
longStop3Prev = iff(isnan(longStop3[1]) == true, longStop3,longStop3[1]);
longStop3 = iff(mav3g > longStop3Prev , max(longStop3, longStop3Prev) , longStop3);
shortStop3 = mav3g + fark3;
shortStop3Prev = iff(isnan(shortStop3[1]) == true, shortStop3,shortStop3[1]);
shortStop3 = iff(mav3g < shortStop3Prev , min(shortStop3, shortStop3Prev) , shortStop3);
dir3 = 1;
dir3 = iff(isnan(dir3[1])==true,dir3,dir3[1]);
dir3 = iff(dir3 == -1 and mav3g > shortStop3Prev , 1 , IFf(dir3 == 1 and mav3g < longStop3Prev , -1 , dir3));
MT3 = iff(dir3==1 , longStop3 , shortStop3);
OTT3= iff(mav3g>MT3 , MT3*(200+percent3)/200 , MT3*(200-percent3)/200 );
OTT3C = IFf(OTT3[2] > OTT3[3] , green ,red);
var31 = mav3g;
var32 = IFf(isnan(OTT3[2]) == true,0,OTT3[1]);
input : length4(2),percent4(4);
input : mav4(6);//"1:SMA", "2:EMA", "3:WMA", "4:TMA", "5:VAR", "6:WWMA4", "7:ZLEMA4", "8:TSF4"]);
var : valpha4(0),vUD41(0),vdd41(0),vUD4(0),vdd4(0),vCMO4(0),varv4(0);
var : wwalpha4(0),WWMA4(0);
var : zxLag4(0),zxEMAData4(0),ZLEMA4(0);
var : lrc4(0),LRs4(0),TSF4(0),mav4g(0);
valpha4=2/(length4+1);
vUD41=iff(src>src[1] , src-src[1] , 0);
vdd41=iff(src<src[1] , src[1]-src , 0);
vUD4=AccumN(vUD41,9);
vdd4=AccumN(vdd41,9);
vCMO4= iff(isnan((vUD4-vdd4)/(vUD4+vdd4)) == true,0,(vUD4-vdd4)/(vUD4+vdd4));
varv4 =0.0;
varv4 = iff(isnan(valpha4*abs(vCMO4)*src) ==true,0,valpha4*abs(vCMO4)*src)+(1-valpha4*abs(vCMO4))*iff(isnan(varv4[1])==true,0,varv4[1]);
wwalpha4 = 1/ length4;
WWMA4 = 0.0;
WWMA4 = wwalpha4*src + (1-wwalpha4)*iff(isnan(WWMA4[1])==true,0,WWMA4[1]);
zxLag4 = iff(length4/2==round(length4/2,0) , length4/2 , (length4 - 1) / 2);
zxEMAData4 = (src + (src - src[zxLag4]));
ZLEMA4 = ema(zxEMAData4, length4);
TSF4 = LRL(src, length4)+LRs(src, length4);
if mav4== 1 Then #SMA
{
mav4g = ma(src,length4) ;
}
if mav4== 2 Then #EMA
{
mav4g = ema(src, length4);
}
if mav4== 3 Then #WMA
{
mav4g = wma(src, length4);
}
if mav4== 4 Then #TMA
{
mav4g = ma(ma(src, Ceiling(length4 / 2)), floor(length4 / 2) + 1);
}
if mav4== 5 Then #VAR
{
mav4g = varv4;
}
if mav4== 6 Then #WWMA4
{
mav4g = WWMA4;
}
if mav4== 7 Then #ZLEMA4
{
mav4g = ZLEMA4;
}
if mav4== 8 Then #TSF4
{
mav4g = TSF4;
}
var : fark4(0),longStop4(0),longStop4Prev(0),shortStop4(0),shortStop4Prev(0);
var : dir4(0),MT4(0),OTT4(0),OTT4C(0);
fark4=mav4g*percent4*0.01;
longStop4 = mav4g - fark4;
longStop4Prev = iff(isnan(longStop4[1]) == true, longStop4,longStop4[1]);
longStop4 = iff(mav4g > longStop4Prev , max(longStop4, longStop4Prev) , longStop4);
shortStop4 = mav4g + fark4;
shortStop4Prev = iff(isnan(shortStop4[1]) == true, shortStop4,shortStop4[1]);
shortStop4 = iff(mav4g < shortStop4Prev , min(shortStop4, shortStop4Prev) , shortStop4);
dir4 = 1;
dir4 = iff(isnan(dir4[1])==true,dir4,dir4[1]);
dir4 = iff(dir4 == -1 and mav4g > shortStop4Prev , 1 , IFf(dir4 == 1 and mav4g < longStop4Prev , -1 , dir4));
MT4 = iff(dir4==1 , longStop4 , shortStop4);
OTT4= iff(mav4g>MT4 , MT4*(200+percent4)/200 , MT4*(200-percent4)/200 );
OTT4C = IFf(OTT4[2] > OTT4[3] , green ,red);
var41 = mav4g;
var42 = IFf(isnan(OTT4[2]) == true,0,OTT4[1]);
If CrossUP(var12, Var22) Then
Buy("b1",OnClose,Def,1);
If CrossUP(var12, Var32) Then
Buy("b2",OnClose,Def,1);
If CrossUP(var12, Var42) Then
Buy("b3",OnClose,Def,1);
If CrossDown(var12, Var22) Then
Sell("s1",OnClose,Def,1);
If CrossDown(var12, Var32) Then
Sell("s2",OnClose,Def,1);
If CrossDown(var12, Var42) Then
Sell("s3",OnClose,Def,1);
즐거운 하루되세요
> 사노소이 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다
> percent 값을 2, 3, 4 이런 식으로 3개 추가하고 1이 각 값을 상,하향 돌파할 때,
1계약 씩 3회 추가 진입하는 수식으로 수정 부탁드립니다.
var : src(0);
src = close;
input : length(2),percent(1);
input : mav(6);//"1:SMA", "2:EMA", "3:WMA", "4:TMA", "5:VAR", "6:WWMA", "7:ZLEMA", "8:TSF"]);
var : valpha(0),vud1(0),vdd1(0),vUD(0),vdd(0),vCMO(0),varv(0);
var : wwalpha(0),WWMA(0);
var : zxLag(0),zxEMAData(0),ZLEMA(0);
var : lrc(0),LRs(0),TSF(0),MAvg(0);
valpha=2/(length+1);
vud1=iff(src>src[1] , src-src[1] , 0);
vdd1=iff(src<src[1] , src[1]-src , 0);
vUD=AccumN(vud1,9);
vDD=AccumN(vdd1,9);
vCMO= iff(isnan((vUD-vDD)/(vUD+vDD)) == true,0,(vUD-vDD)/(vUD+vDD));
varv =0.0;
varv = iff(isnan(valpha*abs(vCMO)*src) ==true,0,valpha*abs(vCMO)*src)+(1-valpha*abs(vCMO))*iff(isnan(varv[1])==true,0,varv[1]);
wwalpha = 1/ length;
WWMA = 0.0;
WWMA = wwalpha*src + (1-wwalpha)*iff(isnan(WWMA[1])==true,0,WWMA[1]);
zxLag = iff(length/2==round(length/2,0) , length/2 , (length - 1) / 2);
zxEMAData = (src + (src - src[zxLag]));
ZLEMA = ema(zxEMAData, length);
TSF = LRL(src, length)+LRS(src, length);
if mav== 1 Then #SMA
{
MAvg = ma(src,Length) ;
}
if mav== 2 Then #EMA
{
Mavg = ema(src, Length);
}
if mav== 3 Then #WMA
{
Mavg = wma(src, Length);
}
if mav== 4 Then #TMA
{
Mavg = ma(ma(src, Ceiling(length / 2)), floor(length / 2) + 1);
}
if mav== 5 Then #VAR
{
Mavg = varv;
}
if mav== 6 Then #WWMA
{
Mavg = WWMA;
}
if mav== 7 Then #ZLEMA
{
Mavg = ZLEMA;
}
if mav== 8 Then #TSF
{
Mavg = TSF;
}
var : fark(0),longStop(0),longStopPrev(0),shortStop(0),shortStopPrev(0);
var : dir(0),MT(0),OTT(0),OTTC(0);
fark=MAvg*percent*0.01;
longStop = MAvg - fark;
longStopPrev = iff(isnan(longStop[1]) == true, longStop,longStop[1]);
longStop = iff(MAvg > longStopPrev , max(longStop, longStopPrev) , longStop);
shortStop = MAvg + fark;
shortStopPrev = iff(isnan(shortStop[1]) == true, shortStop,shortStop[1]);
shortStop = iff(MAvg < shortStopPrev , min(shortStop, shortStopPrev) , shortStop);
dir = 1;
dir = iff(isnan(dir[1])==true,dir,dir[1]);
dir = iff(dir == -1 and MAvg > shortStopPrev , 1 , IFf(dir == 1 and MAvg < longStopPrev , -1 , dir));
MT = iff(dir==1 , longStop , shortStop);
OTT= iff(MAvg>MT , MT*(200+percent)/200 , MT*(200-percent)/200 );
OTTC = IFf(OTT[2] > OTT[3] , green ,red);
var1 = MAvg;
var2 = IFf(isnan(OTT[2]) == true,0,OTT[1]);
If CrossUP(var1, Var2) Then
Buy();
If CrossDown(var1, Var2) Then
Sell();