답변완료
수식문의드립니다
안녕하세요~
아래와 같이 수식을 짰는데 테스트 중 원인을 알수없는 진입을 발견해 문의드립니다
-----------------------------------------------
input : HB(13163), LB(13128), TT1(120000), TT2(213200), TD(20220826), MDD(100000);
var : Bsystem(False), Ssystem(False), Fsystem(true), unitP(0), condition1(true);
// MACD 변수
input : 타주기분(5),short(12),long(26),sig(9);
var : S1(0),D1(0),TM(0),EP1(0),EP2(0),EP3(0),MACDO(0);
var : TF(0),xma1(0),xma2(0),idx(0),Prexma1(0),Prexma2(0),MACDV(0),MACDS(0),PreMACDS(0);
unitP = floor(MDD/(2*ATR(14)*BigPointValue*1400));
if sDate >= TD && TT2 > sTime && sTime > TT1 Then condition11 = true;
Else condition11 = False;
if condition11 == true Then
{
MessageLog("rsi %.4f, ATR %.4f, unitP %.4f, MP %.4f, macdV %.4f", rsi(14), ATR(14), unitP, MarketPosition, MACDV);
MessageLog("H %.4f, L %.4f, BS %4s, SS %4s, FS %4s", H, L, Bsystem, Ssystem, Fsystem);
// 횡보구간 이탈 - 회귀 - 매수매도구간 진입
if H > HB + 15 Then Fsystem = False;
if L < LB - 15 Then Fsystem = False;
if HB > C && C > LB && condition1 == true Then Fsystem = true;
if H > HB + 30 Then
{
Bsystem = true;
condition1 = False;
}
if L < LB - 30 Then
{
Ssystem = true;
condition1 = False;
}
// 진입
if Bsystem == true && RSI(14) <= 30 Then Buy("b1-1", OnClose, Def, unitP);
if Ssystem == true && RSI(14) >= 70 Then Sell("s2-1", OnClose, Def, unitP);
if Fsystem == true Then
{
if RSI(14) <= 30 Then Buy("b3-1", OnClose, Def, unitP);
if RSI(14) >= 70 Then Sell("s3-1", OnClose, Def, unitP);
}
//청산
if marketposition == 1 then
{
ExitLong("xL1", AtLimit, EntryPrice + 2*ATr(14));
ExitLong("xL2", AtStop, EntryPrice - 2*ATr(14));
}
if MarketPosition == -1 Then
{
ExitShort("xS1", AtLimit, EntryPrice - 2*ATr(14));
ExitShort("xS2", AtStop, EntryPrice + 2*ATr(14));
}
}
// 매수매도 off
Ep1 = 2/(short+1);
Ep2 = 2/(long+1);
Ep3 = 2/(sig+1);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
idx = idx + 1;
Prexma1 = xma1[1];
Prexma2 = xma2[1];
PreMACDS = MACDS[1];
}
if idx <= 1 then
{
xma1 = C;
xma2 = C;
MACDV = xma1-xma2;
MACDS = MACDV;
MACDO = MACDV-MACDS;
}
else
{
xma1 = C * EP1 + Prexma1 * (1-EP1);
xma2 = C * EP2 + Prexma2 * (1-EP2);
MACDV = xma1-xma2;
MACDS = MACDV * EP3 + PreMACDS * (1-EP3);
MACDO = MACDV-MACDS;
}
if condition11 == True Then
{
if Ssystem == true && MACDV > 0 Then Ssystem = False;
if Bsystem == true && MACDV < 0 Then Bsystem = false;
}
}
------------------------------
제가 짠 수식에선 Bsystem, Ssystem, Fsystem 최소한 셋 중 하나는 true이어야만 진입이 발생할 수 있는데
첨부한 사진을 보면 21:31에 세 조건이 모두 false인데 매도진입이 이뤄졌습니다
=>로그 상의 BS, SS, FS 값이 모두 false인 상황
3개 조건에 한해서만 진입조건을 걸어뒀는데 왜 이런 진입이 일어났는지 아무리 봐도 모르겠어서 살펴봐주시면 감사하겠습니다
감사합니다
2022-08-28
1327
글번호 161794
시스템
답변완료
추가수정 요청...
잘 작동됩니다. 감사합니다. ^^
문제가 있는데요
*정해진 체크시간에 돌파 체크하고 만약 돌파 하지 않는다면 아래 정해진 시간에 강제 진입
위 상황인데 정해진 시간 전에 종료가 되면 또 한번 진입합니다.
만약 이평선 크로스로 진입하되 강제시간 전에 수익이 난다면 추가 진입을 안했으면 좋겠습니다.
감사합니다. ^^
-----------------------------------------------------------------------------------------------------
안녕하세요
예스스탁입니다.
input : position(1), P1(5),P2(20);
input : StartTime(220000),EndTime(223000),xtime(55800),vol1(1);
input : 최소수익틱수(100),수익감소틱수(10);
var : Tcond(false);
IF xtime > starttime Then
SetStopEndofday(xtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(xtime);
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
if MarketPosition == 0 and position == 1 Then
Buy("b2",OnClose,Def,vol1);
if MarketPosition == 0 and position == -1 Then
Sell("s2",OnClose,Def,vol1);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
IF xtime <= starttime Then
{
SetStopEndofday(0);
}
}
var1 = ma(C,P1);
Var2 = ma(C,P2);
if Tcond == true Then
{
if MarketPosition == 0 and position == 1 and CrossUp(var1,Var2) Then
Buy("b1",OnClose,Def,vol1);
if MarketPosition == 0 and position == -1 and CrossDown(var1,Var2) Then
Sell("s1",OnClose,Def,vol1);
}
if MarketPosition == 1 and Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소수익틱수 Then
ExitLong("매수스탑x",AtStop,Highest(H,BarsSinceEntry)-PriceScale*수익감소틱수);
if MarketPosition == -1 and lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소수익틱수 Then
ExitShort("매도스턉x",AtStop,lowest(L,BarsSinceEntry)+PriceScale*수익감소틱수);
즐거운 하루되세요
> 스카스카 님이 쓴 글입니다.
> 제목 : 수정 요청드립니다. ^^ 감사합니다~
> 아래 수식을 사용하고 있습니다.
추가 내용을 요청드립니다. ^^ 감사합니다.
-----------------------------------------------------------------------------------------------------
포지션에 따라 (1 or -1) 매수/매도 진입을 하는데
이동평균선 돌파 후 진입 기능 (5일선 / 20일선)
*단 정해진 체크시간에 돌파 체크하고 만약 돌파 하지 않는다면 아래 정해진 시간에 강제 진입
[예시]
1. 매수의 경우 22시 부터 22시 30분까지 이동평균선 (5일선 20일선) 5일선이 20일선을 크로스하면 매수진입...
만약 크로스 안하면 22시 30분 강제 진입
매도의 경우 반대
** 5일선 10일선은 마음대로 (일수)수정이 가능했으면 좋겠습니다.
** 이동평균선 진입 시간도 수정이 가능하면 좋겠습니다.
요청 드립니다~ ^^
--------------------------------------------------------------------------------------------------------
input : position1(1),ntime1(223000),vol1(1);
input : xtime(55800);
input : 최소수익틱수(100),수익감소틱수(10);
var : ST(0);
if Bdate != Bdate[1] Then
{
ST = sTime;
}
if ST > 0 then
{
if (sdate != sdate[1] and stime >= ntime1) or
(sdate == sdate[1] and stime >= ntime1 and stime[1] < ntime1) Then
{
if position1 == 1 Then
Buy("매수-1",OnClose,DEf,vol1);
if position1 == -1 Then
Sell("매도-1",OnClose,DEf,vol1);
}
if MarketPosition == 1 and Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*최소수익틱수 Then
ExitLong("매수스탑x",AtStop,Highest(H,BarsSinceEntry)-PriceScale*수익감소틱수);
if MarketPosition == -1 and lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*최소수익틱수 Then
ExitShort("매도스턉x",AtStop,lowest(L,BarsSinceEntry)+PriceScale*수익감소틱수);
}
IF Xtime > ST Then
SetStopEndofday(Xtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Xtime);
}
if (sdate != sdate[1] and stime >= ST) or
(sdate == sdate[1] and stime >= ST and stime[1] < ST) Then
{
IF Xtime <= ST Then
{
SetStopEndofday(0);
}
}
2022-08-26
1366
글번호 161785
시스템