커뮤니티
스탑로스 질문드립니다.
2018-10-16 00:59:09
196
글번호 122702
var : BLcnt(0),SLcnt(0),추격횟수(0), 피라미딩매수(0);
if Bdate != Bdate[1] Then{
BLcnt = 0;
SLcnt = 0;
}
if MarketPosition != MarketPosition[1] and MarketPosition(1) == 1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "StopLoss" Then
BLcnt = BLcnt+1;
if MarketPosition == 1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "StopLoss" Then
BLcnt = BLcnt+1;
if BLcnt < 2 and 매수식 then
이면 스탑로스2회 발생시 매매X였습니다.
If MarketPosition == 0 Then
if BLcnt < 2 Then{
if 조건 then
buy
if 조건 then
buy
}
스탑컷이 유효하지가 않네요.
근데 이게 안되더군요. 무엇이 문제인지...
실험한 로직첨부합니다. 일3회 스탑이 나온것을 확인할 수 있습니다.
/////////
var : BLcnt(0),SLcnt(0);
if Bdate != Bdate[1] Then{
BLcnt = 0;
SLcnt = 0;
}
if MarketPosition != MarketPosition[1] and MarketPosition(1) == 1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "StopLoss" Then
BLcnt = BLcnt+1;
if MarketPosition == 1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "StopLoss" Then
BLcnt = BLcnt+1;
if MarketPosition != MarketPosition[1] and MarketPosition(1) == -1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "손절" Then
SLcnt = SLcnt+1;
if MarketPosition == -1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "손절" Then
SLcnt = SLcnt+1;
MessageLog("BLcnt %.f SLcnt %.f",BLcnt,SLcnt);
If blcnt < 2 and CrossUp(Close,Ma(c,5)) Then{
Buy();
}
SetStopLoss(20*PriceScale,PointStop);
SetStopProfittarget(20*PriceScale,PointStop);
////////////////////나스닥100 2분봉 캔들갯수10000개 하신뒤 확인해보시길 바랍니다. 사진1입니다.
그래서 보안책으로 윗 로직을 지운뒤
Vars : 시작시간(070100),종료시간(070000);
Input : 당일누적손실틱수(120);
Var : N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),Tcond(false);
당일누적손실 = PriceScale*당일누적손실틱수;
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
}
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
IsExitName("누적손실제한",1) == true then
Xcond = true;
if Xcond == False then
If MarketPosition == 0 Then{
if 조건식 then
buy
로 해도 일최대손실 틱수를 인식하지 못합니다. 가령100틱을 설정해도 100틱이 누적되었음에도 불구하고 한번더 주문이 나간뒤
If marketposition == -1 then {
ExitShort("누적손실제한",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));} 이 작동합니다. 120틱째에 누적손실제한이 걸린다거나 하는것이죠. 대체 뭐가 문제일련지요?
1.
그저 저는 하루에 스탑2번 발생시 매매금지 이것만 하고싶을 뿐인데...
참고로 제 진입식은 총5개입니다.
2.
일최대 손실틱수를 100틱으로 하고싶습니다.
토탈 100틱이상 손실이 났을 경우 매매중지이죠.
설정은 외부변수로 선택할 수 있게하고싶습니다.
- 1. 3회손실BLcnt.png (0.05 MB)
답변 1
예스스탁 예스스탁 답변
2018-10-16 11:40:14
안녕하세요
예스스탁입니다.
var : BLcnt(0),SLcnt(0);
Input : 당일손실틱수(80);
Var : N1(0),dayPl(0),당일누적손실(0),Xcond(false);
당일누적손실 = -PriceScale*당일손실틱수;
if Bdate != Bdate[1] Then{
BLcnt = 0;
SLcnt = 0;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
daypl <= 당일누적손실 then
Xcond = true;
if MarketPosition == 0 and
MarketPosition(1) == 1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "StopLoss" Then
{
BLcnt = BLcnt+1;
}
if MarketPosition == 1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "StopLoss" Then
{
BLcnt = BLcnt+1;
}
if MarketPosition == 0 and
MarketPosition(1) == -1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "StopLoss" Then
SLcnt = SLcnt+1;
if MarketPosition == -1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "StopLoss" Then
SLcnt = SLcnt+1;
If blcnt < 2 and Xcond == false and CrossUp(Close,Ma(c,5)) Then
{
Buy();
}
SetStopLoss(20*PriceScale,PointStop);
SetStopProfittarget(20*PriceScale,PointStop);
if MarketPosition == 1 then{
ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then{
ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
즐거운 하루되세요
> stockric 님이 쓴 글입니다.
> 제목 : 스탑로스 질문드립니다.
> var : BLcnt(0),SLcnt(0),추격횟수(0), 피라미딩매수(0);
if Bdate != Bdate[1] Then{
BLcnt = 0;
SLcnt = 0;
}
if MarketPosition != MarketPosition[1] and MarketPosition(1) == 1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "StopLoss" Then
BLcnt = BLcnt+1;
if MarketPosition == 1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "StopLoss" Then
BLcnt = BLcnt+1;
if BLcnt < 2 and 매수식 then
이면 스탑로스2회 발생시 매매X였습니다.
If MarketPosition == 0 Then
if BLcnt < 2 Then{
if 조건 then
buy
if 조건 then
buy
}
스탑컷이 유효하지가 않네요.
근데 이게 안되더군요. 무엇이 문제인지...
실험한 로직첨부합니다. 일3회 스탑이 나온것을 확인할 수 있습니다.
/////////
var : BLcnt(0),SLcnt(0);
if Bdate != Bdate[1] Then{
BLcnt = 0;
SLcnt = 0;
}
if MarketPosition != MarketPosition[1] and MarketPosition(1) == 1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "StopLoss" Then
BLcnt = BLcnt+1;
if MarketPosition == 1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "StopLoss" Then
BLcnt = BLcnt+1;
if MarketPosition != MarketPosition[1] and MarketPosition(1) == -1 and
TotalTrades > TotalTrades[1] and LatestExitName(1) == "손절" Then
SLcnt = SLcnt+1;
if MarketPosition == -1 and CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "손절" Then
SLcnt = SLcnt+1;
MessageLog("BLcnt %.f SLcnt %.f",BLcnt,SLcnt);
If blcnt < 2 and CrossUp(Close,Ma(c,5)) Then{
Buy();
}
SetStopLoss(20*PriceScale,PointStop);
SetStopProfittarget(20*PriceScale,PointStop);
////////////////////나스닥100 2분봉 캔들갯수10000개 하신뒤 확인해보시길 바랍니다. 사진1입니다.
그래서 보안책으로 윗 로직을 지운뒤
Vars : 시작시간(070100),종료시간(070000);
Input : 당일누적손실틱수(120);
Var : N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),Tcond(false);
당일누적손실 = PriceScale*당일누적손실틱수;
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
}
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
IsExitName("누적손실제한",1) == true then
Xcond = true;
if Xcond == False then
If MarketPosition == 0 Then{
if 조건식 then
buy
로 해도 일최대손실 틱수를 인식하지 못합니다. 가령100틱을 설정해도 100틱이 누적되었음에도 불구하고 한번더 주문이 나간뒤
If marketposition == -1 then {
ExitShort("누적손실제한",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));} 이 작동합니다. 120틱째에 누적손실제한이 걸린다거나 하는것이죠. 대체 뭐가 문제일련지요?
1.
그저 저는 하루에 스탑2번 발생시 매매금지 이것만 하고싶을 뿐인데...
참고로 제 진입식은 총5개입니다.
2.
일최대 손실틱수를 100틱으로 하고싶습니다.
토탈 100틱이상 손실이 났을 경우 매매중지이죠.
설정은 외부변수로 선택할 수 있게하고싶습니다.