커뮤니티
수식수정 부탁드립니다.
2019-04-29 09:36:02
217
글번호 128182
1. 분할매수 수식인데요. 5분봉기준으로 했을때, 첫번째 매수를 아침 장 시작을 보합이나 마이너스로 시작할때는 바로 매수하는걸로 바꾸고 싶습니다. 그리고 2~3매수도 장중 마이너스 일때만 매수하는걸로 바꾸고 싶습니다.
--------------------------------------------------------
Input : 투자금액(10000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24),P3(99),N(1), 시작일(20190429),시작시간(090000);
Input : loss(5);
var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false),BBup(0),BBdn(0);
var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0),Cma3(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
MAv = ma(C,Period);
MACDV = MACD(Short,long);
MACDS = ema(MACDV,sig);
MACDO = MACDV-MACDS;
Vma = ma(v,VP);
Cma1 = ma(C,P1);
Cma2 = ma(C,P2);
Cma3 = ma(C,P3);
BBup = BollBandUp(Period,MultiD);
BBdn = BollBandDown(Period,MultiD);
vv[0] = floor((투자금액*0.1)/NextBarOpen);
vv[1] = floor((투자금액*0.2)/NextBarOpen);
vv[2] = floor((투자금액*0.3)/NextBarOpen);
vv[3] = floor((투자금액*0.4)/NextBarOpen);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if Tcond == true then{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{
if MarketPosition == 0 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then {
buy("b1",atmarket,def,vv[MaxEntries]);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] Then{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.08 and HH < EntryPrice*1.12 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.15 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-5%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}}}
----------------------------------------------------------------
2. 위에서 수정된 수식을 바탕으로. 1번째 매수는 장시작 보합이나 마이너스일때 매수, 2~3번째 매수를 볼밴하단이 아닌 Williams'R이 95이상일때 매수, 이것또한 장중 마이너스일때 매수하는걸로 바꾸고 싶습니다.
첫 매수가 안이루어 지면 그 이후 매수는 이루어지지 않도록 하고 싶습니다.
그리고 쓸데없는 수식이나 오류가 들어가 있는 부분은 삭제혹은 수정좀 부탁드립니다... 너무 오랜만에 수식수정을 하려니 너무 어렵네요....
답변 1
예스스탁 예스스탁 답변
2019-04-29 12:33:15
안녕하세요
예스스탁입니다.
1
Input : 투자금액(10000000),Period(20), MultiD(2), N(1),시작일(20190429),시작시간(090000);
Input : loss(5);
var : e(0),x(0),count(0),Tcond(false),BBup(0),BBdn(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
BBup = BollBandUp(Period,MultiD);
BBdn = BollBandDown(Period,MultiD);
vv[0] = floor((투자금액*0.1)/NextBarOpen);
vv[1] = floor((투자금액*0.2)/NextBarOpen);
vv[2] = floor((투자금액*0.3)/NextBarOpen);
vv[3] = floor((투자금액*0.4)/NextBarOpen);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if bdate != bdate[1] Then
count = 0;
if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then
count = count+1;
if Tcond == true then
{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then
{
if MarketPosition == 0 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b1",atmarket,def,vv[MaxEntries]);
}
if MarketPosition == 0 and NextBarSdate != sdate and NextBarOpen <= C Then
{
buy("b11",atmarket,def,vv[MaxEntries]);
}
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.08 and HH < EntryPrice*1.12 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.15 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-5%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else
{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}
}
2
Input : 투자금액(10000000),P(20), N(1),시작일(20190429),시작시간(090000);
Input : loss(5);
var : e(0),x(0),count(0),Tcond(false),Wr(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
Wr = willr(P);
vv[0] = floor((투자금액*0.1)/NextBarOpen);
vv[1] = floor((투자금액*0.2)/NextBarOpen);
vv[2] = floor((투자금액*0.3)/NextBarOpen);
vv[3] = floor((투자금액*0.4)/NextBarOpen);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if bdate != bdate[1] Then
count = 0;
if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then
count = count+1;
if Tcond == true then
{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then
{
if MarketPosition == 0 and NextBarSdate != sdate and NextBarOpen <= C Then
{
buy("b11",atmarket,def,vv[MaxEntries]);
}
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and count < N and CrossDown(Wr,95) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(Wr,95) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and count < N and CrossDown(Wr,95) and dayhigh < DayClose(1)*1.18 and stime < 150000 and C < DayClose(1) Then
{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.08 and HH < EntryPrice*1.12 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.15 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-5%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else
{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}
}
즐거운 하루되세요
> 바나 님이 쓴 글입니다.
> 제목 : 수식수정 부탁드립니다.
> 1. 분할매수 수식인데요. 5분봉기준으로 했을때, 첫번째 매수를 아침 장 시작을 보합이나 마이너스로 시작할때는 바로 매수하는걸로 바꾸고 싶습니다. 그리고 2~3매수도 장중 마이너스 일때만 매수하는걸로 바꾸고 싶습니다.
--------------------------------------------------------
Input : 투자금액(10000000),Period(20), MultiD(2), short(12),long(26),sig(9),VP(20),P1(5),P2(24),P3(99),N(1), 시작일(20190429),시작시간(090000);
Input : loss(5);
var : MAv(0),e(0),x(0),cnt(0),count(0),Tcond(false),BBup(0),BBdn(0);
var : MACDV(0),MACDS(0),MACDO(0),Vma(0),Cma1(0),Cma2(0),Cma3(0);
var : HH(0),Bxcond1(false),Bxcond2(false),Bxcond3(false);
var : LL(0),Sxcond1(false),Sxcond2(false),Sxcond3(false);
Array : VV[5](0),XX[5](0);
MAv = ma(C,Period);
MACDV = MACD(Short,long);
MACDS = ema(MACDV,sig);
MACDO = MACDV-MACDS;
Vma = ma(v,VP);
Cma1 = ma(C,P1);
Cma2 = ma(C,P2);
Cma3 = ma(C,P3);
BBup = BollBandUp(Period,MultiD);
BBdn = BollBandDown(Period,MultiD);
vv[0] = floor((투자금액*0.1)/NextBarOpen);
vv[1] = floor((투자금액*0.2)/NextBarOpen);
vv[2] = floor((투자금액*0.3)/NextBarOpen);
vv[3] = floor((투자금액*0.4)/NextBarOpen);
if sdate >= 시작일 and stime >= 시작시간 Then
Tcond = true;
if Tcond == true then{
if (TotalTrades == 0 or MarketPosition == 0 and BarsSinceExit(1) > 2) then{
if MarketPosition == 0 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then {
buy("b1",atmarket,def,vv[MaxEntries]);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] Then{
e = e +1;
if e == 1 then
XX[e] = CurrentContracts;
Else
XX[e] = CurrentContracts-CurrentContracts[1];
}
#두번째 매수
if MarketPosition == 1 and e == 1 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then{
buy("b3",atmarket,def,vv[MaxEntries]);
}
#네번재매수
if MarketPosition == 1 and e == 3 and count < N and CrossDown(c,bbdn) and dayhigh < DayClose(1)*1.18 and stime < 150000 Then{
buy("b4",atmarket,def,vv[MaxEntries]);
}
HH = highest(H,BarsSinceEntry);
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx1" Then
Bxcond1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx2" Then
Bxcond2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "Bx3" Then
Bxcond3 = true;
if Bxcond1 == false and HH >= EntryPrice*1.05 and HH < EntryPrice*1.08 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.08 and HH < EntryPrice*1.12 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.15 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
#3번 매수후 평단가-5%면 전량 매도
if MaxEntries == 4 Then
ExitLong("b.out",AtStop,AvgEntryPrice*(1-loss/100));
}
Else{
e = 0;
X = 0;
Bxcond1 = false;
Bxcond2 = false;
Bxcond3 = false;
}}}
----------------------------------------------------------------
2. 위에서 수정된 수식을 바탕으로. 1번째 매수는 장시작 보합이나 마이너스일때 매수, 2~3번째 매수를 볼밴하단이 아닌 Williams'R이 95이상일때 매수, 이것또한 장중 마이너스일때 매수하는걸로 바꾸고 싶습니다.
첫 매수가 안이루어 지면 그 이후 매수는 이루어지지 않도록 하고 싶습니다.
그리고 쓸데없는 수식이나 오류가 들어가 있는 부분은 삭제혹은 수정좀 부탁드립니다... 너무 오랜만에 수식수정을 하려니 너무 어렵네요....