커뮤니티

수식문의드립니다

프로필 이미지
jshwang2
2022-09-06 02:31:50
1290
글번호 162013
답변완료
안녕하세요~ 시스템을 작성하였는데 피라미딩을 할 때 진입 이후 2번째 봉에서 신호 발생시 피라미딩 진입이 이뤄지지 않고 세번째 봉부터는 정상적으로 진입되는데 원인을 못찾겠어 문의드립니다 감사합니다 ---------------------------------------------------------- input : TT1(81000), TD1(20220905), TT2(92500), TD2(20220905), MDD(100000); var : BS1(False), SS1(False), BS2(False), SS2(False), unitP(0); var : HB(0), LB(0), rHB(0), rLB(0), exitC(0), N(0), e60(0); N = ATr(14); unitP = floor(MDD/(2*N*BigPointValue*1400)); exitC = (2-(MaxEntries-1)/2)*N; e60 = Ema(C,40); if sDate >= TD1 && sTime > TT1 Then condition11 = true; if sDate >= TD2 && sTime > TT2 Then condition11 = False; //if condition11 == true Then if (macd(5,20) > 0 && macd(5,40) > 0 && macd(20,40) > 0) && (CrossUp(macd(5,20),0) or CrossUp(macd(5,40),0) or CrossUp(macd(20,40),0)) Then BS1 = true; Else BS1 = False; if (macd(5,20) < 0 && macd(5,40) < 0 && macd(20,40) < 0) && (CrossDown(macd(5,20),0) or CrossDown(macd(5,40),0) or CrossDown(macd(20,40),0)) Then SS1 = true; else SS1 = False; if (BS1 == True or BS2 == TRUE) && marketposition == 0 Then Buy("b1", OnClose, Def, unitP); if MarketPosition[1] == 0 && MarketPosition == -1 Then HB = EntryPrice; if (SS1 == True or SS2 == TRUE) && marketposition == 0 Then Sell("s1", OnClose, Def, unitP); if MarketPosition[1] == 0 && MarketPosition == -1 Then LB = EntryPrice; if marketposition ==1 Then { rHB = Highest(H, BarsSinceEntry+1) ; if rHB < HB+0.5*N Then Buy("b2.",AtStop,HB+0.5*N,unitP); if rHB < HB+N Then Buy("b3.",AtStop,HB+N,unitP); if rHB < HB+1.5*N Then Buy("b4.",AtStop,HB+1.5*N,unitP); if e60 < HB+2*N Then Exitlong("exitB1", atstop, HB-exitC); if e60 >= HB+2*N and CrossDown(close, e60) Then { ExitLong("exitB2") ; } } if marketposition == -1 Then { rLB = Lowest(L, BarsSinceEntry+1); if rLB > LB-0.5*N Then Sell("s2.",AtStop,LB-0.5*N,unitP); if rLB > LB-N Then Sell("s3.",AtStop,LB-N,unitP); if rLB > LB-1.5*N Then Sell("s4.",AtStop,LB-1.5*N,unitP); if e60 > LB-2*N Then ExitShort("exitS1", atstop, LB+exitC); if e60 <= LB-2*N and CrossUp(close, e60) Then { ExitShort("exitS2"); } } if (macd(5,20) > 0 && macd(5,40) > 0 && macd(20,40) > 0) && PositionProfit[1] < 0 Then BS2 = true; Else BS2 = False; if (macd(5,20) < 0 && macd(5,40) < 0 && macd(20,40) < 0) && PositionProfit[1] < 0 Then SS2 = true; Else SS2 = False; MessageLog("Mp %.4f, HB %.4f, ep %.4f", MarketPosition, HB, EntryPrice);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-09-06 11:21:46

