커뮤니티
[STAD_02] Opening Gap
2014-03-16 21:41:07
173
글번호 73522
input : P1(20), p2(40);
input : HLperiod(20), ARmult(4), Div(40);
Var: StopPrice(0), BullTrend(false), BearTrend(true);
Var: SellOnSwingHigh(false), BuyOnSwingLow(false), MP(0);
var : sumV1(0), sumV2(0), ShortDayAvg(0), LongDayAvg(0), count(0);
##분봉에서 일봉이평을 구함
sumV1 = 0;
sumV2 = 0;
for count = 0 to p2-1 {
if count < p1 then
sumV1 = sumV1 + DayClose(count);
if count < p2 then
sumV2 = sumV2 + DayClose(count);
}
ShortDayAvg = sumV1 / P1; //분봉에서 일봉20일 이평
LongDayAvg = sumV2 / P2; //분봉에서 일봉40일 이평
##
BullTrend = ShortDayAvg >= LongDayAvg;
BearTrend = ShortDayAvg < LongDayAvg;
If Date <> Date[1] then {
SellOnSwingHigh = False;
BuyOnSwingLow = False;
If BullTrend then {
If Close < dayLow(1) and C > dayOpen then {
A열 Buy();
BuyOnSwingLow = True;
}
If Close > dayHIgh(1) then
SellOnSwingHigh = True;
}
If BearTrend then {
If Close > dayHIgh(1) and C < dayOPen then {
B열 Sell();
SellOnSwingHigh = True;
}
If Close < dayLow(1) then
BuyOnSwingLow = True;
}
}
---------------------------------------
If date == date[1] Then {
----------------------------------------
질문1 없어도 되는거 아닌가요? 왜들어갔는지 궁금합니다
If SellOnSwingHigh then
Sell("Sell",atstop, lowest(L,HLPeriod));;
If BuyOnSwingLow then
Buy("Buy",atstop,highest(H,HLPeriod));
-------------------------------------------------
If MarketPosition == -1 then
SellOnSwingHigh = false;
If MarketPosition == 1 then
BuyOnSwingLow = false;
----------------------------------------
질문2 위 내용은 A열buy()와 B열sell() 이후에 중복진입을 막기위해서 인가요?
}
MP = MarketPosition;
if MP == 1 and MP[1] <> 1 then
StopPrice = low - ma(range,40)*ARmult;
if MP == -1 and MP[1] <> -1 then
StopPrice = High + ma(range,40)*ARmult;
If MP == 1 then {
exitlong ("ExitLong", atstop, stopprice );
stopprice = stopprice + (low-stopprice)/Div;
}
If MP == -1 then {
exitshort ("ExitShort",atstop, stopprice );
stopprice = stopprice - (stopprice-high)/Div;
}
setstoploss(2.0);
SetStopEndofday(1500);
부탁드립니다
답변 1
예스스탁 예스스탁 답변
2014-03-17 14:31:59
안녕하세요
예스스탁입니다.
1.
첫봉에서 조건이 걸리지 않게 하기 위함입니다.
dayindex > 0이라는 조건을 달리표현한 것입니다.
첫봉에서는 다른 진입조건이 있으므로
최소 두번째 봉부터 if조건이 만족할때 신호를 발생하기 위함입니다.
2.
A열매수나 B열매도가 발생하면
그날은 더이상 동일방향으로 진입을 허용하지 않게 하기 위함입니다.
즉 매수나 매도진입이 각각 당일 한번만 진입하게 하기 위함입니다.
즐거운 하루되세요
> cinamon 님이 쓴 글입니다.
> 제목 : [STAD_02] Opening Gap
>
input : P1(20), p2(40);
input : HLperiod(20), ARmult(4), Div(40);
Var: StopPrice(0), BullTrend(false), BearTrend(true);
Var: SellOnSwingHigh(false), BuyOnSwingLow(false), MP(0);
var : sumV1(0), sumV2(0), ShortDayAvg(0), LongDayAvg(0), count(0);
##분봉에서 일봉이평을 구함
sumV1 = 0;
sumV2 = 0;
for count = 0 to p2-1 {
if count < p1 then
sumV1 = sumV1 + DayClose(count);
if count < p2 then
sumV2 = sumV2 + DayClose(count);
}
ShortDayAvg = sumV1 / P1; //분봉에서 일봉20일 이평
LongDayAvg = sumV2 / P2; //분봉에서 일봉40일 이평
##
BullTrend = ShortDayAvg >= LongDayAvg;
BearTrend = ShortDayAvg < LongDayAvg;
If Date <> Date[1] then {
SellOnSwingHigh = False;
BuyOnSwingLow = False;
If BullTrend then {
If Close < dayLow(1) and C > dayOpen then {
A열 Buy();
BuyOnSwingLow = True;
}
If Close > dayHIgh(1) then
SellOnSwingHigh = True;
}
If BearTrend then {
If Close > dayHIgh(1) and C < dayOPen then {
B열 Sell();
SellOnSwingHigh = True;
}
If Close < dayLow(1) then
BuyOnSwingLow = True;
}
}
---------------------------------------
If date == date[1] Then {
----------------------------------------
질문1 없어도 되는거 아닌가요? 왜들어갔는지 궁금합니다
If SellOnSwingHigh then
Sell("Sell",atstop, lowest(L,HLPeriod));;
If BuyOnSwingLow then
Buy("Buy",atstop,highest(H,HLPeriod));
-------------------------------------------------
If MarketPosition == -1 then
SellOnSwingHigh = false;
If MarketPosition == 1 then
BuyOnSwingLow = false;
----------------------------------------
질문2 위 내용은 A열buy()와 B열sell() 이후에 중복진입을 막기위해서 인가요?
}
MP = MarketPosition;
if MP == 1 and MP[1] <> 1 then
StopPrice = low - ma(range,40)*ARmult;
if MP == -1 and MP[1] <> -1 then
StopPrice = High + ma(range,40)*ARmult;
If MP == 1 then {
exitlong ("ExitLong", atstop, stopprice );
stopprice = stopprice + (low-stopprice)/Div;
}
If MP == -1 then {
exitshort ("ExitShort",atstop, stopprice );
stopprice = stopprice - (stopprice-high)/Div;
}
setstoploss(2.0);
SetStopEndofday(1500);
부탁드립니다