커뮤니티
재진입 제한
2012-06-16 01:29:22
276
글번호 52046
항상 정성스런 답변 감사드립니다.
아래의 시스템식에서
재진입은 손절후에 전거래 중의 최고점(매수)과 최저점(매도)을 5포인트이상 넘어설때
이루어집니다.
그런데, 매도를 예로 들면, 손절후 가격이 기준선인 "slowMA"를 넘어섰다가
"매수신호(buy1)"가 나오지 않은 상태에서 다시 하락하면, "Sell1"과 "Sell_re"의
신호가 같이 나오는 오류가 발생합니다("Sell1"이 먼저 진입했다가 청산되면, 진입하지
못하고 있던 "Sell_re"이 그다음에 바로 들어가는 오류)
그래서 매도의 경우,재진입식을 손절후 가격이 기준선인 "slowMA"을 넘어서지 않고
다시 하락하는 경우에만 재진입하도록 수정하고싶습니다.
(손절후 가격이 기준선"slowMA"을 넘어서면 다시 하락해도 재진입제한)
매수의 경우도 역시, 손절후 가격이 기준선인"slowMA"보다 하락하지 않고
다시 상승하는 경우만 재진입하도록 수정하려고 합니다.
수정부탁드립니다. 미리 감사드립니다.
----------------------------------------------------------------------------------
Input: SlowLen(35), ChLen(300), TrailBar(30), Rebar(300);
Vars: SlowMA(0),LEntryPrice(0), SEntryPrice(0), LCount(-999), SCount(-999),MP(0), Recnt(0),
L_re_EntryPrice(0), S_re_EntryPrice(0);
SlowMA = ma(C , SlowLen );
If CrossUp(Close , SlowMA) and index > 1 then {
LEntryPrice = Highest(H , TrailBar )[1];
LCount = index;
}
If MarketPosition <> 1 AND index < LCount + ChLen then
Buy("Buy1", atstop,LEntryPrice,1);
If CrossDown(Close , SlowMA) and index > 1 then {
SEntryPrice = Lowest(L , TrailBar )[1];
SCount = index;
}
If MarketPosition <> -1 AND index < SCount + ChLen then
Sell ("Sell1", atstop,SEntryPrice,1);
If MarketPosition == 1 then {
LCount = -999;
ExitLong("LongTStop_1", atstop, Lowest(L , TrailBar ),"Buy1",1,1);
exitlong("bloss1",AtStop,EntryPrice-20,"buy1",1,1);
}
If MarketPosition == -1 then {
SCount = -999;
ExitShort("ShortTStop_1", atstop, Highest(H , TrailBar),"Sell1",1,1);
ExitShort("sLoss1",AtStop,EntryPrice+20,"sell1",1,1);
}
//RE_BUY_SELL//
MP = MarketPosition;
If MP == 0 AND MP[1] == -1 then
ReCnt = 1;
If MP == 0 AND MP[1] == 1 then
ReCnt = 1;
if MarketPosition == 1 Then
L_re_EntryPrice = Highest(c,BarsSinceEntry);
If MarketPosition == 0 AND MarketPosition(1) == 1
and IsExitName("bloss1",1) == True AND ReCnt < Rebar then {
ReCnt = ReCnt + 1;
Buy ("Buy_re", AtStop, L_re_EntryPrice+5);
}
if MarketPosition == -1 Then
S_re_EntryPrice = lowest(L,BarsSinceEntry);
If MarketPosition == 0 AND MarketPosition(1) == -1
and IsExitName("sLoss1",1) == True AND ReCnt < Rebar then {
ReCnt = ReCnt + 1;
Sell ("Sell_re", AtStop, S_re_EntryPrice-5);
}
If MarketPosition == 1 and IsEntryName("Buy_re",0) == True then {
ExitLong("LongTStop_re", AtStop, Lowest(L , TrailBar));
}
if MarketPosition == -1 and IsEntryName("Sell_re",0) == True then {
ExitShort ("ShortTStop_re", Atstop, Highest(H , TrailBar));
}
답변 1
예스스탁 예스스탁 답변
2012-06-18 10:33:15
안녕하세요
예스스탁입니다.
매수재진입시에 SlowMA가 손절시 SlowMA보다 작은봉이 없을때만 매수재진입하게 수정했습니다
매도재진입시에 SlowMA가 손절시 SlowMA보다 큰봉이 없을때만 매도재진입하게 수정했습니다
Input: SlowLen(35), ChLen(300), TrailBar(30), Rebar(300);
Vars: SlowMA(0),LEntryPrice(0), SEntryPrice(0), LCount(-999), SCount(-999),MP(0), Recnt(0),
L_re_EntryPrice(0), S_re_EntryPrice(0);
SlowMA = ma(C , SlowLen );
If CrossUp(Close , SlowMA) and index > 1 then {
LEntryPrice = Highest(H , TrailBar )[1];
LCount = index;
}
If MarketPosition <> 1 AND index < LCount + ChLen then
Buy("Buy1", atstop,LEntryPrice,1);
If CrossDown(Close , SlowMA) and index > 1 then {
SEntryPrice = Lowest(L , TrailBar )[1];
SCount = index;
}
If MarketPosition <> -1 AND index < SCount + ChLen then
Sell ("Sell1", atstop,SEntryPrice,1);
If MarketPosition == 1 then {
LCount = -999;
ExitLong("LongTStop_1", atstop, Lowest(L , TrailBar ),"Buy1",1,1);
exitlong("bloss1",AtStop,EntryPrice-20,"buy1",1,1);
}
If MarketPosition == -1 then {
SCount = -999;
ExitShort("ShortTStop_1", atstop, Highest(H , TrailBar),"Sell1",1,1);
ExitShort("sLoss1",AtStop,EntryPrice+20,"sell1",1,1);
}
//RE_BUY_SELL//
MP = MarketPosition;
If MP == 0 AND MP[1] == -1 then
ReCnt = 1;
If MP == 0 AND MP[1] == 1 then
ReCnt = 1;
if MarketPosition == 1 Then
L_re_EntryPrice = Highest(c,BarsSinceEntry);
If MarketPosition == 0 AND MarketPosition(1) == 1
and IsExitName("bloss1",1) == True AND ReCnt < Rebar and
countif(SlowMA < SlowMA[BarsSinceEntry],BarsSinceexit(1)) < 1 then {
ReCnt = ReCnt + 1;
Buy ("Buy_re", AtStop, L_re_EntryPrice+5);
}
if MarketPosition == -1 Then
S_re_EntryPrice = lowest(L,BarsSinceEntry);
If MarketPosition == 0 AND MarketPosition(1) == -1
and IsExitName("sLoss1",1) == True AND ReCnt < Rebar and
countif(SlowMA > SlowMA[BarsSinceEntry],BarsSinceexit(1)) < 1 then {
ReCnt = ReCnt + 1;
Sell ("Sell_re", AtStop, S_re_EntryPrice-5);
}
If MarketPosition == 1 and IsEntryName("Buy_re",0) == True then {
ExitLong("LongTStop_re", AtStop, Lowest(L , TrailBar));
}
if MarketPosition == -1 and IsEntryName("Sell_re",0) == True then {
ExitShort ("ShortTStop_re", Atstop, Highest(H , TrailBar));
}
즐거운 하루되세요
> 공감n감사 님이 쓴 글입니다.
> 제목 : 재진입 제한
> 항상 정성스런 답변 감사드립니다.
아래의 시스템식에서
재진입은 손절후에 전거래 중의 최고점(매수)과 최저점(매도)을 5포인트이상 넘어설때
이루어집니다.
그런데, 매도를 예로 들면, 손절후 가격이 기준선인 "slowMA"를 넘어섰다가
"매수신호(buy1)"가 나오지 않은 상태에서 다시 하락하면, "Sell1"과 "Sell_re"의
신호가 같이 나오는 오류가 발생합니다("Sell1"이 먼저 진입했다가 청산되면, 진입하지
못하고 있던 "Sell_re"이 그다음에 바로 들어가는 오류)
그래서 매도의 경우,재진입식을 손절후 가격이 기준선인 "slowMA"을 넘어서지 않고
다시 하락하는 경우에만 재진입하도록 수정하고싶습니다.
(손절후 가격이 기준선"slowMA"을 넘어서면 다시 하락해도 재진입제한)
매수의 경우도 역시, 손절후 가격이 기준선인"slowMA"보다 하락하지 않고
다시 상승하는 경우만 재진입하도록 수정하려고 합니다.
수정부탁드립니다. 미리 감사드립니다.
----------------------------------------------------------------------------------
Input: SlowLen(35), ChLen(300), TrailBar(30), Rebar(300);
Vars: SlowMA(0),LEntryPrice(0), SEntryPrice(0), LCount(-999), SCount(-999),MP(0), Recnt(0),
L_re_EntryPrice(0), S_re_EntryPrice(0);
SlowMA = ma(C , SlowLen );
If CrossUp(Close , SlowMA) and index > 1 then {
LEntryPrice = Highest(H , TrailBar )[1];
LCount = index;
}
If MarketPosition <> 1 AND index < LCount + ChLen then
Buy("Buy1", atstop,LEntryPrice,1);
If CrossDown(Close , SlowMA) and index > 1 then {
SEntryPrice = Lowest(L , TrailBar )[1];
SCount = index;
}
If MarketPosition <> -1 AND index < SCount + ChLen then
Sell ("Sell1", atstop,SEntryPrice,1);
If MarketPosition == 1 then {
LCount = -999;
ExitLong("LongTStop_1", atstop, Lowest(L , TrailBar ),"Buy1",1,1);
exitlong("bloss1",AtStop,EntryPrice-20,"buy1",1,1);
}
If MarketPosition == -1 then {
SCount = -999;
ExitShort("ShortTStop_1", atstop, Highest(H , TrailBar),"Sell1",1,1);
ExitShort("sLoss1",AtStop,EntryPrice+20,"sell1",1,1);
}
//RE_BUY_SELL//
MP = MarketPosition;
If MP == 0 AND MP[1] == -1 then
ReCnt = 1;
If MP == 0 AND MP[1] == 1 then
ReCnt = 1;
if MarketPosition == 1 Then
L_re_EntryPrice = Highest(c,BarsSinceEntry);
If MarketPosition == 0 AND MarketPosition(1) == 1
and IsExitName("bloss1",1) == True AND ReCnt < Rebar then {
ReCnt = ReCnt + 1;
Buy ("Buy_re", AtStop, L_re_EntryPrice+5);
}
if MarketPosition == -1 Then
S_re_EntryPrice = lowest(L,BarsSinceEntry);
If MarketPosition == 0 AND MarketPosition(1) == -1
and IsExitName("sLoss1",1) == True AND ReCnt < Rebar then {
ReCnt = ReCnt + 1;
Sell ("Sell_re", AtStop, S_re_EntryPrice-5);
}
If MarketPosition == 1 and IsEntryName("Buy_re",0) == True then {
ExitLong("LongTStop_re", AtStop, Lowest(L , TrailBar));
}
if MarketPosition == -1 and IsEntryName("Sell_re",0) == True then {
ExitShort ("ShortTStop_re", Atstop, Highest(H , TrailBar));
}