안녕하세요 예스스탁입니다. if문은 봉완성시(다음봉시가수신) 기준입니다. atstop은 봉완성시 값을 셋팅하고 다음봉의 현재가와 비교해서 신호가 발생합니다. 포지션 첫 진입이 봉완성시에 발생하는 onclose이므로 다음봉 완성부터 marketposition이 1이나 -1로 if조건이 체크되므로 진입신호봉 기준 다음다음봉부터 진입신호가 발생하게 됩니다. 해당 부분은 해결하려면 첫진입조건이 만족해서 첫진입발생시 동시에 다음봉을 감시하는 내용을 넣으셔야 합니다. input : TT1(81000), TD1(20220905), TT2(92500), TD2(20220905), MDD(100000); var : BS1(False), SS1(False), BS2(False), SS2(False), unitP(0); var : HB(0), LB(0), rHB(0), rLB(0), exitC(0), N(0), e60(0); N = ATr(14); unitP = floor(MDD/(2*N*BigPointValue*1400)); exitC = (2-(MaxEntries-1)/2)*N; e60 = Ema(C,40); if sDate >= TD1 && sTime > TT1 Then condition11 = true; if sDate >= TD2 && sTime > TT2 Then condition11 = False; //if condition11 == true Then if (macd(5,20) > 0 && macd(5,40) > 0 && macd(20,40) > 0) && (CrossUp(macd(5,20),0) or CrossUp(macd(5,40),0) or CrossUp(macd(20,40),0)) Then BS1 = true; Else BS1 = False; if (macd(5,20) < 0 && macd(5,40) < 0 && macd(20,40) < 0) && (CrossDown(macd(5,20),0) or CrossDown(macd(5,40),0) or CrossDown(macd(20,40),0)) Then SS1 = true; else SS1 = False; if (BS1 == True or BS2 == TRUE) && marketposition == 0 Then { Buy("b1", OnClose, Def, unitP); HB = EntryPrice; Buy("b2.",AtStop,HB+0.5*N,unitP); Buy("b3.",AtStop,HB+N,unitP); Buy("b4.",AtStop,HB+1.5*N,unitP); } if (SS1 == True or SS2 == TRUE) && marketposition == 0 Then { Sell("s1", OnClose, Def, unitP); LB = EntryPrice; Sell("s2.",AtStop,LB-0.5*N,unitP); Sell("s3.",AtStop,LB-N,unitP); Sell("s4.",AtStop,LB-1.5*N,unitP); } if marketposition ==1 Then { rHB = Highest(H, BarsSinceEntry+1) ; if rHB < HB+0.5*N Then Buy("b2",AtStop,HB+0.5*N,unitP); if rHB < HB+N Then Buy("b3",AtStop,HB+N,unitP); if rHB < HB+1.5*N Then Buy("b4",AtStop,HB+1.5*N,unitP); if e60 < HB+2*N Then Exitlong("exitB1", atstop, HB-exitC); if e60 >= HB+2*N and CrossDown(close, e60) Then { ExitLong("exitB2") ; } } if marketposition == -1 Then { rLB = Lowest(L, BarsSinceEntry+1); if rLB > LB-0.5*N Then Sell("s2",AtStop,LB-0.5*N,unitP); if rLB > LB-N Then Sell("s3",AtStop,LB-N,unitP); if rLB > LB-1.5*N Then Sell("s4",AtStop,LB-1.5*N,unitP); if e60 > LB-2*N Then ExitShort("exitS1", atstop, LB+exitC); if e60 <= LB-2*N and CrossUp(close, e60) Then { ExitShort("exitS2"); } } if (macd(5,20) > 0 && macd(5,40) > 0 && macd(20,40) > 0) && PositionProfit[1] < 0 Then BS2 = true; Else BS2 = False; if (macd(5,20) < 0 && macd(5,40) < 0 && macd(20,40) < 0) && PositionProfit[1] < 0 Then SS2 = true; Else SS2 = False; MessageLog("Mp %.4f, HB %.4f, ep %.4f", MarketPosition, HB, EntryPrice); 즐거운 하루되세요 > jshwang2 님이 쓴 글입니다. > 제목 : 수식문의드립니다 > 안녕하세요~ 시스템을 작성하였는데 피라미딩을 할 때 진입 이후 2번째 봉에서 신호 발생시 피라미딩 진입이 이뤄지지 않고 세번째 봉부터는 정상적으로 진입되는데 원인을 못찾겠어 문의드립니다 감사합니다 ---------------------------------------------------------- input : TT1(81000), TD1(20220905), TT2(92500), TD2(20220905), MDD(100000); var : BS1(False), SS1(False), BS2(False), SS2(False), unitP(0); var : HB(0), LB(0), rHB(0), rLB(0), exitC(0), N(0), e60(0); N = ATr(14); unitP = floor(MDD/(2*N*BigPointValue*1400)); exitC = (2-(MaxEntries-1)/2)*N; e60 = Ema(C,40); if sDate >= TD1 && sTime > TT1 Then condition11 = true; if sDate >= TD2 && sTime > TT2 Then condition11 = False; //if condition11 == true Then if (macd(5,20) > 0 && macd(5,40) > 0 && macd(20,40) > 0) && (CrossUp(macd(5,20),0) or CrossUp(macd(5,40),0) or CrossUp(macd(20,40),0)) Then BS1 = true; Else BS1 = False; if (macd(5,20) < 0 && macd(5,40) < 0 && macd(20,40) < 0) && (CrossDown(macd(5,20),0) or CrossDown(macd(5,40),0) or CrossDown(macd(20,40),0)) Then SS1 = true; else SS1 = False; if (BS1 == True or BS2 == TRUE) && marketposition == 0 Then Buy("b1", OnClose, Def, unitP); if MarketPosition[1] == 0 && MarketPosition == -1 Then HB = EntryPrice; if (SS1 == True or SS2 == TRUE) && marketposition == 0 Then Sell("s1", OnClose, Def, unitP); if MarketPosition[1] == 0 && MarketPosition == -1 Then LB = EntryPrice; if marketposition ==1 Then { rHB = Highest(H, BarsSinceEntry+1) ; if rHB < HB+0.5*N Then Buy("b2.",AtStop,HB+0.5*N,unitP); if rHB < HB+N Then Buy("b3.",AtStop,HB+N,unitP); if rHB < HB+1.5*N Then Buy("b4.",AtStop,HB+1.5*N,unitP); if e60 < HB+2*N Then Exitlong("exitB1", atstop, HB-exitC); if e60 >= HB+2*N and CrossDown(close, e60) Then { ExitLong("exitB2") ; } } if marketposition == -1 Then { rLB = Lowest(L, BarsSinceEntry+1); if rLB > LB-0.5*N Then Sell("s2.",AtStop,LB-0.5*N,unitP); if rLB > LB-N Then Sell("s3.",AtStop,LB-N,unitP); if rLB > LB-1.5*N Then Sell("s4.",AtStop,LB-1.5*N,unitP); if e60 > LB-2*N Then ExitShort("exitS1", atstop, LB+exitC); if e60 <= LB-2*N and CrossUp(close, e60) Then { ExitShort("exitS2"); } } if (macd(5,20) > 0 && macd(5,40) > 0 && macd(20,40) > 0) && PositionProfit[1] < 0 Then BS2 = true; Else BS2 = False; if (macd(5,20) < 0 && macd(5,40) < 0 && macd(20,40) < 0) && PositionProfit[1] < 0 Then SS2 = true; Else SS2 = False; MessageLog("Mp %.4f, HB %.4f, ep %.4f", MarketPosition, HB, EntryPrice);