답변완료
문의드립니다
input : tenkan_len(9),tenkan_mult(2),kijun_len(26),kijun_mult(4),spanB_len(52),spanB_mult(6),offset(26);
Input : 당일수익틱수(100),당일손실틱수(200);
Var : N1(0),dayPl(0),당일수익(0),당일손실(0);
var : Xcond(false);
var : ATR1(0),up1(0),dn1(0),upper1(0),lower1(0),os1(0),spt1(0),max1(0),min1(0),tenkan(0);
var : ATR2(0),up2(0),dn2(0),upper2(0),lower2(0),os2(0),spt2(0),max2(0),min2(0),kijun(0);
var : senkouA(0);
var : ATR3(0),up3(0),dn3(0),upper3(0),lower3(0),os3(0),spt3(0),max3(0),min3(0),senkouB(0);
var : tenkan_css(0),kijun_css(0),cloud_a(0),cloud_b(0),chikou_css(0),tx(0);
ATR1 = ATR(tenkan_len)*tenkan_mult;
up1 = (h+L)/2 + ATR1;
dn1 = (h+L)/2 - ATR1;
upper1 = iff(C[1] < upper1[1],min(up1,upper1[1]),up1);
lower1 = iff(C[1] > lower1[1],max(dn1,lower1[1]),dn1);
os1 = iff(c > upper1 , 1 ,IFf(c < lower1, 0 , os1[1]));
spt1 = iff(os1 == 1 , lower1 , upper1);
max1 = iff(CrossUp(c,spt1) or CrossDown(c,spt1) , max(c,max1[1]) , IFf(os1 == 1 , max(c,max1[1]) , spt1));
min1 = iff(CrossUp(c,spt1) or CrossDown(c,spt1) , min(c,min1[1]) , iff(os1 == 0 , min(c,min1[1]) , spt1));
tenkan = avg(max1,min1);
ATR2 = ATR(kijun_len)*kijun_mult;
up2 = (h+L)/2 + ATR2;
dn2 = (h+L)/2 - ATR2;
upper2 = iff(C[1] < upper2[1],min(up2,upper2[1]),up2);
lower2 = iff(C[1] > lower2[1],max(dn2,lower2[1]),dn2);
os2 = iff(c > upper2 , 1 ,IFf(c < lower2, 0 , os2[1]));
spt2 = iff(os2 == 1 , lower2 , upper2);
max2 = iff(CrossUp(c,spt2) or CrossDown(c,spt2) , max(c,max2[1]) , IFf(os2 == 1 , max(c,max2[1]) , spt2));
min2 = iff(CrossUp(c,spt2) or CrossDown(c,spt2) , min(c,min2[1]) , iff(os2 == 0 , min(c,min2[1]) , spt2));
kijun = avg(max2,min2);
senkouA = avg(kijun,tenkan);
ATR3 = ATR(spanB_len)*spanB_mult;
up3 = (h+L)/2 + ATR3;
dn3 = (h+L)/2 - ATR3;
upper3 = iff(C[1] < upper3[1],min(up3,upper3[1]),up3);
lower3 = iff(C[1] > lower3[1],max(dn3,lower3[1]),dn3);
os3 = iff(c > upper3 , 1 ,IFf(c < lower3, 0 , os3[1]));
spt3 = iff(os3 == 1 , lower3 , upper3);
max3 = iff(CrossUp(c,spt3) or CrossDown(c,spt3) , max(c,max3[1]) , IFf(os3 == 1 , max(c,max3[1]) , spt3));
min3 = iff(CrossUp(c,spt3) or CrossDown(c,spt3) , min(c,min3[1]) , iff(os3 == 0 , min(c,min3[1]) , spt3));
senkouB = avg(max3,min3);
tenkan_css = Red;
kijun_css = Blue;
cloud_a = teal;
cloud_b = red;
chikou_css = Green;
당일수익 = PriceScale*당일수익틱수;
당일손실 = PriceScale*당일손실틱수;
if Bdate != Bdate[1] Then
{
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
}
if Xcond == false Then
{
if CrossUp(tenkan,kijun) Then
{
Buy();
}
if CrossDown(tenkan,kijun) Then
{
sell();
}
}
if MarketPosition == 1 then
{
ExitLong("dbp",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then{
ExitShort("dsp",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts));
}
수고 많으십니다
전에 만들어 주신 수식인데
하루 100틱 수익이나 손실이면 매매 종료하는 수식입니다
문의드릴 내용은 여기에 한 가지 더 추가 부탁드립니다
1계약으로 100틱 수익이 먼저 나다면 매매 종료하고
만약 손실이 먼저 난다면 매매 종료하지 않고
2계약으로 다음 신호부터 진입하여
200틱 손실이나 300틱 익절하면 매매종료
이런 수식을 부탁드립니다
계약수와 손익절 틱수는 최적화 가능하게 변수로 빼주십시요
감사합니다
2024-09-08
679
글번호 183266
시스템