커뮤니티
부탁드립니다.
2018-08-06 12:32:16
162
글번호 121139
감사드립니다.
1. 아래식에서 진입신호가 나오기전에 스위칭이 되는 횟수를 S(2) 두번으로 제한하고 싶습니다 수정 부탁드립니다.
2. SetStopProfittarget(0.2)의 익절과 같은 방식으로 손절(0.2) 수식을 추가 요청드립니다.
input : 익절3(22),스위칭(10);
input:b_time1(000001),e_time1(030000),
stoK_p11(50), stoK_p12(50), stoK_p13(10),
ma_p11(10),ma_p12(5),ma_p13(15),ma_p14(250),
ma_p15(20),ma_p16(10),ma_p17(38),
b_time2(030001),e_time2(180000),
stoK_p21(50),stoK_p22(50),stoK_p23(10),
ma_p21(25),ma_p22(5),ma_p23(15),ma_p24(127),
ma_p25(68),ma_p26(10),ma_p27(15),
b_time3(180001),e_time3(240000),
stoK_p31(50),stoK_p32(50),stoK_p33(10),
ma_p31(25),ma_p32(5),ma_p33(15),ma_p34(102),
ma_p35(40),ma_p36(10),ma_p37(15);
var : BH(0),SL(0),para(0),HE(0),LE(0);
Var:stoK(0),stoD(0),TRIXv(0),TRIXsig(0);
var : StochasticsKS1(0),StochasticsDS1(0),HV1(0),Lv1(0),FK1(0);
var : StochasticsKS2(0),StochasticsDS2(0),HV2(0),Lv2(0),FK2(0);
var : StochasticsKS3(0),StochasticsDS3(0),HV3(0),Lv3(0),FK3(0);
LV1 = Lowest(L, stoK_p11);
HV1 = Highest(H, stoK_p11);
FK1 = (Close - LV1) / (HV1 - LV1) * 100;
StochasticsKS1 = ma(FK1,stoK_p12);
StochasticsDS1 = ma(StochasticsKS1,stoK_p13);
LV2 = Lowest(L, stoK_p21);
HV2 = Highest(H, stoK_p21);
FK2 = (Close - LV2) / (HV2 - LV2) * 100;
StochasticsKS2 = ma(FK2,stoK_p22);
StochasticsDS2 = ma(StochasticsKS2,stoK_p23);
LV3 = Lowest(L, stoK_p31);
HV3 = Highest(H, stoK_p31);
FK3 = (Close - LV3) / (HV3 - LV3) * 100;
StochasticsKS3 = ma(FK3,stoK_p32);
StochasticsDS3 = ma(StochasticsKS3,stoK_p33);
If b_time1 <= Time and Time <= e_time1 Then
{
stoK = StochasticsKS1;
stoD = StochasticsDS1;
If countif(ma(C,ma_p11)[1] < ma(C,ma_p11),1) == 1
and (ma(C,ma_p12)[1] <= ma(C,ma_p13)[1] and ma(C,ma_p12) > ma(C,ma_p13))
and countif(ma(C,ma_p14)[1] < ma(C,ma_p14),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수1",AtMarket);
}
If countif(ma(C,ma_p11)[1] > ma(C,ma_p11),1) == 1
and (ma(C,ma_p12)[1] >= ma(C,ma_p13)[1] and ma(C,ma_p12) < ma(C,ma_p13))
and countif(ma(C,ma_p14)[1] > ma(C,ma_p14),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도1",AtMarket);
}
// SetStopProfittarget(목표청산1);
}
If b_time2 <= Time and Time <= e_time2 Then
{
stoK = StochasticsKS2;
stoD = StochasticsDS2;
If countif(ma(C,ma_p21)[1] < ma(C,ma_p21),1) == 1
and (ma(C,ma_p22)[1] <= ma(C,ma_p23)[1] and ma(C,ma_p22) > ma(C,ma_p23))
and countif(ma(C,ma_p24)[1] < ma(C,ma_p24),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수2",AtMarket);
}
If countif(ma(C,ma_p21)[1] > ma(C,ma_p21),1) == 1
and (ma(C,ma_p22)[1] >= ma(C,ma_p23)[1] and ma(C,ma_p22) < ma(C,ma_p23))
and countif(ma(C,ma_p24)[1] > ma(C,ma_p24),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도2",AtMarket);
}
// SetStopProfittarget(목표청산2);
}
If b_time3 <= Time and Time <= e_time3 Then
{
stoK = StochasticsKS3;
stoD = StochasticsDS3;
If countif(ma(C,ma_p31)[1] < ma(C,ma_p31),1) == 1
and (ma(C,ma_p32)[1] <= ma(C,ma_p33)[1] and ma(C,ma_p32) > ma(C,ma_p33))
and countif(ma(C,ma_p34)[1] < ma(C,ma_p34),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수3",AtMarket);
}
If countif(ma(C,ma_p31)[1] > ma(C,ma_p31),1) == 1
and (ma(C,ma_p32)[1] >= ma(C,ma_p33)[1] and ma(C,ma_p32) < ma(C,ma_p33))
and countif(ma(C,ma_p34)[1] > ma(C,ma_p34),1) == 1
and countif(ma(C,ma_p35)[1] > ma(C,ma_p35),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도3",AtMarket);
}
// SetStopProfittarget(목표청산3);
}
############## 스위칭 ############
if MarketPosition == 1 Then{
BH = highest(H,BarsSinceEntry);
if MaxEntries == 1 Then
HE = LatestEntryPrice(0);
if MaxEntries >= 2 and LatestEntryPrice(0) > HE Then
HE = LatestEntryPrice(0);
if BH >= EntryPrice+PriceScale*익절3 then{
ExitLong("B익절%",AtStop,BH-(BH-EntryPrice)*0.1);
}
SetStopProfittarget(0.2); #동일방식 손절 추가요청
Sell("B스위칭",AtStop,HE-PriceScale*스위칭);
}
if MarketPosition == -1 Then{
SL = Lowest(L,BarsSinceEntry);
if MaxEntries == 1 Then
LE = LatestEntryPrice(0);
if MaxEntries >= 2 and LatestEntryPrice(0) < LE Then
LE = LatestEntryPrice(0);
if SL <= EntryPrice-PriceScale*익절3 then{
ExitShort("S익절%",AtStop,SL+(EntryPrice-SL)*0.1);
}
SetStopProfittarget(0.2); #동일방식 손절 추가요청
Buy("S스위칭",AtStop,LE+PriceScale*스위칭);
}
답변 1
예스스탁 예스스탁 답변
2018-08-07 09:43:20
안녕하세요
예스스탁입니다.
input : 익절3(22),스위칭(10),S(2);
input:b_time1(000001),e_time1(030000),
stoK_p11(50), stoK_p12(50), stoK_p13(10),
ma_p11(10),ma_p12(5),ma_p13(15),ma_p14(250),
ma_p15(20),ma_p16(10),ma_p17(38),
b_time2(030001),e_time2(180000),
stoK_p21(50),stoK_p22(50),stoK_p23(10),
ma_p21(25),ma_p22(5),ma_p23(15),ma_p24(127),
ma_p25(68),ma_p26(10),ma_p27(15),
b_time3(180001),e_time3(240000),
stoK_p31(50),stoK_p32(50),stoK_p33(10),
ma_p31(25),ma_p32(5),ma_p33(15),ma_p34(102),
ma_p35(40),ma_p36(10),ma_p37(15);
var : BH(0),SL(0),para(0),HE(0),LE(0);
var :stoK(0),stoD(0),TRIXv(0),TRIXsig(0);
var : StochasticsKS1(0),StochasticsDS1(0),HV1(0),Lv1(0),FK1(0);
var : StochasticsKS2(0),StochasticsDS2(0),HV2(0),Lv2(0),FK2(0);
var : StochasticsKS3(0),StochasticsDS3(0),HV3(0),Lv3(0),FK3(0);
var : sw(0);
LV1 = Lowest(L, stoK_p11);
HV1 = Highest(H, stoK_p11);
FK1 = (Close - LV1) / (HV1 - LV1) * 100;
StochasticsKS1 = ma(FK1,stoK_p12);
StochasticsDS1 = ma(StochasticsKS1,stoK_p13);
LV2 = Lowest(L, stoK_p21);
HV2 = Highest(H, stoK_p21);
FK2 = (Close - LV2) / (HV2 - LV2) * 100;
StochasticsKS2 = ma(FK2,stoK_p22);
StochasticsDS2 = ma(StochasticsKS2,stoK_p23);
LV3 = Lowest(L, stoK_p31);
HV3 = Highest(H, stoK_p31);
FK3 = (Close - LV3) / (HV3 - LV3) * 100;
StochasticsKS3 = ma(FK3,stoK_p32);
StochasticsDS3 = ma(StochasticsKS3,stoK_p33);
//스위칭 횟수카운트
if MarketPosition(0) != 0 and MarketPosition(0) != MarketPosition(0)[1] Then
{
if MarketPosition(0)[1] != 0 Then
sw = sw+1;
}
if MarketPosition == 0 Then
sw = 0;
If b_time1 <= Time and Time <= e_time1 and SW < S Then
{
stoK = StochasticsKS1;
stoD = StochasticsDS1;
If countif(ma(C,ma_p11)[1] < ma(C,ma_p11),1) == 1
and (ma(C,ma_p12)[1] <= ma(C,ma_p13)[1] and ma(C,ma_p12) > ma(C,ma_p13))
and countif(ma(C,ma_p14)[1] < ma(C,ma_p14),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수1",AtMarket);
}
If countif(ma(C,ma_p11)[1] > ma(C,ma_p11),1) == 1
and (ma(C,ma_p12)[1] >= ma(C,ma_p13)[1] and ma(C,ma_p12) < ma(C,ma_p13))
and countif(ma(C,ma_p14)[1] > ma(C,ma_p14),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도1",AtMarket);
}
}
If b_time2 <= Time and Time <= e_time2 and SW < S Then
{
stoK = StochasticsKS2;
stoD = StochasticsDS2;
If countif(ma(C,ma_p21)[1] < ma(C,ma_p21),1) == 1
and (ma(C,ma_p22)[1] <= ma(C,ma_p23)[1] and ma(C,ma_p22) > ma(C,ma_p23))
and countif(ma(C,ma_p24)[1] < ma(C,ma_p24),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수2",AtMarket);
}
If countif(ma(C,ma_p21)[1] > ma(C,ma_p21),1) == 1
and (ma(C,ma_p22)[1] >= ma(C,ma_p23)[1] and ma(C,ma_p22) < ma(C,ma_p23))
and countif(ma(C,ma_p24)[1] > ma(C,ma_p24),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도2",AtMarket);
}
}
If b_time3 <= Time and Time <= e_time3 and SW < S Then
{
stoK = StochasticsKS3;
stoD = StochasticsDS3;
If countif(ma(C,ma_p31)[1] < ma(C,ma_p31),1) == 1
and (ma(C,ma_p32)[1] <= ma(C,ma_p33)[1] and ma(C,ma_p32) > ma(C,ma_p33))
and countif(ma(C,ma_p34)[1] < ma(C,ma_p34),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수3",AtMarket);
}
If countif(ma(C,ma_p31)[1] > ma(C,ma_p31),1) == 1
and (ma(C,ma_p32)[1] >= ma(C,ma_p33)[1] and ma(C,ma_p32) < ma(C,ma_p33))
and countif(ma(C,ma_p34)[1] > ma(C,ma_p34),1) == 1
and countif(ma(C,ma_p35)[1] > ma(C,ma_p35),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도3",AtMarket);
}
// SetStopProfittarget(목표청산3);
}
############## 스위칭 ############
if MarketPosition == 1 Then{
BH = highest(H,BarsSinceEntry);
if MaxEntries == 1 Then
HE = LatestEntryPrice(0);
if MaxEntries >= 2 and LatestEntryPrice(0) > HE Then
HE = LatestEntryPrice(0);
if BH >= EntryPrice+PriceScale*익절3 then{
ExitLong("B익절%",AtStop,BH-(BH-EntryPrice)*0.1);
}
if SW < S then
Sell("B스위칭",AtStop,HE-PriceScale*스위칭);
}
if MarketPosition == -1 Then
{
SL = Lowest(L,BarsSinceEntry);
if MaxEntries == 1 Then
LE = LatestEntryPrice(0);
if MaxEntries >= 2 and LatestEntryPrice(0) < LE Then
LE = LatestEntryPrice(0);
if SL <= EntryPrice-PriceScale*익절3 then
{
ExitShort("S익절%",AtStop,SL+(EntryPrice-SL)*0.1);
}
if SW < S then
Buy("S스위칭",AtStop,LE+PriceScale*스위칭);
}
SetStopProfittarget(0.2);
SetStoploss(0.2);
즐거운 하루되세요
> 라떼처럼 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 감사드립니다.
1. 아래식에서 진입신호가 나오기전에 스위칭이 되는 횟수를 S(2) 두번으로 제한하고 싶습니다 수정 부탁드립니다.
2. SetStopProfittarget(0.2)의 익절과 같은 방식으로 손절(0.2) 수식을 추가 요청드립니다.
input : 익절3(22),스위칭(10);
input:b_time1(000001),e_time1(030000),
stoK_p11(50), stoK_p12(50), stoK_p13(10),
ma_p11(10),ma_p12(5),ma_p13(15),ma_p14(250),
ma_p15(20),ma_p16(10),ma_p17(38),
b_time2(030001),e_time2(180000),
stoK_p21(50),stoK_p22(50),stoK_p23(10),
ma_p21(25),ma_p22(5),ma_p23(15),ma_p24(127),
ma_p25(68),ma_p26(10),ma_p27(15),
b_time3(180001),e_time3(240000),
stoK_p31(50),stoK_p32(50),stoK_p33(10),
ma_p31(25),ma_p32(5),ma_p33(15),ma_p34(102),
ma_p35(40),ma_p36(10),ma_p37(15);
var : BH(0),SL(0),para(0),HE(0),LE(0);
Var:stoK(0),stoD(0),TRIXv(0),TRIXsig(0);
var : StochasticsKS1(0),StochasticsDS1(0),HV1(0),Lv1(0),FK1(0);
var : StochasticsKS2(0),StochasticsDS2(0),HV2(0),Lv2(0),FK2(0);
var : StochasticsKS3(0),StochasticsDS3(0),HV3(0),Lv3(0),FK3(0);
LV1 = Lowest(L, stoK_p11);
HV1 = Highest(H, stoK_p11);
FK1 = (Close - LV1) / (HV1 - LV1) * 100;
StochasticsKS1 = ma(FK1,stoK_p12);
StochasticsDS1 = ma(StochasticsKS1,stoK_p13);
LV2 = Lowest(L, stoK_p21);
HV2 = Highest(H, stoK_p21);
FK2 = (Close - LV2) / (HV2 - LV2) * 100;
StochasticsKS2 = ma(FK2,stoK_p22);
StochasticsDS2 = ma(StochasticsKS2,stoK_p23);
LV3 = Lowest(L, stoK_p31);
HV3 = Highest(H, stoK_p31);
FK3 = (Close - LV3) / (HV3 - LV3) * 100;
StochasticsKS3 = ma(FK3,stoK_p32);
StochasticsDS3 = ma(StochasticsKS3,stoK_p33);
If b_time1 <= Time and Time <= e_time1 Then
{
stoK = StochasticsKS1;
stoD = StochasticsDS1;
If countif(ma(C,ma_p11)[1] < ma(C,ma_p11),1) == 1
and (ma(C,ma_p12)[1] <= ma(C,ma_p13)[1] and ma(C,ma_p12) > ma(C,ma_p13))
and countif(ma(C,ma_p14)[1] < ma(C,ma_p14),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수1",AtMarket);
}
If countif(ma(C,ma_p11)[1] > ma(C,ma_p11),1) == 1
and (ma(C,ma_p12)[1] >= ma(C,ma_p13)[1] and ma(C,ma_p12) < ma(C,ma_p13))
and countif(ma(C,ma_p14)[1] > ma(C,ma_p14),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도1",AtMarket);
}
// SetStopProfittarget(목표청산1);
}
If b_time2 <= Time and Time <= e_time2 Then
{
stoK = StochasticsKS2;
stoD = StochasticsDS2;
If countif(ma(C,ma_p21)[1] < ma(C,ma_p21),1) == 1
and (ma(C,ma_p22)[1] <= ma(C,ma_p23)[1] and ma(C,ma_p22) > ma(C,ma_p23))
and countif(ma(C,ma_p24)[1] < ma(C,ma_p24),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수2",AtMarket);
}
If countif(ma(C,ma_p21)[1] > ma(C,ma_p21),1) == 1
and (ma(C,ma_p22)[1] >= ma(C,ma_p23)[1] and ma(C,ma_p22) < ma(C,ma_p23))
and countif(ma(C,ma_p24)[1] > ma(C,ma_p24),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도2",AtMarket);
}
// SetStopProfittarget(목표청산2);
}
If b_time3 <= Time and Time <= e_time3 Then
{
stoK = StochasticsKS3;
stoD = StochasticsDS3;
If countif(ma(C,ma_p31)[1] < ma(C,ma_p31),1) == 1
and (ma(C,ma_p32)[1] <= ma(C,ma_p33)[1] and ma(C,ma_p32) > ma(C,ma_p33))
and countif(ma(C,ma_p34)[1] < ma(C,ma_p34),1) == 1
Then
{
If !(ExitName(1) == "B익절%" and
(EntryName(1) == "매수1" or EntryName(1) == "매수2" or EntryName(1) == "매수3") and
MarketPosition == 0) Then
Buy("매수3",AtMarket);
}
If countif(ma(C,ma_p31)[1] > ma(C,ma_p31),1) == 1
and (ma(C,ma_p32)[1] >= ma(C,ma_p33)[1] and ma(C,ma_p32) < ma(C,ma_p33))
and countif(ma(C,ma_p34)[1] > ma(C,ma_p34),1) == 1
and countif(ma(C,ma_p35)[1] > ma(C,ma_p35),1) == 1
Then
{
If !(ExitName(1) == "S익절%" and
(EntryName(1) == "매도1" or EntryName(1) == "매도2" or EntryName(1) == "매도3") and
MarketPosition == 0) Then
Sell("매도3",AtMarket);
}
// SetStopProfittarget(목표청산3);
}
############## 스위칭 ############
if MarketPosition == 1 Then{
BH = highest(H,BarsSinceEntry);
if MaxEntries == 1 Then
HE = LatestEntryPrice(0);
if MaxEntries >= 2 and LatestEntryPrice(0) > HE Then
HE = LatestEntryPrice(0);
if BH >= EntryPrice+PriceScale*익절3 then{
ExitLong("B익절%",AtStop,BH-(BH-EntryPrice)*0.1);
}
SetStopProfittarget(0.2); #동일방식 손절 추가요청
Sell("B스위칭",AtStop,HE-PriceScale*스위칭);
}
if MarketPosition == -1 Then{
SL = Lowest(L,BarsSinceEntry);
if MaxEntries == 1 Then
LE = LatestEntryPrice(0);
if MaxEntries >= 2 and LatestEntryPrice(0) < LE Then
LE = LatestEntryPrice(0);
if SL <= EntryPrice-PriceScale*익절3 then{
ExitShort("S익절%",AtStop,SL+(EntryPrice-SL)*0.1);
}
SetStopProfittarget(0.2); #동일방식 손절 추가요청
Buy("S스위칭",AtStop,LE+PriceScale*스위칭);
}
다음글