답변완료
문의
선물 5분봉
별첨파일 1은 손절 1.00 인데 1.90 청산된 경우입니다
별첨파일 2는 손절 0.80 인데 1.45 청산된 경우입니다.
1. stop주문이므로 손절가격으로 청산되야 하는데 예외가 발생되는 이유가 궁금합니다.
2.
진입시간과 진입제한시간에 대하여
2016년 7월 31일 이전과 2016년 8월 01일 이후 2개로 구분하여 한 번에 시뮬레이션하고 싶습니다.
input : 진입시간(090000),진입제한시간(132000);
var : tcond(false);
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then
Tcond = true;
if (sdate != sdate[1] and stime >= 진입제한시간) or
(sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then
Tcond = false;
if 진입수식 and Tcond == true then
****************************************************************************************
input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1);
input : uppyra검증1(0),상승pyra1(0),상승N1(0);
input : up손절1(1.00),up익절1(99999),upTR1(1.00);
input : uppyra검증2(0),상승pyra2(0),상승N2(0);
input : up손절2(0.80),up익절2(99999),upTR2(1.00);
input : uppyra검증3(0),상승pyra3(0),상승N3(0);
input : up손절3(0.60),up익절3(99999),upTR3(1.00);
input : dnpyra검증1(0),하락pyra1(0),하락N1(0);
input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00);
input : dnpyra검증2(0),하락pyra2(0),하락N2(0);
input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00);
input : dnpyra검증3(0),하락pyra3(0),하락N3(0);
input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00);
if dayindex == 0 and MarketPosition == 0 Then{
Condition1 = false;
if C > O Then{
buy("b1",AtMarket);
Condition1 = true;
}
if c < O Then{
sell("s1",AtMarket);
Condition1 = true;
}
}
if MarketPosition == 0 and #현재 무포지션이고
EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고
MarketPosition(1) == 1 and #직전거래가 매수거래이고
countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면
buy("b2");
if MarketPosition == 0 and #현재 무포지션이고
EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고
MarketPosition(1) == -1 and #직전거래가 매도거래이고
countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면
buy("b3");
if MarketPosition == 0 and #현재 무포지션이고
EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고
MarketPosition(1) == -1 and #직전거래가 매도거래이고
countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면
sell("s2");
if MarketPosition == 0 and #현재 무포지션이고
EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고
MarketPosition(1) == 1 and #직전거래가 매수거래이고
countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면
sell("s3");
if MarketPosition == 1 and IsEntryName("b1") == true Then
{
if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then
buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1);
ExitLong("bl1",AtStop,EntryPrice-pointstop*up손절1);
Exitlong("bp1",AtLimit,EntryPrice+pointstop*up익절1);
Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-pointstop*upTR1);
}
if MarketPosition == 1 and IsEntryName("b2") == true then
{
if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then
buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2);
ExitLong("bl2",AtStop,EntryPrice-PointStop*up손절2);
Exitlong("bp2",AtLimit,EntryPrice+PointStop*up익절2);
Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR2);
}
if MarketPosition == 1 and IsEntryName("b3") == true then
{
if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then
buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3);
ExitLong("bl3",AtStop,EntryPrice-PointStop*up손절3);
Exitlong("bp3",AtLimit,EntryPrice+PointStop*up익절3);
Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR3);
}
if MarketPosition == -1 and IsEntryName("s1") == true Then
{
if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then
sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1);
ExitShort("sl1",AtStop,EntryPrice+PointStop*dn손절1);
ExitShort("sp1",AtLimit,EntryPrice-PointStop*dn익절1);
ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR1);
}
if MarketPosition == -1 and IsEntryName("s2") == true Then
{
if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then
sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2);
ExitShort("sl2",AtStop,EntryPrice+PointStop*dn손절2);
ExitShort("sp2",AtLimit,EntryPrice-PointStop*dn익절2);
ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR2);
}
if MarketPosition == -1 and IsEntryName("s3") == true Then
{
if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then
sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3);
ExitShort("sl3",AtStop,EntryPrice+PointStop*dn손절3);
ExitShort("sp3",AtLimit,EntryPrice-PointStop*dn익절3);
ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR3);
}
2020-04-16
634
글번호 137946
시스템
답변완료
부탁드립니다.
항상 감사드립니다.
1. 아래의 식에서 R3의 값이 40 이하가 되면 70 까지 도달 할때까지
■가 포함된 신호로 표현하고 싶습니다.
단순히 40~70 사이 값에서 ■ 포함 표시가 아니고,
R3의 값이 40 이하가 되면 ■포함(B1■) 되기 시작되어, 70 도달 전까지 ■포함 되고,
다시 40 이하가 되기 전까지는 일반으로(B1) 표시가 될수 있도록 요청을 드립니다.
R3 60 40 20 30 50 70 90 70 50 40 20
표시 B B■ B■ B■ B■ B B B B B■ B■
2. ###카운트3 에서 0.03 의 값을 전략창 전체 진입수 조건에 따라 변경하고 싶습니다.
300개 <= 전체 진입수 일때는 0.02
200개 <= 전체 진입수 < 300개 일때는 0.04
전체 진입수 < 200개 일때는 0.05
### 부분은 작성을 해본 수식입니다. 수정해 주시면 됩니다. 감사합니다.
input : 손절(20),익절(15),익절하락(3);
input : P1(30), P2(120), p3(240);
input : StartTime(090000),EndTime(050000);
var : tt(0),tx(0),X(false),tx1(0),cnt(0),sum(0);
var: Tcond(false),ht(0),lcnt(0),trcnt(0),R(-1);
Array : XX[200](-1);
var1 = ma(C, P1);
var2 = ma(C, P2);
var3 = ma(C, P3);
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
tt = 0;
X = false;
}
if Tcond == true then
{
if marketposition == 0 and crossup(var1,var2) Then {
if Condition3 == true and R3 < 50 then #### <-- 수정요청
buy("B1■");
Else
buy("B1");
}
if marketposition == 0 and crossdown(var1,var2) Then {
if Condition3 == true and R3 < 50 then #### <-- 수정요청
sell("S1■");
Else
sell("S1");
}
if marketposition == 0 and crossup(var2,var3) and var3[1] < var3 Then {
if Condition3 == true and R3 < 50 then #### <-- 수정요청
buy("B2■");
Else
buy("B2");
}
if marketposition == 0 and crossdown(var3,var4) and var3[1] > var3 Then {
if Condition3 == true and R3 < 50 then #### <-- 수정요청
sell("S2■");
Else
sell("S2");
}
## 청산
if MarketPosition == 1 then
{
SetStopTrailing(익절하락,익절,PointStop);
SetStopLoss(손절,PointStop);
}
if MarketPosition == -1 Then
{
SetStopTrailing(익절하락,익절,PointStop);
SetStopLoss(손절,PointStop);
}
}
## 카운트3
var : tx3(0),cnt3(0),sum3(0),lcnt3(0),trcnt3(0),R3(-1), TR3(0), GR3(0);
Array : XX3[200](-1);
if TotalTrades > TotalTrades[1] then
{
if IsExitName("StopLoss",1) == true then
{
lcnt3 = lcnt3+1;
XX3[0] = 0;
for cnt3 = 1 to 199
{
XX3[cnt3] = XX3[cnt3-1][1];
}
if Floor((trcnt3+lcnt3)*(0.03)) > 1 then
{
sum3 = 0;
for cnt3 = 0 to Floor((trcnt3+lcnt3)*(0.03))-1
{
if XX3[cnt3] == 1 Then
sum3 = sum3 + 1;
}
R3 = sum3/Floor((trcnt3+lcnt3)*(0.03))*100;
}
}
if IsExitName("StopTrailing",1) == true then
{
trcnt3 = trcnt3+1;
XX3[0] = 1;
for cnt3 = 1 to 199
{
XX3[cnt3] = XX3[cnt3-1][1];
}
if Floor((trcnt3+lcnt3)*(0.03)) > 1 then
{
sum3 = 0;
for cnt3 = 0 to Floor((trcnt3+lcnt3)*(0.03))-1
{
if XX3[cnt3] == 1 Then
sum3 = sum3+1;
}
R3 = sum3/Floor((trcnt3+lcnt3)*(0.03))*100;
}
}
TR3 = trcnt3/(trcnt3+lcnt3)*100 ;
}
### 수정요청↓
if R3 > 40 Then
{
Condition3 = false;
}
else
{
Condition3 = true;
}
if Condition3 == true and R3 >= 70 then
Condition3 = false;
### 수정요청↑
Text_Delete(tx3);
tx3 = Text_New(NextBarSdate,NextBarStime,H,NumToStr(TR3,1)+NewLine+NumToStr(R3,1));
Text_SetSize(tx3,15);
Text_Setstyle(tx3,2,20);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = false;
if MarketPosition == 1 Then
{
ExitLong("BE6");
}
if MarketPosition == -1 Then
{
ExitShort("SE6");
}
}
2020-04-15
469
글번호 137941
시스템