답변완료
안녕하세요 ^^
안녕하세요, 비트코인 변동성 돌파전략을 개발중인데요,
당일 매매횟수가 0 이면 entry 값으로 매수를 하구요,
매매횟수가 1 이상이면 당일 고가에 매수를 하는 전략을 짜고 있습니다.
var : weight(0),entry(0),k(0);
k = iff(dayclose(1) > dayclose(2),1,0.4);
weight = (dayhigh(1) - daylow(1)) * k;
entry = weight + dayopen;
if marketposition == 0 then begin
if entriestoday(date) == 0 and h < entry then buy("Entry",atstop,entry);
else if entriestoday(date) > 0 and h < dayhigh and barssinceexit(1) > 3 then buy("Re Entry",atstop,dayhigh);
end;
if marketposition == 1 then begin
if nextbarstime == 085000 then exitlong("Exit",atmarket);
if dayopen - weight < l then exitlong("Cut",atstop,dayopen - weight);
end;
## entriestoday(사용자함수)
Input : nDate(Numeric);
Var : Count(0);
Count = 0 ;
For Value1 = 0 To 10 {
If EntryDate(Value1) == nDate Then
Count = Count + 1;
}
EntriesToday = Count;
그런데 당일 매매횟수가 0번이어서 entry 값에 매수가 들어가야 하는데 re entry, 즉 당일 고가에 매수가 들어가고 있습니다.
해결 방법 좀 알 수 있을까요?
2021-06-08
1494
글번호 149749
시스템
답변완료
수식 문의
질문 두가지가 있습니다
1.
if MarketPosition == -1 Then
{
if X5 == -1 and CountIf(X5 == 1,BarsSinceEntry) == 0 and
X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 >= Var27 Then
ExitShort("풋청1",AtMarket);
풋 청산을 예로 들면, 위 식에서, 진입한 이후에 5선(X)이 변곡3번이상 나오고 양봉이면 청산인데요..
Barsinceentry 대신에 5와 20이 Deadcross가 나오고 나서 5선이 상승 변곡이 3번이상나오면 청산으로 하고 싶은데요..countif 조건문에서 Deadcross를 넣을수는 없어서요..
Countif(X == 1 and X !=[1], Deadcross(5,20)) >=3 <- 이렇게 표현하고 싶습니다.
2. 보내주신 수식 설명좀 부탁드릴수 있을까요?
var : mav1(0),mav2(0),mav3(0),S(0),T(0);
mav1 = ma(C,20);
mav2 = ma(C,60);
mav3 = ma(C,240);
if mav1 > mav1[1] Then
S = 1;
if mav1 < mav1[1] Then
S = -1;
if CrossUp(mav2,mav3) Then
T = 1;
if CrossDown(mav2,mav3) Then
{
T = -1;
if mav1 > mav2 Then
T = 0;
}
if T == -1 and CrossUp(mav1,mav2) Then
T = -2;
if T == -2 and (mav1 < mav2 or mav1 > mav3) Then
T = 0;
if T == -2 and S == -1 and S != S[1] Then
{
T = -3;
Sell();
}
위 조건에서 T = 0 를 다른 조건으로 두번을 썻는데요..수식이 이해가 안되서요
그리고 60-240이 deadcross한 시점에서 60선이 1파동일때만 진입하고 3파동일때는 진입이 안되게 하는건 어떤부분인지 궁금합니다
- 수식을 잘 작동하고 있습니다.
///////////////////////////////////////////////////////////////////////////////
var : Period1(3),Period2(10),Period3(30),Period4(120),X5(0),X20(0),X60(0),XP(0),X(0),Y(0),Z(0),Q(0),Mav1(0), Mav2(0),Mav3(0),Mav4(0);
Input : Left(3),right(3);
var : B5(0),BP60(0),B20(0),B60(0),S5(0),S20(0),S60(0),SP60(0),Bcnt5(0),Bcnt20(0),Bcnt60(0),BcntP60(0), Scnt5(0), Scnt20(0), Scnt60(0),ScntP60(0),H1(0),H2(0),L1(0),L2(0);
InPUT : 진입시작시간(090000), 매매종료시간(153000);
if Bdate != Bdate[1] Then
{
Condition1 = False;
Condition2 = False;
}
Var26 = ema(Ema(Ema(c,period1),period1),period1); //ma(c,period1); //5선
Var27 = ema(Ema(Ema(c,period2),period2),period2); //20선
Var28 = ema(Ema(Ema(c,period3),period3),period3); //60선
Var29 = ema(Ema(Ema(c,period4),period4),period4); //240선
if CrossUp(Var26,Var27) Then
X5 = 1; //5-20 cross
if CrossDown(Var26,Var27) Then
X5 = -1;
if CrossUp(Var27,Var28) Then
X20 = 1; //20-60 cross
if CrossDown(Var27,Var28) Then
X20 = -1;
if CrossUp(Var28,Var29) Then
X60 = 1; //60-240 cross
if CrossDown(Var28,Var29) Then
X60 = -1;
if CrossUp(Var26,Var28) Then
XP = 1; //5-60 cross
if CrossDown(Var26,Var28) Then
XP = -1;
if Var26 > var26[1] Then
X = 1;
if Var26 < var26[1] Then
X = -1;
if Var27 > var27[1] Then // X5 : 5-20 Cross X : 5선
Y = 1; // X20 : 20-60 Cross Y : 20선
if Var27 < var27[1] Then // X60 : 60-240 cross Z : 60선
Y = -1; // XP : 5-60 cross
if Var28 > var28[1] Then
Z = 1;
if Var28 < var28[1] Then
Z = -1;
if X == 1 and X != X[1] and Bdate == Bdate[1] Then
Condition1 = true;
if X == -1 and X != X[1] and Bdate == Bdate[1] Then
Condition2 = true;
//////////////////////상방기준//////////////////
if XP == 1 and X == 1 and Condition1 == true Then //5-60 정배열 & 5상승
{
if X != X[1] Then //5선이 상승변곡 이면 B = 1
{
BP60 = 1;
} //5선이 상승변곡 & 20선 상승 & 5선 20선위 & 몸통이 5 BC 면 B =2
if BP60 == 1 and Y == 1 and Var26 > Var27 and C > O and (C+O)/2 >= var26 Then
{
BP60 = 2;
}
}
else
BP60 = 0;
if sDate == 20210429 and sTime < 92000 Then
MessageLog("%.2f",BP60);
//////////////////////하방기준//////////////////
if XP == -1 and X == -1 and Condition2 == true Then
{
if X!= X[1] Then
{
SP60 = 1;
}
if SP60 == 1 and Y == -1 and Var26 < Var27 and C < O and (C+O)/2 < var26 Then
{
SP60 = 2;
}
}
else
SP60 = 0;
//////////////////////////상방시그널/////////////////
if sTime >= 진입시작시간 and sTime <= 매매종료시간 and
XP == 1 Then
{
if XP != XP[1] Then
BcntP60 = 0;
if BP60 == 2 and BP60 != BP60[1] Then
{
BcntP60 = BcntP60+1;
if BcntP60 <= 1 Then
Buy("BP60");
}
}
////////////////////////하방 시그널//////////////////
if sTime >= 진입시작시간 and sTime <= 매매종료시간 and
XP == -1 Then
{
if XP != XP[1] Then
ScntP60 = 0;
if SP60 == 2 and SP60 != SP60[1] Then
{
ScntP60 = ScntP60+1;
if ScntP60 <= 1 Then
Sell("SP60");
}
}
if MarketPosition == 1 Then
{
if X5 == 1 and CountIf(X5 == -1,BarsSinceEntry) == 0 and
X == -1 and CountIf(X == -1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 <= Var27 then
ExitLong("콜청1",AtMarket);
if X5 == -1 and X == -1 and CountIf(X == -1 and X != X[1],BarsSinceEntry) >= 1 and (C+O)/2 <= Var27 Then
ExitLong("콜정2",AtMarket);
}
if MarketPosition == -1 Then
{
if X5 == -1 and CountIf(X5 == 1,BarsSinceEntry) == 0 and
X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 >= Var27 Then
ExitShort("풋청1",AtMarket);
if X5 == 1 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 1 and (C+O)/2 >= Var27 Then
ExitShort("풋정2",AtMarket);
}
2021-06-08
1737
글번호 149745
시스템