커뮤니티
당일청산좀 추가부탁드립니다.
2019-05-03 08:00:00
193
글번호 128354
당일날 분할 매수한 종목들의 평단가가 + 이면 종가 청산하고 - 이면 그대로 유지하고 그 다음날까지 매수 계속 진행 하는 식을 추가하고 싶어요.
Input : 투자금액(10000000),Period(20), MultiD(2), N(1),시작일(20190503),시작시간(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 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 C < DayClose(1) Then
{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(c,bbdn) 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 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.02 and HH < EntryPrice*1.05 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.06 and HH < EntryPrice*1.10 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.12 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
}}
답변 1
예스스탁 예스스탁 답변
2019-05-03 09:20:52
안녕하세요
예스스탁입니다.
종가수신되면 이미 장이 종료된 시점이므로 청산시간을 지정하셔야 합니다.
또한 시스템은 정규장안에 신호와 주문이 집행되어야 합니다.
봉완성이 다음봉시가가 수신될때이므로
plot1(stime);
위지표로 봉의 시각확인하시고
사용하는 차트주기에서 정규장의 마지막봉의 전봉의 시간을 지정해 주셔야 합니다.
Input : 투자금액(10000000),Period(20), MultiD(2), N(1),시작일(20190503),시작시간(090000),청산시간(151500);
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 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 C < DayClose(1) Then
{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(c,bbdn) 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 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.02 and HH < EntryPrice*1.05 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.06 and HH < EntryPrice*1.10 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.12 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
if (stime >= 청산시간 and stime[1] < 청산시간) and C > AvgEntryPrice then
{
ExitLong("bx");
}
}}
즐거운 하루되세요
> 바나 님이 쓴 글입니다.
> 제목 : 당일청산좀 추가부탁드립니다.
> 당일날 분할 매수한 종목들의 평단가가 + 이면 종가 청산하고 - 이면 그대로 유지하고 그 다음날까지 매수 계속 진행 하는 식을 추가하고 싶어요.
Input : 투자금액(10000000),Period(20), MultiD(2), N(1),시작일(20190503),시작시간(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 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 C < DayClose(1) Then
{
buy("b2",atmarket,def,vv[MaxEntries]);
}
#세번재매수
if MarketPosition == 1 and e == 2 and count < N and CrossDown(c,bbdn) 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 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.02 and HH < EntryPrice*1.05 Then
ExitLong("Bx1",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(1/5)),1);
if Bxcond2 == false and HH >= EntryPrice*1.06 and HH < EntryPrice*1.10 Then
ExitLong("Bx2",AtStop,HH-(HH-EntryPrice)*0.1,"",Floor(MaxContracts*(2/5)),1);
if Bxcond3 == false and HH >= EntryPrice*1.12 Then
ExitLong("Bx3",AtStop,HH-(HH-EntryPrice)*0.1);
}}