커뮤니티
수정부탁드립니다
2017-09-28 23:55:34
198
글번호 113184
식 확인 및 수정 부탁드립니다.
(매수로만 설명드립니다 매도는 반대 동일조건으로 해주세요)
1. 아래식의 경우 매수진입하여 익절이 되면 바로 다시 매수로 재진입 되는 경우가 있습니다.(그림1) 익절 후에도 매수 조건이라서 재진입이 되는거 같은데, 바로 같은 포지션으로 재진입이 되지 않도록 해주세요.
(시뮬레이션에는 재진입이 없습니다. 실 매매에서만 재진입이 이루어 집니다.)
2. 매수 진입하여 손절되면 매도 조건시 진입 (단, 매도 진입은 Data2의 20일선이 100일선 위에 있고 80일선이 상방일때만)
3. 포지션 진입 후 익절이되면 당일 매매 끝
4. 진입회수를 2로 하면 1번과같은 조건이든 매수(청산), 매도(청산) 조건 진입이든 2번만 거래가 이루어 집니다. 진입은 2번항목 조건에 의해서 두번까지만 되게 해주시고, 첫번째 매매에서 익절이 되면 당일 매매는 종료하게 해주세요.
input : short(12),long(26),sig(9),P1(3),P2(20),P3(100);
input : 시작시간(102000), 종료시간(172000);
input : 진입회수(2);
var : mav1(0,data1),mav2(0,data1),mav3(0,data1);
var : Tcond(False,data1),Bcount(0,data1),Scount(0,data1);
var : MACDO2(0,data2), MACDO1(0,data1);
var : BH(0,data1),SL(0,data1);
MACDO2 = data2(MACD_OSC(short,long,sig));
MACDO1 = data1(MACD_OSC(short,long,sig));
mav1 = data1(ma(c,P1));
mav2 = data1(ma(c,P2));
mav3 = data1(ma(c,P3));
if stime == 시작시간 or (stime >시작시간 and stime[1] < 시작시간) Then{
Tcond = true;
Bcount = 0;
Scount = 0;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
}
//진입회수
if MarketPosition != MarketPosition[1] and MarketPosition == 1 Then
Bcount = Bcount+1;
if MarketPosition != MarketPosition[1] and MarketPosition == -1 Then
Scount = Scount+1;
//진입
if Tcond == true Then{
if Bcount < 진입회수 and MACDO2 > MACDO2[1] and crossup(mav2,mav3) Then buy("Buy");
if Scount < 진입회수 and MACDO2 < MACDO2[1] and CrossDown(mav2,mav3) Then sell("Sell");
}
//청산1
if MarketPosition == 1 Then{
BH = highest(H,BarsSinceEntry);
if BH >= EntryPrice+PriceScale*60 and BH < EntryPrice+PriceScale*80 Then
ExitLong("B익절1",AtStop,BH-PriceScale*30);
if BH >= EntryPrice+PriceScale*80 Then
ExitLong("B익절2",AtStop,BH-PriceScale*20);
ExitLong("B손절",AtStop,EntryPrice-PriceScale*40);
}
if MarketPosition == -1 Then{
SL = Lowest(L,BarsSinceEntry);
if SL <= EntryPrice-PriceScale*60 and SL > EntryPrice-PriceScale*80 Then
ExitShort("S익절1",AtStop,SL+PriceScale*30);
if SL <= EntryPrice-PriceScale*80 Then
ExitShort("S익절2",AtStop,sL+PriceScale*20);
ExitShort("S손절",AtStop,EntryPrice+PriceScale*40);
}
if 종료시간 <= sTime or sTime < 시작시간 then {
if MarketPosition == 1 then{
ExitLong("B장종료");
}
if MarketPosition == -1 then{
ExitShort("S장종료");
}
}
- 1. 113750_그림_1.jpg (0.07 MB)
답변 1
예스스탁 예스스탁 답변
2017-09-29 15:11:14
안녕하세요
예스스탁입니다.
input : short(12),long(26),sig(9),P1(3),P2(20),P3(100);
input : 시작시간(102000), 종료시간(172000);
input : 진입횟수(2);
var : mav1(0,data1),mav2(0,data1),mav3(0,data1);
var : Tcond(False,data1),count(0,data1),T1(0,data1);
var : MACDO2(0,data2), MACDO1(0,data1);
var : BH(0,data1),SL(0,data1),Xcond(false,data1);
var : avg1(0,data2),avg2(0,data2),avg3(0,data2);
MACDO2 = data2(MACD_OSC(short,long,sig));
MACDO1 = data1(MACD_OSC(short,long,sig));
mav1 = data1(ma(c,P1));
mav2 = data1(ma(c,P2));
mav3 = data1(ma(c,P3));
avg1 = data2(ma(c,20));
avg2 = data2(ma(c,80));
avg3 = data2(ma(c,100));
if stime == 시작시간 or (stime >시작시간 and stime[1] < 시작시간) Then{
T1 = TotalTrades;
Tcond = true;
Xcond = true;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
}
if TotalTrades > TotalTrades[1] and
(IsExitName("B익절1",1) or
IsExitName("B익절2",1) or
IsExitName("S익절1",1) or
IsExitName("S익절2",1)) Then
Xcond = true;
if MarketPosition == 0 Then
count = TotalTrades-T1;
Else
count = TotalTrades-T1+1;
//진입
if Tcond == true and Xcond == false Then{
if MACDO2 > MACDO2[1] and crossup(mav2,mav3) Then{
if count == 0 and MarketPosition <= 0 Then
buy("Buy1");
if count > 0 and count < 진입횟수 and MarketPosition == -1 then
buy("Buy2");
if count > 0 and count < 진입횟수 and MarketPosition == 0 and MarketPosition(1) != 1 and
IsExitName("S손절",1) == false then
buy("Buy3");
if count > 0 and count < 진입횟수 and MarketPosition == 0 and MarketPosition(1) != 1 and
IsExitName("S손절",1) == true and avg1 < avg3 and avg2 < avg2[1] then
buy("Buy4");
}
if MACDO2 < MACDO2[1] and CrossDown(mav2,mav3) then{
if count == 0 and MarketPosition >= 0 Then
Sell("Sell1");
if count > 0 and count < 진입횟수 and MarketPosition == 1 then
Sell("Sell2");
if count > 0 and count < 진입횟수 and MarketPosition == 0 and MarketPosition(1) != -1 and
IsExitName("B손절",1) == false then
Sell("Sell3");
if count > 0 and count < 진입횟수 and MarketPosition == 0 and MarketPosition(1) != -1 and
IsExitName("B손절",1) == true and avg1 > avg3 and avg2 > avg2[1] then
Sell("Sell4");
}
}
//청산1
if MarketPosition == 1 Then{
BH = highest(H,BarsSinceEntry);
if BH >= EntryPrice+PriceScale*60 and BH < EntryPrice+PriceScale*80 Then
ExitLong("B익절1",AtStop,BH-PriceScale*30);
if BH >= EntryPrice+PriceScale*80 Then
ExitLong("B익절2",AtStop,BH-PriceScale*20);
ExitLong("B손절",AtStop,EntryPrice-PriceScale*40);
}
if MarketPosition == -1 Then{
SL = Lowest(L,BarsSinceEntry);
if SL <= EntryPrice-PriceScale*60 and SL > EntryPrice-PriceScale*80 Then
ExitShort("S익절1",AtStop,SL+PriceScale*30);
if SL <= EntryPrice-PriceScale*80 Then
ExitShort("S익절2",AtStop,sL+PriceScale*20);
ExitShort("S손절",AtStop,EntryPrice+PriceScale*40);
}
if 종료시간 <= sTime or sTime < 시작시간 then {
if MarketPosition == 1 then{
ExitLong("B장종료");
}
if MarketPosition == -1 then{
ExitShort("S장종료");
}
}
즐거운 하루되세요
> 라떼처럼 님이 쓴 글입니다.
> 제목 : 수정부탁드립니다
> 식 확인 및 수정 부탁드립니다.
(매수로만 설명드립니다 매도는 반대 동일조건으로 해주세요)
1. 아래식의 경우 매수진입하여 익절이 되면 바로 다시 매수로 재진입 되는 경우가 있습니다.(그림1) 익절 후에도 매수 조건이라서 재진입이 되는거 같은데, 바로 같은 포지션으로 재진입이 되지 않도록 해주세요.
(시뮬레이션에는 재진입이 없습니다. 실 매매에서만 재진입이 이루어 집니다.)
2. 매수 진입하여 손절되면 매도 조건시 진입 (단, 매도 진입은 Data2의 20일선이 100일선 위에 있고 80일선이 상방일때만)
3. 포지션 진입 후 익절이되면 당일 매매 끝
4. 진입회수를 2로 하면 1번과같은 조건이든 매수(청산), 매도(청산) 조건 진입이든 2번만 거래가 이루어 집니다. 진입은 2번항목 조건에 의해서 두번까지만 되게 해주시고, 첫번째 매매에서 익절이 되면 당일 매매는 종료하게 해주세요.
input : short(12),long(26),sig(9),P1(3),P2(20),P3(100);
input : 시작시간(102000), 종료시간(172000);
input : 진입회수(2);
var : mav1(0,data1),mav2(0,data1),mav3(0,data1);
var : Tcond(False,data1),Bcount(0,data1),Scount(0,data1);
var : MACDO2(0,data2), MACDO1(0,data1);
var : BH(0,data1),SL(0,data1);
MACDO2 = data2(MACD_OSC(short,long,sig));
MACDO1 = data1(MACD_OSC(short,long,sig));
mav1 = data1(ma(c,P1));
mav2 = data1(ma(c,P2));
mav3 = data1(ma(c,P3));
if stime == 시작시간 or (stime >시작시간 and stime[1] < 시작시간) Then{
Tcond = true;
Bcount = 0;
Scount = 0;
}
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then{
Tcond = false;
}
//진입회수
if MarketPosition != MarketPosition[1] and MarketPosition == 1 Then
Bcount = Bcount+1;
if MarketPosition != MarketPosition[1] and MarketPosition == -1 Then
Scount = Scount+1;
//진입
if Tcond == true Then{
if Bcount < 진입회수 and MACDO2 > MACDO2[1] and crossup(mav2,mav3) Then buy("Buy");
if Scount < 진입회수 and MACDO2 < MACDO2[1] and CrossDown(mav2,mav3) Then sell("Sell");
}
//청산1
if MarketPosition == 1 Then{
BH = highest(H,BarsSinceEntry);
if BH >= EntryPrice+PriceScale*60 and BH < EntryPrice+PriceScale*80 Then
ExitLong("B익절1",AtStop,BH-PriceScale*30);
if BH >= EntryPrice+PriceScale*80 Then
ExitLong("B익절2",AtStop,BH-PriceScale*20);
ExitLong("B손절",AtStop,EntryPrice-PriceScale*40);
}
if MarketPosition == -1 Then{
SL = Lowest(L,BarsSinceEntry);
if SL <= EntryPrice-PriceScale*60 and SL > EntryPrice-PriceScale*80 Then
ExitShort("S익절1",AtStop,SL+PriceScale*30);
if SL <= EntryPrice-PriceScale*80 Then
ExitShort("S익절2",AtStop,sL+PriceScale*20);
ExitShort("S손절",AtStop,EntryPrice+PriceScale*40);
}
if 종료시간 <= sTime or sTime < 시작시간 then {
if MarketPosition == 1 then{
ExitLong("B장종료");
}
if MarketPosition == -1 then{
ExitShort("S장종료");
}
}