답변완료
수식문의드립니다
안녕하세요~
현재 사용중인 수식에서 시스템이 실행된 시점부터 이 시스템 내에서 수익, 손실을 모두 합쳐
시스템의 총 손익이 제가 설정한 목표수익 이상이면 거래종료시키고 싶습니다
예를들어 목표수익이 50만원인 상황에서 시스템이 -20, -20, -20, +120 수익으로 진입청산 되었다면
4번째 거래 청산시 총 손익이 +60으로 50만원을 넘었을 때 거래종료시키고자 합니다
총손익을 계산해주는 수식은 따로 없는것 같고
거래가 끝나 청산되었을때의 진입, 청산의 틱수를 통해 계산해야할것 같은데
피라미딩까지 되어있다보니 어떻게 계산해야할지 막막하네요
아래 시스템에서 어떻게 구현해야할지 가능하다면 가르쳐주시면 감사하겠습니다!
감사합니다
-----------------
input : TT(25400), TD(20220219), MDD(200000), goalBalance(500000) ;
var : HB(14064.75), LB(13939), Hx(20000), Lx(1);
var : netBalance(0), e60(0), Hcount(0), Lcount(0),B(0),S(0),cnt(0),T1(0), Hstate(true), Lstate(true), N(0), unitP(0), exitC(0), rHB(0), rLB(0);
=> 목표수익을 goalbalance, 총손익을 netbalance라 정의
N = Highest(ATr(14), 100);
unitP = floor(MDD/(N*5*4*600));
exitC = (2-(MaxEntries-1)/2)*N;
e60 = Ema(C,60);
netbalance = ????
if netbalance >= goalbalance then
{
Hstate = false;
Lstate = false;
}
=> netbalance를 계산해 goalbalance 이상이 되면, Hstate, Lstate를 false로 바꿔 거래 정지
if Condition1 == False and sDate >= TD and sTime >= TT Then
{
Condition1 = true;
Hcount = 0;
Lcount = 0;
T1 = TotalTrades;
}
if Condition1 == true Then
{
B = 0;
S = 0;
if TotalTrades-T1 > 0 Then
{
For cnt = 1 to TotalTrades-T1
{
if MarketPosition(cnt) == 1 Then B = B+1;
if MarketPosition(cnt) == -1 Then S = S+1;
}
}
Hcount = B + IFf(MarketPosition == 1,1,0);
Lcount = S + IFf(MarketPosition == -1,1,0);
if B>0 && B == Hcount then HB = rHB;
if S>0 && S == Lcount then LB = rLB;
if MarketPosition <= 0 and Hstate == true then
{
Buy("b1",AtStop,HB,unitP);
Buy("b2",AtStop,HB+0.5*N,unitP);
Buy("b3",AtStop,HB+N,unitP);
Buy("b4",AtStop,HB+1.5*N,unitP);
}
if MarketPosition >= 0 and Lstate == true then
{
Sell("s1",AtStop,LB,unitP);
Sell("s2",AtStop,LB-0.5*N,unitP);
Sell("s3",AtStop,LB-N,unitP);
Sell("s4",AtStop,LB-1.5*N,unitP);
}
if marketposition ==1 Then
{
rHB = Highest(H, BarsSinceEntry+1) ;
if rHB < HB+0.5*N Then
Buy("b2.",AtStop,HB+0.5*N,unitP);
if rHB < HB+N Then
Buy("b3.",AtStop,HB+N,unitP);
if rHB < HB+1.5*N Then
Buy("b4.",AtStop,HB+1.5*N,unitP);
if e60 < HB+2*N Then
Exitlong("exitB1", atstop, HB-exitC);
if e60 >= HB+2*N and CrossDown(close, e60) Then
{
ExitLong("exitB2") ;
Hstate = false ;
}
Exitlong("exitB3", AtLimit, Hx);
}
if marketposition == -1 Then
{
rLB = Lowest(L, BarsSinceEntry+1);
if rLB > LB-0.5*N Then
Sell("s2.",AtStop,LB-0.5*N,unitP);
if rLB > LB-N Then
Sell("s3.",AtStop,LB-N,unitP);
if rLB > LB-1.5*N Then
Sell("s4.",AtStop,LB-1.5*N,unitP);
if e60 > LB-2*N Then
ExitShort("exitS1", atstop, LB+exitC);
if e60 <= LB-2*N and CrossUp(close, e60) Then
{
ExitShort("exitS2");
Lstate = false ;
}
exitshort("exitS3", AtLimit, Lx);
}
if Hcount >= 3 Then Hstate = False;
if Lcount >= 3 Then Lstate = False;
if H >= Hx then Hstate = false;
if L <= Lx then Lstate = false;
}
2022-02-20
1182
글번호 156479
시스템
답변완료
수정부탁드립니다========================
식을 간단하게 줄일수있나요?
부탇드립니다
Input : 돌파소리(0);
var : pv(0),r1(0),s1(0),r11(0),s11(0),r31(0),s31(0),r41(0),s41(0),r51(0),s51(0),r61(0),s61(0);
var : r71(0),s71(0),r81(0),s81(0),r91(0),s91(0),r101(0),s101(0);
var1 = Floor(opend(0)/2.0);
var2 = var1*2.0;
var3 = opend(0)-var2;
var4 = highest(C,dayindex+1);
var5 = lowest(C,dayindex+1);
if var3 >= 1.0 Then
pv = var2+2.0;
Else
pv = var2;
r1 = pv+1.0;
s1 = pv-1.0;
r11 = pv+2.0;
s11 = pv-2.0;
r31 = pv+3.0;
s31 = pv-3.0;
r41 = pv+4.0;
s41 = pv-4.0;
r51 = pv+5.0;
s51 = pv-5.0;
r61 = pv+6.0;
s61 = pv-6.0;
r71 = pv+7.0;
s71 = pv-7.0;
r81 = pv+8.0;
s81 = pv-8.0;
r91 = pv+9.0;
s91 = pv-9.0;
r101 = pv+10.0;
s101 = pv-10.0;
if DayHigh >= pv and pv >= DayLow Then
plot1(pv,"시초가",WHITE); Else NoPlot(1);
if DayHigh >= r1 and r1 >= DayLow Then
plot2(r1,"라인",WHITE); Else NoPlot(2);
if DayHigh >= s1 and s1 >= DayLow Then
plot3(s1,"라인",WHITE); Else NoPlot(3);
if DayHigh >= r11 and r11 >= DayLow Then
plot4(r11,"라인",WHITE); Else NoPlot(4);
if DayHigh >= s11 and s11 >= DayLow Then
plot5(s11,"라인",WHITE); Else NoPlot(5);
if DayHigh >= r31 and r31 >= DayLow Then
plot6(r31,"라인",WHITE); Else NoPlot(6);
if DayHigh >= s31 and s31 >= DayLow Then
plot7(s31,"라인",WHITE); Else NoPlot(7);
if DayHigh >= r41 and r41 >= DayLow Then
plot8(r41,"라인",WHITE); Else NoPlot(8);
if DayHigh >= s41 and s41 >= DayLow Then
plot9(s41,"라인",WHITE); Else NoPlot(9);
if DayHigh >= r51 and r51 >= DayLow Then
plot10(r51,"라인",WHITE); Else NoPlot(10);
if DayHigh >= s51 and s51 >= DayLow Then
plot11(s51,"라인",WHITE); Else NoPlot(11);
if DayHigh >= r61 and r61 >= DayLow Then
plot12(r61,"라인",WHITE); Else NoPlot(12);
if DayHigh >= s61 and s61 >= DayLow Then
plot13(s61,"라인",WHITE); Else NoPlot(13);
if DayHigh >= r71 and r71 >= DayLow Then
plot14(r71,"라인",WHITE); Else NoPlot(14);
if DayHigh >= s71 and s71 >= DayLow Then
plot15(s71,"라인",WHITE); Else NoPlot(15);
if DayHigh >= r81 and r81 >= DayLow Then
plot16(r81,"라인",WHITE); Else NoPlot(16);
if DayHigh >= s81 and s81 >= DayLow Then
plot17(s81,"라인",WHITE); Else NoPlot(17);
if DayHigh >= r91 and r91 >= DayLow Then
plot18(r91,"라인",WHITE); Else NoPlot(18);
if DayHigh >= s91 and s91 >= DayLow Then
plot19(s91); Else NoPlot(19);
if DayHigh >= r101 and r101 >= DayLow Then
plot20(r101,"라인",WHITE); Else NoPlot(20);
if DayHigh >= s101 and s101 >= DayLow Then
plot21(s101,"라인",WHITE); Else NoPlot(21);
if pv > pv[1] then {
plot34(pv, "상향돌파");
if 돌파소리 == 1 then {
PlaySound("C:₩Users₩Windows 10₩Desktop₩sound₩상30초.wav");
}
}
if pv < pv[1] then {
plot35(pv, "하향돌파");
if 돌파소리 == 1 then {
PlaySound("C:₩Users₩Windows 10₩Desktop₩sound₩하20초.wav");
}
}
// PLOT64(diver_tema,"상상승승");
// if 상하소리 == 1 then {
// PlaySound("C:₩Users₩Windows 10₩Desktop₩sound₩상30초.wav");
// }
2022-02-20
645
글번호 156476
지표