답변완료
수식 부탁드립니다
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();
2024-09-24
713
글번호 183719
시스템