커뮤니티

mov avg crossover 설명 부탁드립니다

프로필 이미지
cinamon
2014-02-27 08:16:36
188
글번호 72967
답변완료
Input: FastLen(10), SlowLen(500), ChLen(30), TrailBar(160), ReBars(2), stopPer(1.0); Vars: FastMA(0), SlowMA(0),LEntryPrice(0), SEntryPrice(0), LCount(-999), SCount(-999), ReCnt(0), MP(0); FastMA = ma(C , FastLen ); SlowMA = ma(C , SlowLen ); If CrossUp(FastMA , SlowMA) and index > 1 then { LEntryPrice = Highest(H , TrailBar )[1]; LCount = index; } If MarketPosition <> 1 AND index < LCount + ChLen then Buy ("Cross Over Buy", atstop,LEntryPrice); If CrossDown(FastMA , SlowMA) and index > 1 then { SEntryPrice = Lowest(L , TrailBar )[1]; SCount = index; } If MarketPosition <> -1 AND index < SCount + ChLen then Sell ("Cross Under Sell", atstop,SEntryPrice ); If MarketPosition == 1 then { LCount = -999; ExitLong ("LongTStop", atstop, Lowest(L , TrailBar )); } If MarketPosition == -1 then { SCount = -999; ExitShort ("ShortTStop", atstop, Highest(H , TrailBar )); } // 재진입 /*MP = MarketPosition; If MP == 0 AND MP[1] == -1 then ReCnt = 1; If MP == 0 AND MP[1] == 1 then ReCnt = 1; If MarketPosition == 0 AND MarketPosition(1) == 1 AND ReCnt < ReBars then { ReCnt = ReCnt + 1; Buy ("Long ReEntry", atstop,Highest(H , TrailBar ) ) ; } If MarketPosition == 0 AND MarketPosition(1) == -1 AND ReCnt < ReBars then { ReCnt = ReCnt + 1; Sell ("Short ReEntry", atstop,Lowest(L , TrailBar ) ) ; }*/ SetStopLoss(stopPer, PercentStop); SetStopEndofday(150000); 진입식 까지는 이해 할수 있는데요 청산식 에서 LCount = -999 SCount = -999 무슨의미 인지 모르겠습니다 그리고 내부변수 선언시 숫자나(0) 논리형(false) 이어야 하는데 LCount(-999), SCount(-999)는 무었인가요? 그리고 //재진입 밑으로 설명좀 부탁드려도 될까요? 부탁드립니다
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2014-02-27 17:27:47

안녕하세용 예스스탁입니다. 1 수식에서 LCount,SCount는 이평이 크로스한 봉의 인덱스(봉번호)가 저장이 됩니댜. 이평 크로스가 발생하고 몇개봉 이내에 지정한 가격을 터치할때 진입하므로 진입이 발생하면 LCount,SCount를 -999라는 값을 주어서 더이상 매수진입 식의 index < LCount + ChLen 매도진입 식의 index < SCount + ChLen 조건을 만족하지 않게 하여 청산 후에 같은 방향의 진입이 나오지 않게 하는 용도입니다. 2. 아래는 재진입 설명입니다. 청산 후에 동일방향으로 다시 진입하는 식인데 재진입이 청산후에 2개봉(ReBars) 까지만 진입을 허용하는 식입니다. // 재진입 MP = MarketPosition;//포지션 상태 #포지션이 매도포지션이었다가 무포지션이 되면 ReCnt에 1저장 If MP == 0 AND MP[1] == -1 then ReCnt = 1; #포지션이 매수포지션이었다가 무포지션이 되면 ReCnt에 1저장 If MP == 0 AND MP[1] == 1 then ReCnt = 1; #위 내용은 청산이 발생하고 값을 1로 초기화하는 내용입니다. #그리고 아래식에서 청산후의 봉수를 카운트 해서 지정한 봉수(ReBars) 이내일때만 #재진입이 이루어 지게 합니다. #현재 무포지션이고 직전거래는 매수이고 청산후 경과된 봉수가 2개봉(ReBars) 이내일때 If MarketPosition == 0 AND MarketPosition(1) == 1 AND ReCnt < ReBars then { ReCnt = ReCnt + 1;#청산 후 봉수 카운트 Buy ("Long ReEntry", atstop,Highest(H , TrailBar ) ) ; #최근 160개봉 최고가를 터치하면 매수 } #현재 무포지션이고 직전거래는 매도이고 청산후 경과된 봉수가 2개봉(ReBars) 이내일때 If MarketPosition == 0 AND MarketPosition(1) == -1 AND ReCnt < ReBars then { ReCnt = ReCnt + 1;#청산 후 봉수 카운트 Sell ("Short ReEntry", atstop,Lowest(L , TrailBar ) ) ; #최근 160개봉 최저가를 터치하면 매도 } 즐거운 하루되세요 > cinamon 님이 쓴 글입니다. > 제목 : mov avg crossover 설명 부탁드립니다 > Input: FastLen(10), SlowLen(500), ChLen(30), TrailBar(160), ReBars(2), stopPer(1.0); Vars: FastMA(0), SlowMA(0),LEntryPrice(0), SEntryPrice(0), LCount(-999), SCount(-999), ReCnt(0), MP(0); FastMA = ma(C , FastLen ); SlowMA = ma(C , SlowLen ); If CrossUp(FastMA , SlowMA) and index > 1 then { LEntryPrice = Highest(H , TrailBar )[1]; LCount = index; } If MarketPosition <> 1 AND index < LCount + ChLen then Buy ("Cross Over Buy", atstop,LEntryPrice); If CrossDown(FastMA , SlowMA) and index > 1 then { SEntryPrice = Lowest(L , TrailBar )[1]; SCount = index; } If MarketPosition <> -1 AND index < SCount + ChLen then Sell ("Cross Under Sell", atstop,SEntryPrice ); If MarketPosition == 1 then { LCount = -999; ExitLong ("LongTStop", atstop, Lowest(L , TrailBar )); } If MarketPosition == -1 then { SCount = -999; ExitShort ("ShortTStop", atstop, Highest(H , TrailBar )); } // 재진입 /*MP = MarketPosition; If MP == 0 AND MP[1] == -1 then ReCnt = 1; If MP == 0 AND MP[1] == 1 then ReCnt = 1; If MarketPosition == 0 AND MarketPosition(1) == 1 AND ReCnt < ReBars then { ReCnt = ReCnt + 1; Buy ("Long ReEntry", atstop,Highest(H , TrailBar ) ) ; } If MarketPosition == 0 AND MarketPosition(1) == -1 AND ReCnt < ReBars then { ReCnt = ReCnt + 1; Sell ("Short ReEntry", atstop,Lowest(L , TrailBar ) ) ; }*/ SetStopLoss(stopPer, PercentStop); SetStopEndofday(150000); 진입식 까지는 이해 할수 있는데요 청산식 에서 LCount = -999 SCount = -999 무슨의미 인지 모르겠습니다 그리고 내부변수 선언시 숫자나(0) 논리형(false) 이어야 하는데 LCount(-999), SCount(-999)는 무었인가요? 그리고 //재진입 밑으로 설명좀 부탁드려도 될까요? 부탁드립니다