답변완료
수정부탁드립니다.
안녕하세요? 아래와같은 답변 감사히 잘받았습니다.
매매횟수가 적용이안되서 죄송하지만 한번더 검토 부탁드리겠습니다.
횟수에 1회~5회까지 다양하게 적용해봤는데 훨씬많이 나오는 증상입니다.
부탁드리겠습니다. 감사합니다.
안녕하세요
예스스탁입니다.
Input : 단기(5), 장기(20), profit_pt(0.5), loss_pt(0.5), 장종료청산(151000),진입횟수(3);
Variable : ent_position(0),entry(0);
if MarketPosition == 0 Then{
var1 = 0;
ent_position = 0;
entry = 0;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition != MarketPosition[1] and TotalTrades > TotalTrades[1]) then
entry = entry+1;
//If ma(C,단기)>ma(C,장기) and ( C>O and L==O ) or ( C[1]<O[1] and H[1]==O[1] and C>O ) Then {
If ma(C,단기)>ma(C,장기) and ( C>O and L==O ) and ent_position == 0 and entry < 진입횟수 Then {
Buy("매수",AtMarket);
Var1 = NextBarOpen;
ent_position = 1;
}
//If ma(C,단기)<ma(C,장기) and ( C<O and H==O ) or ( C[1]>O[1] and L[1]==O[1] and C<O ) Then {
If ma(C,단기)<ma(C,장기) and ( C<O and H==O ) and ent_position == 0 and entry < 진입횟수 Then {
Sell("매도",AtMarket);
Var1 = NextBarOpen;
ent_position = -1;
}
if PositionProfit >= profit_pt and ent_position<>0 Then{
if ent_position == 1 and C<O Then {
ExitLong("매수청산");
}
if ent_position == -1 and C>O Then {
ExitLong("매도청산");
}
}
SetStopLoss(loss_pt,PointStop);
SetStopEndofday(장종료청산);
즐거운 하루되세요
> 대구어린울프 님이 쓴 글입니다.
> 제목 : 수정 부탁드립니다.
> 안녕하세요?
아래의 수식에서 하루매매횟를 외부변수로 넣고싶습니다.
부탁드립니다.
감사합니다.
Input : 단기(5), 장기(20), profit_pt(0.5), loss_pt(0.5), 장종료청산(151000);
Variable : ent_position(0);
if MarketPosition == 0 Then{
var1 = 0;
ent_position = 0;
}
//If ma(C,단기)>ma(C,장기) and ( C>O and L==O ) or ( C[1]<O[1] and H[1]==O[1] and C>O ) Then {
If ma(C,단기)>ma(C,장기) and ( C>O and L==O ) and ent_position == 0 Then {
Buy("매수",AtMarket);
Var1 = NextBarOpen;
ent_position = 1;
}
//If ma(C,단기)<ma(C,장기) and ( C<O and H==O ) or ( C[1]>O[1] and L[1]==O[1] and C<O ) Then {
If ma(C,단기)<ma(C,장기) and ( C<O and H==O ) and ent_position == 0 Then {
Sell("매도",AtMarket);
Var1 = NextBarOpen;
ent_position = -1;
}
if PositionProfit >= profit_pt and ent_position<>0 Then{
if ent_position == 1 and C<O Then {
ExitLong("매수청산");
}
if ent_position == -1 and C>O Then {
ExitLong("매도청산");
}
}
SetStopLoss(loss_pt,PointStop);
SetStopEndofday(장종료청산);
2020-07-13
1638
글번호 140636
시스템
답변완료
수식부탁합니다
아래 두가지 지표식을 하나로 구성해 Gold cross와 Dead Cross 종목검색식 부탁합니다
두가지 지표식에서 공통적으로 plot2 가지고 검색식 부탁합니다
2번지표식 plot2가 1번지표식 plot2를 상승해서 돌파하면 Gold cross
2번지표식 plot2가 1번지표식 plot2를 하락 돌파하면 Dead cross
* 1번지표식
Var:chng_rt(0),j(0),ma_val(0),std_val(0),dn_rng(0),up_rng(0),rawVBE_up(0),rawVBE_dn(0);
Array:len[6](0),VBE_up[6](0),VBE_dn[6](0),
up_chg[6](0),dn_chg[6](0),up_cor[6](0),dn_cor[6](0),
fcstVBE_up[6](0),fcstVBE_dn[6](0);
len[0] = 21;
len[1] = 17;
len[2] = 13;
len[3] = 9;
len[4] = 5;
len[5] = 2;
chng_rt = (C/C[1]-1); //가격 변동률
ma_val = ma(chng_rt,len[0]); //가격변동률의 평균
std_val = Std(chng_rt,len[0]); //가격변동률의 표준편차
dn_rng = ma_val - (std_val * 2);
up_rng = ma_val + (std_val * 2);
rawVBE_up = C * (1 + up_rng); //원시VBE
rawVBE_dn = C * (1 + dn_rng);
for j = 0 to 5 {
VBE_up[j] = wma(rawVBE_up,len[j]); //원시VBE를 가중이평으로 평활화
VBE_dn[j] = wma(rawVBE_dn,len[j]);
if VBE_up[j][1] > 0 then up_chg[j] = (VBE_up[j]-VBE_up[j][1])/VBE_up[j][1]; //VBE의 변동률
if VBE_dn[j][1] > 0 then dn_chg[j] = (VBE_dn[j]-VBE_dn[j][1])/VBE_dn[j][1];
}
fcstVBE_up[0] = VBE_up[0];
fcstVBE_dn[0] = VBE_dn[0];
for j = 1 to 5 {
up_cor[j] = Correlation(up_chg[0], up_chg[j],63); //21일 VBE변동률과 17,13,9,5,2 변동률간의 상관도
dn_cor[j] = Correlation(dn_chg[0], dn_chg[j],63);
fcstVBE_up[j] = fcstVBE_up[j-1] * (1+(up_chg[j]*up_cor[j])); //이전값에 상관도와 변동률을 곱해서 계산
fcstVBE_dn[j] = fcstVBE_dn[j-1] * (1+(dn_chg[j]*dn_cor[j]));
}
plot1(fcstVBE_up[0],"상-5",RED); //5봉 뒤로 이동
plot2(fcstVBE_dn[0],"하-5",Black); //5봉 뒤로 이동
if LastBarOnChart then { //마지막봉에서 아래 5봉만 추가로 출력
plot3(fcstVBE_up[5],"상0",RED);
plot4(fcstVBE_up[4],"상-1",RED); //1봉 뒤로 이동
plot5(fcstVBE_up[3],"상-2",RED); //2봉 뒤로 이동
plot6(fcstVBE_up[2],"상-3",RED); //3봉 뒤로 이동
plot7(fcstVBE_up[1],"상-4",RED); //4봉 뒤로 이동
plot8(fcstVBE_dn[5],"하0",BLUE);
plot9(fcstVBE_dn[4],"하-1",BLUE); //1봉 뒤로 이동
plot10(fcstVBE_dn[3],"하-2",BLUE); //2봉 뒤로 이동
plot11(fcstVBE_dn[2],"하-3",BLUE); //3봉 뒤로 이동
plot12(fcstVBE_dn[1],"하-4",BLUE); //4봉 뒤로 이동
}
* 2번지표식
input:N(9),multi(2),Period(63);
Var:chng_rt(0),j(0),ma_val(0),std_val(0),dn_rng(0),up_rng(0),rawVBE_up(0),rawVBE_dn(0);
Array:len[11](0),VBE_up[11](0),VBE_dn[11](0),
up_chg[11](0),dn_chg[11](0),up_cor[11](0),dn_cor[11](0),
fcstVBE_up[11](0),fcstVBE_dn[11](0);
len[0] = 2;
len[1] = 5;
len[2] = 9;
len[3] = 13;
len[4] = 17;
len[5] = 21;
len[6] = 25;
len[7] = 29;
len[8] = 33;
len[9] = 37;
len[10] = 41;
chng_rt = (C/C[1]-1); // 가격 변동률
ma_val = ma(chng_rt,len[N]); // 가격변동률의 평균
std_val = Std(chng_rt,len[N]); // 가격변동률의 표준편차
dn_rng = ma_val - (std_val * multi);
up_rng = ma_val + (std_val * multi);
rawVBE_up = C * (1 + up_rng); // 원시VBE
rawVBE_dn = C * (1 + dn_rng);
for j = 0 to N {
VBE_up[j] = wma(rawVBE_up,len[j]); // 원시VBE를 가중이평으로 평활화
VBE_dn[j] = wma(rawVBE_dn,len[j]);
if VBE_up[j][1] > 0 then up_chg[j] = (VBE_up[j]-VBE_up[j][1])/VBE_up[j][1]; // VBE의 변동률
if VBE_dn[j][1] > 0 then dn_chg[j] = (VBE_dn[j]-VBE_dn[j][1])/VBE_dn[j][1];
}
fcstVBE_up[N] = VBE_up[N];
fcstVBE_dn[N] = VBE_dn[N];
for j = N - 1 downto 0 {
up_cor[j] = Correlation(up_chg[N], up_chg[j],Period); // 21일 VBE변동률과 17,13,9,5,2 변동률간의 상관도
dn_cor[j] = Correlation(dn_chg[N], dn_chg[j],Period);
fcstVBE_up[j] = fcstVBE_up[j+1] * (1+(up_chg[j]*up_cor[j])); // 이전값에 상관도와 변동률을 곱해서 계산
fcstVBE_dn[j] = fcstVBE_dn[j+1] * (1+(dn_chg[j]*dn_cor[j]));
}
Var:Size(4);
plot1(fcstVBE_up[N],"상-N",RED,DEF,Size-1); // N봉 뒤로 이동
plot2(fcstVBE_dn[N],"하-N",BLUE,DEF,Size-1); // N봉 뒤로 이동
FixPlotShift(1,-N);
FixPlotShift(2,-N);
if LastBarOnChart then { // 마지막봉에서 아래 N봉만 추가로 출력
plot3(fcstVBE_up[0],"상0",RED,DEF,Size);
if N > 1 then plot4(fcstVBE_up[1],"상-1",RED,DEF,Size); // 1봉 뒤로 이동
if N > 2 then plot5(fcstVBE_up[2],"상-2",RED,DEF,Size); // 2봉 뒤로 이동
if N > 3 then plot6(fcstVBE_up[3],"상-3",RED,DEF,Size); // 3봉 뒤로 이동
if N > 4 then plot7(fcstVBE_up[4],"상-4",RED,DEF,Size); // 4봉 뒤로 이동
if N > 5 then plot8(fcstVBE_up[5],"상-5",RED,DEF,Size); // 5봉 뒤로 이동
if N > 6 then plot9(fcstVBE_up[6],"상-6",RED,DEF,Size); // 6봉 뒤로 이동
if N > 7 then plot10(fcstVBE_up[7],"상-7",RED,DEF,Size); // 7봉 뒤로 이동
if N > 8 then plot11(fcstVBE_up[8],"상-8",RED,DEF,Size); // 8봉 뒤로 이동
plot12(fcstVBE_dn[0],"하0",BLUE,DEF,Size);
if N > 1 then plot13(fcstVBE_dn[1],"하-1",BLUE,DEF,Size); // 1봉 뒤로 이동
if N > 2 then plot14(fcstVBE_dn[2],"하-2",BLUE,DEF,Size); // 2봉 뒤로 이동
if N > 3 then plot15(fcstVBE_dn[3],"하-3",BLUE,DEF,Size); // 3봉 뒤로 이동
if N > 4 then plot16(fcstVBE_dn[4],"하-4",BLUE,DEF,Size); // 4봉 뒤로 이동
if N > 5 then plot17(fcstVBE_dn[5],"하-5",BLUE,DEF,Size); // 5봉 뒤로 이동
if N > 6 then plot18(fcstVBE_dn[6],"하-6",BLUE,DEF,Size); // 6봉 뒤로 이동
if N > 7 then plot19(fcstVBE_dn[7],"하-7",BLUE,DEF,Size); // 7봉 뒤로 이동
if N > 8 then plot20(fcstVBE_dn[8],"하-8",BLUE,DEF,Size); // 8봉 뒤로 이동
FixPlotShift(4,-1);
FixPlotShift(5,-2);
FixPlotShift(6,-3);
FixPlotShift(7,-4);
FixPlotShift(8,-5);
FixPlotShift(9,-6);
FixPlotShift(10,-7);
FixPlotShift(11,-8);
FixPlotShift(13,-1);
FixPlotShift(14,-2);
FixPlotShift(15,-3);
FixPlotShift(16,-4);
FixPlotShift(17,-5);
FixPlotShift(18,-6);
FixPlotShift(19,-7);
FixPlotShift(20,-8);
}
2020-07-13
2060
글번호 140607
종목검색