커뮤니티
수식문의 부탁합니다
2005-05-27 13:51:31
1534
글번호 7478
- 좋은 답변에 감사드립니다
*기본설정
- 연결선물지수,5분봉,당일청산 시스템식입니다
- 시초가 전일변동폭 채널 돌파식입니다.
- atstop으로 매수/매도 진입이후 추적스탑 청산이후에
추적스탑청산 가격 일정수준 이상 동일방향으로
추세 형성시 재진입조건입니다.
수식문의 ) 추적청산이후 동일봉에서 매도/매수가 바로 발생합니다
onclose주문형태[cross(c,채널)]에서는 추적스탑청산이후 동일봉에서
바로 매수/매도신호가 발생하지 않습니다.
포지션함수을 이용해서 다각적으로 coding을 해도 잘 안되네요
//시스템식
Input : RangeX(0.4);
Var : BarRange(0),Range(0),RangeUpCh(0),RangeDnCh(0),Cond1(0),Cond2(0),MP(0);
Var : BBpos(0),SSpos(0),Bpos1(0),Spos1(0),Bpos2(0),Spos2(0),Bpos3(0),Spos3(0);
Var : Bindx(0),Sindx(0),PosHigh(0),PosLow(0);
Var : BuyVal1(0),SellVal1(0),BuyVal2(0),SellVal2(0),BuyVal3(0),SellVal3(0);
Var : stopX(1.5),profitX(4.2),tsX(1.2),beX(0.8),bpX(2.5);
##변수할당 및 사용자함수 정의
BarRange = DayHigh(1)-DayLow(1);
Range = BarRange*RangeX;
RangeUpCh = DayOpen()+Range;
RangeDnCh = DayOpen()-Range;
Cond1 = Date==ExitDate(1)&&MarketPosition(1)==1;
Cond2 = Date==ExitDate(1)&&MarketPosition(1)==-1;
MP = MarketPosition();
##변수초기화
If Date[1]!=Date||MP[1]!=MP[0] then {
BBpos = 0;
SSpos = 0;
Bpos1 = 0;
Spos1 = 0;
Bpos2 = 0;
Spos2 = 0;
Bpos3 = 0;
Spos3 = 0;
}
###진입전략
//매수진입
If sTime<=144500 then {
if cond1==false then {
Buy("LE",atstop,RangeUpCh);
BBpos = 1;
Bindx = DayIndex();
Bpos1 = 0;
Bpos2 = 0;
Bpos3 = 0;
}
if Cond2==false then {
Sell("SE",atstop,RangeDnCh);
SSpos = 1;
Sindx = DayIndex();
Spos1 = 0;
Spos2 = 0;
Spos3 = 0;
}
}
###청산전략
##강제청산
SetStopLoss(stopX);
SetStopProfittarget(ProfitX);
SetStopEndofday(150400);
##수익청산
//PosLH정의 (1)
If MP[1]!=MP[0] then {
PosHigh = -999;
PosLow = 999;
if MP!=0 then {
PosHigh = H;
PosLow = L;
}
}
If MP!=0 then {
PosHigh = max(PosHigh,H);
PosLow = min(PosLow,L);
}
#추적청산
//추적청산을 위한 SetProfit설정
If BBpos==1&&PosHigh>EntryPrice()+(EntryPrice()*tsX/100) then {
Bpos1 = 1;
BuyVal1 = c;
}
If SSpos==1&&PosLow<EntryPrice()-(EntryPrice()*tsX/100) then {
Spos1 = 1;
SellVal2 = c;
}
//추적청산전략
If Bpos1==1 then {
ExitLong("LTS",atstop,PosHigh-0.3);
BBpos = 0;
Bpos1 = 0;
}
If Spos1==1 then {
ExitShort("STS",atstop,PosLow+0.3);
SSpos = 0;
Spos1 = 0;
}
답변 1
예스스탁 예스스탁 답변
2005-05-30 15:31:48
안녕하세요
예스스탁입니다.
marketoisition의 경우 봉이 완성되야 알수 있습니다.
예를 들어 매도진입을 하고 추적스탑으로 청산 되고 다시 매도진입 조건이 만족하여
진입한 경우 중간에 청산된후 marketoisition이 0이되는것이아니라 중간에 다시 매도진입을 하고 봉의 완성되므로 계속 -1값을 가져오게 됩니다.
진입식을 무포지션상태일 경우만 진입하게 했습니다.
//시스템식
Input : RangeX(0.4);
Var : BarRange(0),Range(0),RangeUpCh(0),RangeDnCh(0),Cond1(0),Cond2(0),MP(0);
Var : BBpos(0),SSpos(0),Bpos1(0),Spos1(0),Bpos2(0),Spos2(0),Bpos3(0),Spos3(0);
Var : Bindx(0),Sindx(0),PosHigh(0),PosLow(0);
Var : BuyVal1(0),SellVal1(0),BuyVal2(0),SellVal2(0),BuyVal3(0),SellVal3(0);
Var : stopX(1.5),profitX(4.2),tsX(1.2),beX(0.8),bpX(2.5);
##변수할당 및 사용자함수 정의
BarRange = DayHigh(1)-DayLow(1);
Range = BarRange*RangeX;
RangeUpCh = DayOpen()+Range;
RangeDnCh = DayOpen()-Range;
Cond1 = Date==ExitDate(1)&&MarketPosition(1)==1;
Cond2 = Date==ExitDate(1)&&MarketPosition(1)==-1;
MP = MarketPosition();
##변수초기화
If Date[1]!=Date||MP[1]!=MP[0] then {
BBpos = 0;
SSpos = 0;
Bpos1 = 0;
Spos1 = 0;
Bpos2 = 0;
Spos2 = 0;
Bpos3 = 0;
Spos3 = 0;
}
###진입전략
//매수진입
If sTime<=144500 and marketposition() == 0 then {
if cond1==false then {
Buy("LE",atstop,RangeUpCh);
BBpos = 1;
Bindx = DayIndex();
Bpos1 = 0;
Bpos2 = 0;
Bpos3 = 0;
}
if Cond2==false then {
Sell("SE",atstop,RangeDnCh);
SSpos = 1;
Sindx = DayIndex();
Spos1 = 0;
Spos2 = 0;
Spos3 = 0;
}
}
###청산전략
##강제청산
SetStopLoss(stopX);
SetStopProfittarget(ProfitX);
SetStopEndofday(150400);
##수익청산
//PosLH정의 (1)
If MP[1]!=MP[0] then {
PosHigh = -999;
PosLow = 999;
if MP!=0 then {
PosHigh = H;
PosLow = L;
}
}
If MP!=0 then {
PosHigh = max(PosHigh,H);
PosLow = min(PosLow,L);
}
#추적청산
//추적청산을 위한 SetProfit설정
If BBpos==1&&PosHigh>EntryPrice()+(EntryPrice()*tsX/100) then {
Bpos1 = 1;
BuyVal1 = c;
}
If SSpos==1&&PosLow<EntryPrice()-(EntryPrice()*tsX/100) then {
Spos1 = 1;
SellVal2 = c;
}
//추적청산전략
If Bpos1==1 then {
ExitLong("LTS",atstop,PosHigh-0.3);
BBpos = 0;
Bpos1 = 0;
}
If Spos1==1 then {
ExitShort("STS",atstop,PosLow+0.3);
SSpos = 0;
Spos1 = 0;
}
즐거운 하루되세요
> 내호림 님이 쓴 글입니다.
> 제목 : 수식문의 부탁합니다
> - 좋은 답변에 감사드립니다
*기본설정
- 연결선물지수,5분봉,당일청산 시스템식입니다
- 시초가 전일변동폭 채널 돌파식입니다.
- atstop으로 매수/매도 진입이후 추적스탑 청산이후에
추적스탑청산 가격 일정수준 이상 동일방향으로
추세 형성시 재진입조건입니다.
수식문의 ) 추적청산이후 동일봉에서 매도/매수가 바로 발생합니다
onclose주문형태[cross(c,채널)]에서는 추적스탑청산이후 동일봉에서
바로 매수/매도신호가 발생하지 않습니다.
포지션함수을 이용해서 다각적으로 coding을 해도 잘 안되네요
//시스템식
Input : RangeX(0.4);
Var : BarRange(0),Range(0),RangeUpCh(0),RangeDnCh(0),Cond1(0),Cond2(0),MP(0);
Var : BBpos(0),SSpos(0),Bpos1(0),Spos1(0),Bpos2(0),Spos2(0),Bpos3(0),Spos3(0);
Var : Bindx(0),Sindx(0),PosHigh(0),PosLow(0);
Var : BuyVal1(0),SellVal1(0),BuyVal2(0),SellVal2(0),BuyVal3(0),SellVal3(0);
Var : stopX(1.5),profitX(4.2),tsX(1.2),beX(0.8),bpX(2.5);
##변수할당 및 사용자함수 정의
BarRange = DayHigh(1)-DayLow(1);
Range = BarRange*RangeX;
RangeUpCh = DayOpen()+Range;
RangeDnCh = DayOpen()-Range;
Cond1 = Date==ExitDate(1)&&MarketPosition(1)==1;
Cond2 = Date==ExitDate(1)&&MarketPosition(1)==-1;
MP = MarketPosition();
##변수초기화
If Date[1]!=Date||MP[1]!=MP[0] then {
BBpos = 0;
SSpos = 0;
Bpos1 = 0;
Spos1 = 0;
Bpos2 = 0;
Spos2 = 0;
Bpos3 = 0;
Spos3 = 0;
}
###진입전략
//매수진입
If sTime<=144500 then {
if cond1==false then {
Buy("LE",atstop,RangeUpCh);
BBpos = 1;
Bindx = DayIndex();
Bpos1 = 0;
Bpos2 = 0;
Bpos3 = 0;
}
if Cond2==false then {
Sell("SE",atstop,RangeDnCh);
SSpos = 1;
Sindx = DayIndex();
Spos1 = 0;
Spos2 = 0;
Spos3 = 0;
}
}
###청산전략
##강제청산
SetStopLoss(stopX);
SetStopProfittarget(ProfitX);
SetStopEndofday(150400);
##수익청산
//PosLH정의 (1)
If MP[1]!=MP[0] then {
PosHigh = -999;
PosLow = 999;
if MP!=0 then {
PosHigh = H;
PosLow = L;
}
}
If MP!=0 then {
PosHigh = max(PosHigh,H);
PosLow = min(PosLow,L);
}
#추적청산
//추적청산을 위한 SetProfit설정
If BBpos==1&&PosHigh>EntryPrice()+(EntryPrice()*tsX/100) then {
Bpos1 = 1;
BuyVal1 = c;
}
If SSpos==1&&PosLow<EntryPrice()-(EntryPrice()*tsX/100) then {
Spos1 = 1;
SellVal2 = c;
}
//추적청산전략
If Bpos1==1 then {
ExitLong("LTS",atstop,PosHigh-0.3);
BBpos = 0;
Bpos1 = 0;
}
If Spos1==1 then {
ExitShort("STS",atstop,PosLow+0.3);
SSpos = 0;
Spos1 = 0;
}
다음글
이전글