커뮤니티
스토캐스틱 수식 수정 부탁드립니다.
2018-10-03 13:14:21
149
글번호 122396
아래 로직으로 1분봉 챠트에 적용해 보았습니다.
당일누적손실 30틱 규정이 먹히지 않는거 같습니다.
1. 오버나잇은 하되 하루안에 누적손실이 커지면 당일만 거래를 멈추었다가 다음날부터는 다시 매매를 시작하는 수식으로 추가 할수 있을까요??
2. 포지션이 없는 구간에서는 시초가가 정배열이면 매수진입, 역배열이면 매도진입 수식 추가 부탁드립니다.
부탁드리겠습니다.
- 아 래 -
Input : 당일누적수익틱수(80),당일누적손실틱수(30),P(120);
input : startdate(20180903),starttime(090000),enddate(20181031),endtime(153000);
input : sto1(20),sto2(12),sto3(12);
VARS: Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),stok(0),stod(0);
if (sdate == enddate and sdate != sdate[1] and stime >= endtime) or
(sdate == enddate and sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if (sdate == startdate and sdate != sdate[1] and stime >= starttime) or
(sdate == startdate and sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Xcond = false;
N1 = NetProfit;
Tcond = true;
}
당일누적수익 = PriceScale*당일누적수익틱수;
당일누적손실 = PriceScale*당일누적손실틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
stok = StochasticsK(sto1,sto2);
stod = StochasticsD(sto1,sto2,sto3);
if Tcond == true and Xcond == false then
{
if crossup(stok,stod) Then
buy();
if CrossDown(stok,stod) 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));
}
답변 1
예스스탁 예스스탁 답변
2018-10-04 11:10:27
안녕하세요
예스스탁입니다.
1
현재 누적손익이 지정한 값에 도달하면
전체구간에서 진입을 멈추게 되어 있습니다.
날짜변경되면 진입을 다시 할수 있게 수정했습니다.
2
시초가 정배열/역배열은 어떤값 기준인지 모르겠습니다.
좀더 자세한 내용을 올려주시기 바랍니다.
3
Input : 당일누적수익틱수(80),당일누적손실틱수(30),P(120);
input : startdate(20180903),starttime(090000),enddate(20181031),endtime(153000);
input : sto1(20),sto2(12),sto3(12);
VARS: Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),stok(0),stod(0);
if (sdate == enddate and sdate != sdate[1] and stime >= endtime) or
(sdate == enddate and sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if (sdate >= startdate and sdate != sdate[1] and stime >= starttime) or
(sdate >= startdate and sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Xcond = false;
N1 = NetProfit;
Tcond = true;
}
당일누적수익 = PriceScale*당일누적수익틱수;
당일누적손실 = PriceScale*당일누적손실틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
stok = StochasticsK(sto1,sto2);
stod = StochasticsD(sto1,sto2,sto3);
if Tcond == true and Xcond == false then
{
if crossup(stok,stod) Then
buy();
if CrossDown(stok,stod) 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));
}
즐거운 하루되세요
> 승부사1 님이 쓴 글입니다.
> 제목 : 스토캐스틱 수식 수정 부탁드립니다.
> 아래 로직으로 1분봉 챠트에 적용해 보았습니다.
당일누적손실 30틱 규정이 먹히지 않는거 같습니다.
1. 오버나잇은 하되 하루안에 누적손실이 커지면 당일만 거래를 멈추었다가 다음날부터는 다시 매매를 시작하는 수식으로 추가 할수 있을까요??
2. 포지션이 없는 구간에서는 시초가가 정배열이면 매수진입, 역배열이면 매도진입 수식 추가 부탁드립니다.
부탁드리겠습니다.
- 아 래 -
Input : 당일누적수익틱수(80),당일누적손실틱수(30),P(120);
input : startdate(20180903),starttime(090000),enddate(20181031),endtime(153000);
input : sto1(20),sto2(12),sto3(12);
VARS: Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),stok(0),stod(0);
if (sdate == enddate and sdate != sdate[1] and stime >= endtime) or
(sdate == enddate and sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if (sdate == startdate and sdate != sdate[1] and stime >= starttime) or
(sdate == startdate and sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Xcond = false;
N1 = NetProfit;
Tcond = true;
}
당일누적수익 = PriceScale*당일누적수익틱수;
당일누적손실 = PriceScale*당일누적손실틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
stok = StochasticsK(sto1,sto2);
stod = StochasticsD(sto1,sto2,sto3);
if Tcond == true and Xcond == false then
{
if crossup(stok,stod) Then
buy();
if CrossDown(stok,stod) 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));
}
이전글