커뮤니티
문의드립니다.
2018-08-19 23:57:31
159
글번호 121433
도움주시는 덕분에 도전하고 있습니다. 매번 감사합니다.
1. 기타
아래 전략은 진입횟수 1로 해도 하루 진입횟수를 초과해서 진입하더라구요. 어떻게 수정해야 하나요?
/*
1. 전략내용
LRL지표의 변화율이(현재봉과 두봉전) 상승하면서 일정값 이상이면 매수, 하락하면서 일정값 이하면 매도
매수포지션 상태에서 진입후 LRL의 최고가에서 일정값 이상 하락하면 매도
매도포지션 상태에서 진입후 LRL의 최저가에서 일정값 이상 상승하면 매수
2. 기타
LRL지표를 이용하여 TrailingStop과 같은 기능을 구현한게 눈에 띔
매수와 매도 변수를 각각 따로 최적화 하는 것이 갠적으로 걸림..
*/
inputs: ndays(30),//10~100(10)
pctup(0.01),//0.001~0.01(0.001)
pctdn(0.005),//0.001~0.01(0.001)
jmpup(0.20),//0.10~0.60(0.02)
jmpdn(0.18);//0.10~0.60(0.02)
vars: pf(0),le(0),se(0);
pf = LRL(close, ndays);
if marketposition == 0 then begin
if pf / pf[2]*100 > 100 + jmpup then begin
buy("B1", atmarket);
le = 1;
end;
if pf / pf[2]*100 < 100 - jmpdn then begin
sell("S1", atmarket);
se = 1;
end;
end;
input :
진입횟수(1),
손절률(1),
익절률(1)
;
var : count(0),T1(0);
input : 진입시간(90000),제한시간(150000),청산시간(153400);
var : Tcond(false);
SetStopLoss(손절률,PercentStop);
SetStopProfittarget(익절률,PercentStop);
if stime == 청산시간 or (stime > 청산시간 and stime < 청산시간) Then{
Tcond = false;
if MarketPosition == 1 Then
exitlong();
if MarketPosition == -1 Then
ExitShort();
}
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then
{
Tcond = true;
T1 = TotalTrades;
}
if (sdate != sdate[1] and stime >= 제한시간) or
(sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then
{
Tcond = false;
}
if MarketPosition == 0 Then
count = TotalTrades-T1;
Else
count = TotalTrades-T1+1;
if Count < 진입횟수 and Tcond == true then
{
if marketposition == 1 then begin
if pf < highest(pf, le) * (1 - pctdn) then begin
sell("S2", atmarket);
le = 0;
end;
le = le + 1;
end;
if marketposition == -1 then begin
if pf > lowest(pf, se) * (1 + pctup) then begin
buy("B2", atmarket);
se = 0;
end;
se = se + 1;
end;
}
2. 기타
아래 전략 시뮬차트에서도 쓸 수 있게 수정부탁드립니다.
Inputs: TrixLen(3), TSLen(8), ZeroCrss("Y"), AvgCrss("Y");
Vars: TRXval(0), AvgTRX(0), Zero(0), NewTrix(0);
Vars: LogP(0), alpha(0), sm1(0), sm2(0), sm3(0);
//newTrix 시작
LogP = Log(Close);
IF CurrentBar == 1 Then Begin
sm1 = LogP;
sm2 = LogP;
sm3 = LogP;
alpha = 2 / (TRIXLen + 1);
End
Else Begin
sm1 = (LogP - sm1) * alpha + sm1;
sm2 = (sm1 - sm2) * alpha + sm2;
sm3 = (sm2 - sm3) * alpha + sm3;
NewTrix = (sm3 - sm3[1]) * 100;
End;
//newTrix 끝
TRXval = NewTRIX;
AvgTRX = LRL(TRXval, TSLen);
IF UpperStr(ZeroCrss) == "Y" Then Begin
IF CrossUp(TRXval , Zero) Then
Buy("B_ZCrss");
IF CrossDown(TRXval , Zero) Then
Sell("S_ZCrss");
End;
IF UpperStr(AvgCrss) == "Y" Then Begin
IF CrossUp(TRXval , AvgTRX) Then
Buy("B_AvgCrss");
IF Crossdown(TRXval , AvgTRX) Then
Sell("S_AvgCrssS");
End;
3. 기타
전에 만들어주신 수식인데요. 한번 진입한 뒤 진입을 안합니다. 가장 첫 거래때 손실이면 0이 되서 진입을 안하는 건지 이유를 잘 모르겠습니다. 수정 부탁드립니다.
1.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = MaxContracts(1)-증감수량;
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = MaxContracts(0)-증감수량;
}
if MarketPosition <= 0 and vol <= 제한수량 and 매수진입조건 Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and 매도진입조건 Then
{
sell("s",OnClose,def,vol);
}
2
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
}
if MarketPosition <= 0 and vol <= 제한수량 and 매수진입조건 Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and 매도진입조건 Then
{
sell("s",OnClose,def,vol);
}
답변 7
예스스탁 예스스탁 답변
2018-08-20 13:37:19
안녕하세요
예스스탁입니다.
1
B1,S1신호는 진인횟수 제어조건이 if문에 없습니다.
inputs: ndays(30),//10~100(10)
pctup(0.01),//0.001~0.01(0.001)
pctdn(0.005),//0.001~0.01(0.001)
jmpup(0.20),//0.10~0.60(0.02)
jmpdn(0.18);//0.10~0.60(0.02)
vars: pf(0),le(0),se(0);
input :
진입횟수(1),
손절률(1),
익절률(1)
;
var : count(0),T1(0);
input : 진입시간(90000),제한시간(150000),청산시간(153400);
var : Tcond(false);
SetStopLoss(손절률,PercentStop);
SetStopProfittarget(익절률,PercentStop);
if stime == 청산시간 or (stime > 청산시간 and stime < 청산시간) Then{
Tcond = false;
if MarketPosition == 1 Then
exitlong();
if MarketPosition == -1 Then
ExitShort();
}
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then
{
Tcond = true;
T1 = TotalTrades;
}
if (sdate != sdate[1] and stime >= 제한시간) or
(sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then
{
Tcond = false;
}
if MarketPosition == 0 Then
count = TotalTrades-T1;
Else
count = TotalTrades-T1+1;
pf = LRL(close, ndays);
if marketposition == 0 and Count < 진입횟수 then begin
if pf / pf[2]*100 > 100 + jmpup then begin
buy("B1", atmarket);
le = 1;
end;
if pf / pf[2]*100 < 100 - jmpdn then begin
sell("S1", atmarket);
se = 1;
end;
end;
if Count < 진입횟수 and Tcond == true then
{
if marketposition == 1 then
begin
if pf < highest(pf, le) * (1 - pctdn) then
begin
sell("S2", atmarket);
le = 0;
end;
le = le + 1;
end;
if marketposition == -1 then begin
if pf > lowest(pf, se) * (1 + pctup) then begin
buy("B2", atmarket);
se = 0;
end;
se = se + 1;
end;
}
2
Inputs: TrixLen(3), TSLen(8), ZeroCrss(1), AvgCrss(1);
Vars: TRXval(0), AvgTRX(0), Zero(0), NewTrix(0);
Vars: LogP(0), alpha(0), sm1(0), sm2(0), sm3(0);
//newTrix 시작
LogP = Log(Close);
IF CurrentBar == 1 Then Begin
sm1 = LogP;
sm2 = LogP;
sm3 = LogP;
alpha = 2 / (TRIXLen + 1);
End
Else Begin
sm1 = (LogP - sm1) * alpha + sm1;
sm2 = (sm1 - sm2) * alpha + sm2;
sm3 = (sm2 - sm3) * alpha + sm3;
NewTrix = (sm3 - sm3[1]) * 100;
End;
//newTrix 끝
TRXval = NewTRIX;
AvgTRX = LRL(TRXval, TSLen);
IF ZeroCrss == 1 Then Begin
IF CrossUp(TRXval , Zero) Then
Buy("B_ZCrss");
IF CrossDown(TRXval , Zero) Then
Sell("S_ZCrss");
End;
IF AvgCrss == 1 Then Begin
IF CrossUp(TRXval , AvgTRX) Then
Buy("B_AvgCrss");
IF Crossdown(TRXval , AvgTRX) Then
Sell("S_AvgCrssS");
End;
3
손실이 발생하면 수량이 0이 되는 경우가 있어
최소가 설정수량이 되지 수정했습니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and vol <= 제한수량 and crossup(c,ma(C,20)) Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
sell("s",OnClose,def,vol);
}
즐거운 하루되세요
> 잡다백수 님이 쓴 글입니다.
> 제목 : 문의드립니다.
> 도움주시는 덕분에 도전하고 있습니다. 매번 감사합니다.
1. 기타
아래 전략은 진입횟수 1로 해도 하루 진입횟수를 초과해서 진입하더라구요. 어떻게 수정해야 하나요?
/*
1. 전략내용
LRL지표의 변화율이(현재봉과 두봉전) 상승하면서 일정값 이상이면 매수, 하락하면서 일정값 이하면 매도
매수포지션 상태에서 진입후 LRL의 최고가에서 일정값 이상 하락하면 매도
매도포지션 상태에서 진입후 LRL의 최저가에서 일정값 이상 상승하면 매수
2. 기타
LRL지표를 이용하여 TrailingStop과 같은 기능을 구현한게 눈에 띔
매수와 매도 변수를 각각 따로 최적화 하는 것이 갠적으로 걸림..
*/
inputs: ndays(30),//10~100(10)
pctup(0.01),//0.001~0.01(0.001)
pctdn(0.005),//0.001~0.01(0.001)
jmpup(0.20),//0.10~0.60(0.02)
jmpdn(0.18);//0.10~0.60(0.02)
vars: pf(0),le(0),se(0);
pf = LRL(close, ndays);
if marketposition == 0 then begin
if pf / pf[2]*100 > 100 + jmpup then begin
buy("B1", atmarket);
le = 1;
end;
if pf / pf[2]*100 < 100 - jmpdn then begin
sell("S1", atmarket);
se = 1;
end;
end;
input :
진입횟수(1),
손절률(1),
익절률(1)
;
var : count(0),T1(0);
input : 진입시간(90000),제한시간(150000),청산시간(153400);
var : Tcond(false);
SetStopLoss(손절률,PercentStop);
SetStopProfittarget(익절률,PercentStop);
if stime == 청산시간 or (stime > 청산시간 and stime < 청산시간) Then{
Tcond = false;
if MarketPosition == 1 Then
exitlong();
if MarketPosition == -1 Then
ExitShort();
}
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then
{
Tcond = true;
T1 = TotalTrades;
}
if (sdate != sdate[1] and stime >= 제한시간) or
(sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then
{
Tcond = false;
}
if MarketPosition == 0 Then
count = TotalTrades-T1;
Else
count = TotalTrades-T1+1;
if Count < 진입횟수 and Tcond == true then
{
if marketposition == 1 then begin
if pf < highest(pf, le) * (1 - pctdn) then begin
sell("S2", atmarket);
le = 0;
end;
le = le + 1;
end;
if marketposition == -1 then begin
if pf > lowest(pf, se) * (1 + pctup) then begin
buy("B2", atmarket);
se = 0;
end;
se = se + 1;
end;
}
2. 기타
아래 전략 시뮬차트에서도 쓸 수 있게 수정부탁드립니다.
Inputs: TrixLen(3), TSLen(8), ZeroCrss("Y"), AvgCrss("Y");
Vars: TRXval(0), AvgTRX(0), Zero(0), NewTrix(0);
Vars: LogP(0), alpha(0), sm1(0), sm2(0), sm3(0);
//newTrix 시작
LogP = Log(Close);
IF CurrentBar == 1 Then Begin
sm1 = LogP;
sm2 = LogP;
sm3 = LogP;
alpha = 2 / (TRIXLen + 1);
End
Else Begin
sm1 = (LogP - sm1) * alpha + sm1;
sm2 = (sm1 - sm2) * alpha + sm2;
sm3 = (sm2 - sm3) * alpha + sm3;
NewTrix = (sm3 - sm3[1]) * 100;
End;
//newTrix 끝
TRXval = NewTRIX;
AvgTRX = LRL(TRXval, TSLen);
IF UpperStr(ZeroCrss) == "Y" Then Begin
IF CrossUp(TRXval , Zero) Then
Buy("B_ZCrss");
IF CrossDown(TRXval , Zero) Then
Sell("S_ZCrss");
End;
IF UpperStr(AvgCrss) == "Y" Then Begin
IF CrossUp(TRXval , AvgTRX) Then
Buy("B_AvgCrss");
IF Crossdown(TRXval , AvgTRX) Then
Sell("S_AvgCrssS");
End;
3. 기타
전에 만들어주신 수식인데요. 한번 진입한 뒤 진입을 안합니다. 가장 첫 거래때 손실이면 0이 되서 진입을 안하는 건지 이유를 잘 모르겠습니다. 수정 부탁드립니다.
1.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = MaxContracts(1)-증감수량;
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = MaxContracts(0)-증감수량;
}
if MarketPosition <= 0 and vol <= 제한수량 and 매수진입조건 Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and 매도진입조건 Then
{
sell("s",OnClose,def,vol);
}
2
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
}
if MarketPosition <= 0 and vol <= 제한수량 and 매수진입조건 Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and 매도진입조건 Then
{
sell("s",OnClose,def,vol);
}
잡다백수
2018-08-20 13:55:35
코딩감사합니다. 매번 비슷한 질문 하는 것 같아 미안합니다.
이거를 전략에 실행해봤더니 이번엔 제한수량에 도달한 뒤에 더이상 진입을 하지 않습니다.
설정수량에서 a(수익일 때 수량을 1증가)시키고
손실일 때는 a에서 수량을 1감소시키되(수익일 때는 수량을 또 1증가시키고)
수량은 제한수량을 넘지 않도록 (=계속 수익이어도 수량은 계속 제한수량으로 진입하도록)
하고 싶은 건데요.
수정 좀 부탁드립니다. 항상 감사합니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and vol <= 제한수량 and crossup(c,ma(C,20)) Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
sell("s",OnClose,def,vol);
}
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 문의드립니다.
>
안녕하세요
예스스탁입니다.
1
B1,S1신호는 진인횟수 제어조건이 if문에 없습니다.
inputs: ndays(30),//10~100(10)
pctup(0.01),//0.001~0.01(0.001)
pctdn(0.005),//0.001~0.01(0.001)
jmpup(0.20),//0.10~0.60(0.02)
jmpdn(0.18);//0.10~0.60(0.02)
vars: pf(0),le(0),se(0);
input :
진입횟수(1),
손절률(1),
익절률(1)
;
var : count(0),T1(0);
input : 진입시간(90000),제한시간(150000),청산시간(153400);
var : Tcond(false);
SetStopLoss(손절률,PercentStop);
SetStopProfittarget(익절률,PercentStop);
if stime == 청산시간 or (stime > 청산시간 and stime < 청산시간) Then{
Tcond = false;
if MarketPosition == 1 Then
exitlong();
if MarketPosition == -1 Then
ExitShort();
}
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then
{
Tcond = true;
T1 = TotalTrades;
}
if (sdate != sdate[1] and stime >= 제한시간) or
(sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then
{
Tcond = false;
}
if MarketPosition == 0 Then
count = TotalTrades-T1;
Else
count = TotalTrades-T1+1;
pf = LRL(close, ndays);
if marketposition == 0 and Count < 진입횟수 then begin
if pf / pf[2]*100 > 100 + jmpup then begin
buy("B1", atmarket);
le = 1;
end;
if pf / pf[2]*100 < 100 - jmpdn then begin
sell("S1", atmarket);
se = 1;
end;
end;
if Count < 진입횟수 and Tcond == true then
{
if marketposition == 1 then
begin
if pf < highest(pf, le) * (1 - pctdn) then
begin
sell("S2", atmarket);
le = 0;
end;
le = le + 1;
end;
if marketposition == -1 then begin
if pf > lowest(pf, se) * (1 + pctup) then begin
buy("B2", atmarket);
se = 0;
end;
se = se + 1;
end;
}
2
Inputs: TrixLen(3), TSLen(8), ZeroCrss(1), AvgCrss(1);
Vars: TRXval(0), AvgTRX(0), Zero(0), NewTrix(0);
Vars: LogP(0), alpha(0), sm1(0), sm2(0), sm3(0);
//newTrix 시작
LogP = Log(Close);
IF CurrentBar == 1 Then Begin
sm1 = LogP;
sm2 = LogP;
sm3 = LogP;
alpha = 2 / (TRIXLen + 1);
End
Else Begin
sm1 = (LogP - sm1) * alpha + sm1;
sm2 = (sm1 - sm2) * alpha + sm2;
sm3 = (sm2 - sm3) * alpha + sm3;
NewTrix = (sm3 - sm3[1]) * 100;
End;
//newTrix 끝
TRXval = NewTRIX;
AvgTRX = LRL(TRXval, TSLen);
IF ZeroCrss == 1 Then Begin
IF CrossUp(TRXval , Zero) Then
Buy("B_ZCrss");
IF CrossDown(TRXval , Zero) Then
Sell("S_ZCrss");
End;
IF AvgCrss == 1 Then Begin
IF CrossUp(TRXval , AvgTRX) Then
Buy("B_AvgCrss");
IF Crossdown(TRXval , AvgTRX) Then
Sell("S_AvgCrssS");
End;
3
손실이 발생하면 수량이 0이 되는 경우가 있어
최소가 설정수량이 되지 수정했습니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and vol <= 제한수량 and crossup(c,ma(C,20)) Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
sell("s",OnClose,def,vol);
}
즐거운 하루되세요
> 잡다백수 님이 쓴 글입니다.
> 제목 : 문의드립니다.
> 도움주시는 덕분에 도전하고 있습니다. 매번 감사합니다.
1. 기타
아래 전략은 진입횟수 1로 해도 하루 진입횟수를 초과해서 진입하더라구요. 어떻게 수정해야 하나요?
/*
1. 전략내용
LRL지표의 변화율이(현재봉과 두봉전) 상승하면서 일정값 이상이면 매수, 하락하면서 일정값 이하면 매도
매수포지션 상태에서 진입후 LRL의 최고가에서 일정값 이상 하락하면 매도
매도포지션 상태에서 진입후 LRL의 최저가에서 일정값 이상 상승하면 매수
2. 기타
LRL지표를 이용하여 TrailingStop과 같은 기능을 구현한게 눈에 띔
매수와 매도 변수를 각각 따로 최적화 하는 것이 갠적으로 걸림..
*/
inputs: ndays(30),//10~100(10)
pctup(0.01),//0.001~0.01(0.001)
pctdn(0.005),//0.001~0.01(0.001)
jmpup(0.20),//0.10~0.60(0.02)
jmpdn(0.18);//0.10~0.60(0.02)
vars: pf(0),le(0),se(0);
pf = LRL(close, ndays);
if marketposition == 0 then begin
if pf / pf[2]*100 > 100 + jmpup then begin
buy("B1", atmarket);
le = 1;
end;
if pf / pf[2]*100 < 100 - jmpdn then begin
sell("S1", atmarket);
se = 1;
end;
end;
input :
진입횟수(1),
손절률(1),
익절률(1)
;
var : count(0),T1(0);
input : 진입시간(90000),제한시간(150000),청산시간(153400);
var : Tcond(false);
SetStopLoss(손절률,PercentStop);
SetStopProfittarget(익절률,PercentStop);
if stime == 청산시간 or (stime > 청산시간 and stime < 청산시간) Then{
Tcond = false;
if MarketPosition == 1 Then
exitlong();
if MarketPosition == -1 Then
ExitShort();
}
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then
{
Tcond = true;
T1 = TotalTrades;
}
if (sdate != sdate[1] and stime >= 제한시간) or
(sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then
{
Tcond = false;
}
if MarketPosition == 0 Then
count = TotalTrades-T1;
Else
count = TotalTrades-T1+1;
if Count < 진입횟수 and Tcond == true then
{
if marketposition == 1 then begin
if pf < highest(pf, le) * (1 - pctdn) then begin
sell("S2", atmarket);
le = 0;
end;
le = le + 1;
end;
if marketposition == -1 then begin
if pf > lowest(pf, se) * (1 + pctup) then begin
buy("B2", atmarket);
se = 0;
end;
se = se + 1;
end;
}
2. 기타
아래 전략 시뮬차트에서도 쓸 수 있게 수정부탁드립니다.
Inputs: TrixLen(3), TSLen(8), ZeroCrss("Y"), AvgCrss("Y");
Vars: TRXval(0), AvgTRX(0), Zero(0), NewTrix(0);
Vars: LogP(0), alpha(0), sm1(0), sm2(0), sm3(0);
//newTrix 시작
LogP = Log(Close);
IF CurrentBar == 1 Then Begin
sm1 = LogP;
sm2 = LogP;
sm3 = LogP;
alpha = 2 / (TRIXLen + 1);
End
Else Begin
sm1 = (LogP - sm1) * alpha + sm1;
sm2 = (sm1 - sm2) * alpha + sm2;
sm3 = (sm2 - sm3) * alpha + sm3;
NewTrix = (sm3 - sm3[1]) * 100;
End;
//newTrix 끝
TRXval = NewTRIX;
AvgTRX = LRL(TRXval, TSLen);
IF UpperStr(ZeroCrss) == "Y" Then Begin
IF CrossUp(TRXval , Zero) Then
Buy("B_ZCrss");
IF CrossDown(TRXval , Zero) Then
Sell("S_ZCrss");
End;
IF UpperStr(AvgCrss) == "Y" Then Begin
IF CrossUp(TRXval , AvgTRX) Then
Buy("B_AvgCrss");
IF Crossdown(TRXval , AvgTRX) Then
Sell("S_AvgCrssS");
End;
3. 기타
전에 만들어주신 수식인데요. 한번 진입한 뒤 진입을 안합니다. 가장 첫 거래때 손실이면 0이 되서 진입을 안하는 건지 이유를 잘 모르겠습니다. 수정 부탁드립니다.
1.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = MaxContracts(1)-증감수량;
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = MaxContracts(0)-증감수량;
}
if MarketPosition <= 0 and vol <= 제한수량 and 매수진입조건 Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and 매도진입조건 Then
{
sell("s",OnClose,def,vol);
}
2
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
}
if MarketPosition <= 0 and vol <= 제한수량 and 매수진입조건 Then
{
Buy("b",OnClose,def,vol);
}
if MarketPosition >= 0 and vol <= 제한수량 and 매도진입조건 Then
{
sell("s",OnClose,def,vol);
}
예스스탁 예스스탁 답변
2018-08-20 14:01:06
안녕하세요
예스스탁입니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and crossup(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
Buy("b",OnClose,def,vol);
Else
ExitShort("sx");
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
sell("s",OnClose,def,vol);
Else
ExitLong("bx");
}
즐거운 하루되세요
잡다백수
2018-08-20 14:15:39
잡다백수 님에 의해 삭제된 답변입니다.
잡다백수
2018-08-20 14:23:11
ㅠㅠ
onclose는 올려주신대로 수량조절이 됐지만 atstop에서는 여전히 최고수량에 도달한 뒤 진입을 안합니다.
var : count(0) ;
#진입회수제한
Count = 0 ;
for Value1 = 0 to 10 {
if EntryDate( Value1 ) == sdate then
Count = Count + 1;
}
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if Count < entryCount and stime > 시작시간 then {
if MarketPosition <= 0 Then
{
if vol <= 제한수량 Then
buy("b",atstop, var1 + pricescale,vol);
Else
ExitShort("sx",atstop,vol);
}
if MarketPosition >= 0 Then
{
if vol <= 제한수량 Then
sell("s",atstop, var2 - pricescale,vol);
else
ExitLong("bx",AtStop,vol);
}
}
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : Re : Re : 문의드립니다.
>
안녕하세요
예스스탁입니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and crossup(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
Buy("b",OnClose,def,vol);
Else
ExitShort("sx");
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
sell("s",OnClose,def,vol);
Else
ExitLong("bx");
}
즐거운 하루되세요
예스스탁 예스스탁 답변
2018-08-20 14:40:05
안녕하세요
예스스탁입니다.
신호타입다음에는 가격이 와야 합니다.
작성하신 수식에는 수량입니다
또한 해당수식의 청산식에는 별도의 수량지정이 필요없습니다.
if Count < entryCount and stime > 시작시간 then {
if MarketPosition <= 0 Then
{
if vol <= 제한수량 Then
buy("b",atstop, var1 + pricescale,vol);
Else
ExitShort("sx",atstop,var1 + pricescale);
}
if MarketPosition >= 0 Then
{
if vol <= 제한수량 Then
sell("s",atstop, var2 - pricescale,vol);
else
ExitLong("bx",AtStop,var2 - pricescale);
}
}
즐거운 하루되세요
> 잡다백수 님이 쓴 글입니다.
> 제목 : Re : Re : Re : Re : 문의드립니다.
> ㅠㅠ
onclose는 올려주신대로 수량조절이 됐지만 atstop에서는 여전히 최고수량에 도달한 뒤 진입을 안합니다.
var : count(0) ;
#진입회수제한
Count = 0 ;
for Value1 = 0 to 10 {
if EntryDate( Value1 ) == sdate then
Count = Count + 1;
}
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if Count < entryCount and stime > 시작시간 then {
if MarketPosition <= 0 Then
{
if vol <= 제한수량 Then
buy("b",atstop, var1 + pricescale,vol);
Else
ExitShort("sx",atstop,vol);
}
if MarketPosition >= 0 Then
{
if vol <= 제한수량 Then
sell("s",atstop, var2 - pricescale,vol);
else
ExitLong("bx",AtStop,vol);
}
}
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : Re : Re : 문의드립니다.
>
안녕하세요
예스스탁입니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and crossup(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
Buy("b",OnClose,def,vol);
Else
ExitShort("sx");
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
sell("s",OnClose,def,vol);
Else
ExitLong("bx");
}
즐거운 하루되세요
잡다백수
2018-08-20 15:05:36
아래 전략같이 제한수량만큼 승이 쌓이지 않는 전략에서는 짜주신대로 하면 계속 신호가 나옵니다. onclose에 입혀도 문제없이 신호가 나옵니다.(이것도 제한수량만큼 쌓일 때 신호가 나오는 지는 아직 확실치 않습니다.)
그런데 atstop으로 제한수량만큼 승이 쌓이는 전략(승이 특정 구간에서 많이 쌓이는 전략)에선 제한수량에 도달한 순간 더 이상 진입을 하지 않습니다.아래 수식으로 제한수량을 2로 했을 때 저렇게 특정 구간에서 더이상 진입하지 않습니다. 아래 전략을 보면 무조건 진입해야 하는 전략인데도 그렇네요.
자꾸 골치 아픈 일 만들어서 미안합니다. 한번만 더 검토해주세요~~~
Input:
시작시간(90000),
청산시간(150000),
stopp(0.5),
propp(1.2),
entryCount(1)
;
var : count(0) ;
#진입회수제한
Count = 0 ;
for Value1 = 0 to 10 {
if EntryDate( Value1 ) == sdate then
Count = Count + 1;
}
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if Count < entryCount and stime > 시작시간 then {
if MarketPosition <= 0 Then
{
if vol <= 제한수량 Then
buy("b",atstop, dayopen + pricescale,vol);
Else
ExitShort("sx",atstop,dayopen + pricescale);
}
if MarketPosition >= 0 Then
{
if vol <= 제한수량 Then
sell("s",atstop, dayopen - pricescale,vol);
else
ExitLong("bx",AtStop,DayOpen - pricescale);
}
}
input : TsATR길이(49);
var : posHigh(0), posLow(0);
If MarketPosition() == 1 Then {
PosHigh = highest(H,BarsSinceEntry+1);
ExitLong("trailStop_EL%", AtStop, PosHigh - PriceScale * TsATR길이 );
}
If MarketPosition() == -1 Then {
PosLow = lowest(L,BarsSinceEntry+1);
ExitShort("trailStop_ES%", AtStop, PosLow + PriceScale * TsATR길이);
}
SetStopLoss(stopp,PercentStop);
SetStopProfittarget(propp,PercentStop);
SetStopEndofday(청산시간);
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : Re : Re : Re : Re : 문의드립니다.
>
안녕하세요
예스스탁입니다.
신호타입다음에는 가격이 와야 합니다.
작성하신 수식에는 수량입니다
또한 해당수식의 청산식에는 별도의 수량지정이 필요없습니다.
if Count < entryCount and stime > 시작시간 then {
if MarketPosition <= 0 Then
{
if vol <= 제한수량 Then
buy("b",atstop, var1 + pricescale,vol);
Else
ExitShort("sx",atstop,var1 + pricescale);
}
if MarketPosition >= 0 Then
{
if vol <= 제한수량 Then
sell("s",atstop, var2 - pricescale,vol);
else
ExitLong("bx",AtStop,var2 - pricescale);
}
}
즐거운 하루되세요
> 잡다백수 님이 쓴 글입니다.
> 제목 : Re : Re : Re : Re : 문의드립니다.
> ㅠㅠ
onclose는 올려주신대로 수량조절이 됐지만 atstop에서는 여전히 최고수량에 도달한 뒤 진입을 안합니다.
var : count(0) ;
#진입회수제한
Count = 0 ;
for Value1 = 0 to 10 {
if EntryDate( Value1 ) == sdate then
Count = Count + 1;
}
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if Count < entryCount and stime > 시작시간 then {
if MarketPosition <= 0 Then
{
if vol <= 제한수량 Then
buy("b",atstop, var1 + pricescale,vol);
Else
ExitShort("sx",atstop,vol);
}
if MarketPosition >= 0 Then
{
if vol <= 제한수량 Then
sell("s",atstop, var2 - pricescale,vol);
else
ExitLong("bx",AtStop,vol);
}
}
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : Re : Re : 문의드립니다.
>
안녕하세요
예스스탁입니다.
input : 설정수량(1),증감수량(1),제한수량(10);
var : vol(0);
if MarketPosition == 0 then
{
if TotalTrades == 0 Then
vol = 설정수량;
Else
{
if PositionProfit(1) >= 0 Then
vol = MaxContracts(1)+증감수량;
else
vol = max(MaxContracts(1)-증감수량,설정수량);
}
}
else
{
if PositionProfit(0) >= 0 Then
vol = MaxContracts(0)+증감수량;
else
vol = max(MaxContracts(0)-증감수량,설정수량);
}
if MarketPosition <= 0 and crossup(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
Buy("b",OnClose,def,vol);
Else
ExitShort("sx");
}
if MarketPosition >= 0 and vol <= 제한수량 and CrossDown(c,ma(C,20)) Then
{
if vol <= 제한수량 Then
sell("s",OnClose,def,vol);
Else
ExitLong("bx");
}
즐거운 하루되세요