커뮤니티
수고스럽지만 한번더 질문드립니다
2017-11-14 14:10:08
112
글번호 114181
친절한 답변 감사합니다. ㅜㅜ 많이 배우고 있습니다.
아래와 같은 수식에서 매수 조건 이후 진입하고 손절이 되었는데,
손절된 자리에서 그대로 다시 매수 진입해 버리는 현상이 생깁니다.
해결해 주세요 ㅠㅠ
Inputs: 매수1(0), 매수1익(0), 매도1(0), 매도1익(0);
Vars : b1(0), b1e(0), s1(0), s1e(0),
M1(0), D1(0), TM(0), TF(0), cnt(0), TM1(0), TF1(0);
Array : Ovalue[10](0),Hvalue[10](0),Lvalue[10](0),Cvalue[10](0);
b1=매수1; b1e=매수1익;
s1=매도1; s1e=매도1익;
if Bdate != Bdate[1] Then{
M1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then{
if sdate == D1 Then
TM = TimeToMinutes(stime)-M1;
Else
TM = TimeToMinutes(stime)+1440-M1;
TF = TM%60;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF < TF[1]) Then
{
Ovalue[0] = O;
Hvalue[0] = H;
Lvalue[0] = L;
for cnt = 1 to 9{
Ovalue[cnt] = Ovalue[cnt-1][1];
Hvalue[cnt] = Hvalue[cnt-1][1];
Lvalue[cnt] = Lvalue[cnt-1][1];
Cvalue[cnt] = Cvalue[cnt-1][1];
}
Condition1 = false;
Condition2 = false;
Condition11 = Condition1[1];
Condition22 = Condition2[1];
}
#Hvalue[0]보다 큰 고가가 출력하면 값갱신
if H > Hvalue[0] Then
Hvalue[0] = H;
#Lvalue[0]보다 작은 저가가 출력하면 값갱신
if L < Lvalue[0] Then
Lvalue[0] = L;
#Cvalue[0]는 매봉종가
Cvalue[0] = C;
if (TF == 59) then {
if Ovalue[0]<=b1+PriceScale*1
and Cvalue[0]>b1+PriceScale*1
and (Hvalue[0]-Cvalue[0])+(Ovalue[0]-Lvalue[0])<=(Cvalue[0]-Ovalue[0])*2
Then Condition1 = true;
if Ovalue[0]>=s1-PriceScale*1
and Cvalue[0]<s1-PriceScale*1
and (Hvalue[0]-Ovalue[0])+(Cvalue[0]-Lvalue[0])<=(Ovalue[0]-Cvalue[0])*2
Then Condition2 = true;
}
if Condition11 == true Then Buy("매수1",AtLimit,b1);
if Condition22 == true Then Sell("매도1",AtLimit,s1);
#손절 및 청산
setstoploss(pricescale*31,pointstop);
if MarketPosition == 1 then {
if IsEntryName("매수1")
then exitlong("매수1익",AtLimit,b1e);
if C > entryprice and barssinceentry >= 200 then exitlong
("el01",atstop,entryprice+(highest(h,barssinceentry)-entryprice)*0.4);
if TF == 59 Then { if Cvalue[0] < entryprice then
ExitLong ("el00",AtLimit,entryprice);
}
}
if MarketPosition == -1 then {
if IsEntryName("매도1")
then ExitShort("매도1익",AtLimit,s1e);
if C < EntryPrice and BarsSinceEntry >= 200 then exitshort
("es01",atstop,entryprice-(entryprice-lowest(l,barssinceentry))*0.4);
if TF == 59 Then { if Cvalue[0] > entryprice then
ExitShort ("es00",AtLimit,entryprice);
}
}
}
답변 1
예스스탁 예스스탁 답변
2017-11-15 10:45:27
안녕하세요
예스스탁입니다.
Inputs: 매수1(0), 매수1익(0), 매도1(0), 매도1익(0);
Vars : b1(0), b1e(0), s1(0), s1e(0),
M1(0), D1(0), TM(0), TF(0), cnt(0), TM1(0), TF1(0);
var : Bentry(false),Sentry(false);
Array : Ovalue[10](0),Hvalue[10](0),Lvalue[10](0),Cvalue[10](0);
b1=매수1; b1e=매수1익;
s1=매도1; s1e=매도1익;
if Bdate != Bdate[1] Then{
M1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then{
if sdate == D1 Then
TM = TimeToMinutes(stime)-M1;
Else
TM = TimeToMinutes(stime)+1440-M1;
TF = TM%60;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF < TF[1]) Then
{
Ovalue[0] = O;
Hvalue[0] = H;
Lvalue[0] = L;
for cnt = 1 to 9{
Ovalue[cnt] = Ovalue[cnt-1][1];
Hvalue[cnt] = Hvalue[cnt-1][1];
Lvalue[cnt] = Lvalue[cnt-1][1];
Cvalue[cnt] = Cvalue[cnt-1][1];
}
Condition1 = false;
Condition2 = false;
Condition11 = Condition1[1];
Condition22 = Condition2[1];
if MarketPosition <= 0 Then
Bentry = true;
if MarketPosition >= 0 Then
Sentry = true;
}
#Hvalue[0]보다 큰 고가가 출력하면 값갱신
if H > Hvalue[0] Then
Hvalue[0] = H;
#Lvalue[0]보다 작은 저가가 출력하면 값갱신
if L < Lvalue[0] Then
Lvalue[0] = L;
#Cvalue[0]는 매봉종가
Cvalue[0] = C;
if (TF == 59) then {
if Ovalue[0]<=b1+PriceScale*1
and Cvalue[0]>b1+PriceScale*1
and (Hvalue[0]-Cvalue[0])+(Ovalue[0]-Lvalue[0])<=(Cvalue[0]-Ovalue[0])*2
then Condition1 = true;
if Ovalue[0]>=s1-PriceScale*1
and Cvalue[0]<s1-PriceScale*1
and (Hvalue[0]-Ovalue[0])+(Cvalue[0]-Lvalue[0])<=(Ovalue[0]-Cvalue[0])*2
Then Condition2 = true;
}
if Condition11 == true and Bentry == true Then Buy("매수1",AtLimit,b1);
if Condition22 == true and Sentry == true Then Sell("매도1",AtLimit,s1);
if MarketPosition == 1 then {
Bentry = false;
if IsEntryName("매수1") then
exitlong("매수1익",AtLimit,b1e);
if C > entryprice and barssinceentry >= 200 then
exitlong("el01",atstop,entryprice+(highest(h,barssinceentry)-entryprice)*0.4);
if TF == 59 Then {
if Cvalue[0] < entryprice then
ExitLong ("el00",AtLimit,entryprice);
}
}
if MarketPosition == -1 then {
Sentry = false;
if IsEntryName("매도1") then
ExitShort("매도1익",AtLimit,s1e);
if C < EntryPrice and BarsSinceEntry >= 200 then
exitshort("es01",atstop,entryprice-(entryprice-lowest(l,barssinceentry))*0.4);
if TF == 59 Then {
if Cvalue[0] > entryprice then
ExitShort ("es00",AtLimit,entryprice);
}
}
}
#손절 및 청산
setstoploss(pricescale*31,pointstop);
즐거운 하루되세요
> 마인드마스터 님이 쓴 글입니다.
> 제목 : 수고스럽지만 한번더 질문드립니다
> 친절한 답변 감사합니다. ㅜㅜ 많이 배우고 있습니다.
아래와 같은 수식에서 매수 조건 이후 진입하고 손절이 되었는데,
손절된 자리에서 그대로 다시 매수 진입해 버리는 현상이 생깁니다.
해결해 주세요 ㅠㅠ
Inputs: 매수1(0), 매수1익(0), 매도1(0), 매도1익(0);
Vars : b1(0), b1e(0), s1(0), s1e(0),
M1(0), D1(0), TM(0), TF(0), cnt(0), TM1(0), TF1(0);
Array : Ovalue[10](0),Hvalue[10](0),Lvalue[10](0),Cvalue[10](0);
b1=매수1; b1e=매수1익;
s1=매도1; s1e=매도1익;
if Bdate != Bdate[1] Then{
M1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then{
if sdate == D1 Then
TM = TimeToMinutes(stime)-M1;
Else
TM = TimeToMinutes(stime)+1440-M1;
TF = TM%60;
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF < TF[1]) Then
{
Ovalue[0] = O;
Hvalue[0] = H;
Lvalue[0] = L;
for cnt = 1 to 9{
Ovalue[cnt] = Ovalue[cnt-1][1];
Hvalue[cnt] = Hvalue[cnt-1][1];
Lvalue[cnt] = Lvalue[cnt-1][1];
Cvalue[cnt] = Cvalue[cnt-1][1];
}
Condition1 = false;
Condition2 = false;
Condition11 = Condition1[1];
Condition22 = Condition2[1];
}
#Hvalue[0]보다 큰 고가가 출력하면 값갱신
if H > Hvalue[0] Then
Hvalue[0] = H;
#Lvalue[0]보다 작은 저가가 출력하면 값갱신
if L < Lvalue[0] Then
Lvalue[0] = L;
#Cvalue[0]는 매봉종가
Cvalue[0] = C;
if (TF == 59) then {
if Ovalue[0]<=b1+PriceScale*1
and Cvalue[0]>b1+PriceScale*1
and (Hvalue[0]-Cvalue[0])+(Ovalue[0]-Lvalue[0])<=(Cvalue[0]-Ovalue[0])*2
Then Condition1 = true;
if Ovalue[0]>=s1-PriceScale*1
and Cvalue[0]<s1-PriceScale*1
and (Hvalue[0]-Ovalue[0])+(Cvalue[0]-Lvalue[0])<=(Ovalue[0]-Cvalue[0])*2
Then Condition2 = true;
}
if Condition11 == true Then Buy("매수1",AtLimit,b1);
if Condition22 == true Then Sell("매도1",AtLimit,s1);
#손절 및 청산
setstoploss(pricescale*31,pointstop);
if MarketPosition == 1 then {
if IsEntryName("매수1")
then exitlong("매수1익",AtLimit,b1e);
if C > entryprice and barssinceentry >= 200 then exitlong
("el01",atstop,entryprice+(highest(h,barssinceentry)-entryprice)*0.4);
if TF == 59 Then { if Cvalue[0] < entryprice then
ExitLong ("el00",AtLimit,entryprice);
}
}
if MarketPosition == -1 then {
if IsEntryName("매도1")
then ExitShort("매도1익",AtLimit,s1e);
if C < EntryPrice and BarsSinceEntry >= 200 then exitshort
("es01",atstop,entryprice-(entryprice-lowest(l,barssinceentry))*0.4);
if TF == 59 Then { if Cvalue[0] > entryprice then
ExitShort ("es00",AtLimit,entryprice);
}
}
}