커뮤니티

볼린저 밴드 수식 점검 문의드립니다.

프로필 이미지
승부사1
2021-04-14 23:09:01
801
글번호 148034
답변완료
아래의 수식을 적용해 보았습니다. 말씀하신대로 시간제한 수식은 정상작동을 합니다. 그러나 당일누적손실 제한 수식은 정해진 틱수보다 항상 많이 나오는 것으로 보아서 적용이 안되고 있는거 같습니다. 한번만 더 봐주실수 있을런지요?? 부탁드립니다. - 아 래 - Inputs: Length(9), StdDev(2), Bars(2); Variables: BBTop(0),BBBot(0); Input : 당일누적수익틱수(500),당일누적손실틱수(50); input : starttime(100000),endtime(200000); VARS: Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),stok(0),stod(0); if (sdate != sdate[1] and stime >= endtime) or (sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then { Tcond = false; if MarketPosition == 1 Then ExitLong("매수청산"); if MarketPosition == -1 Then ExitShort("매도청산"); } if (sdate != sdate[1] and stime >= starttime) or (sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then { Xcond = false; N1 = NetProfit; Tcond = true; } 당일누적수익 = PriceScale*당일누적수익틱수; 당일누적손실 = PriceScale*당일누적손실틱수; daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] then { if daypl >= 당일누적수익 or daypl <= -당일누적손실 Then Xcond = true; if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then Xcond = true; } if MarketPosition == 1 then{ ExitLong("매수수익",atlimit,EntryPrice+((당일누적수익-daypl)/CurrentContracts)); ExitLong("매수손실",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts)); } if MarketPosition == -1 then{ ExitShort("매도수익",atlimit,EntryPrice-((당일누적수익-daypl)/CurrentContracts)); ExitShort("매도손실",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts)); } BBTop = BollBandup(Length, StdDev); BBBot = BollBanddown(Length, StdDev); If Tcond == true and Xcond == False and CountIF(Close < BBBot, Bars) == Bars Then Buy("매수", AtStop, BBBot); If Tcond == true and Xcond == False and CountIF(Close > BBTop, Bars) == Bars Then Sell("매도", AtStop, BBTop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-04-15 10:10:33

안녕하세요 예스스탁입니다. 청산명 지정이 잘못되어 있었습니다. 수정한 식입니다. Inputs: Length(9), StdDev(2), Bars(2); Variables: BBTop(0),BBBot(0); Input : 당일누적수익틱수(500),당일누적손실틱수(50); input : starttime(100000),endtime(200000); VARS: Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),stok(0),stod(0); if (sdate != sdate[1] and stime >= endtime) or (sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then { Tcond = false; if MarketPosition == 1 Then ExitLong("매수청산"); if MarketPosition == -1 Then ExitShort("매도청산"); } if (sdate != sdate[1] and stime >= starttime) or (sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then { Xcond = false; N1 = NetProfit; Tcond = true; } 당일누적수익 = PriceScale*당일누적수익틱수; 당일누적손실 = PriceScale*당일누적손실틱수; daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] then { if daypl >= 당일누적수익 or daypl <= -당일누적손실 Then Xcond = true; if (IsExitName("매수수익",1) == true or IsExitName("매수손실",1) == true or IsExitName("매도수익",1) == true or IsExitName("매도손실",1) == true) then Xcond = true; } if MarketPosition == 1 then { ExitLong("매수수익",atlimit,EntryPrice+((당일누적수익-daypl)/CurrentContracts)); ExitLong("매수손실",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts)); } if MarketPosition == -1 then { ExitShort("매도수익",atlimit,EntryPrice-((당일누적수익-daypl)/CurrentContracts)); ExitShort("매도손실",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts)); } BBTop = BollBandup(Length, StdDev); BBBot = BollBanddown(Length, StdDev); If Tcond == true and Xcond == False and CountIF(Close < BBBot, Bars) == Bars Then Buy("매수", AtStop, BBBot); If Tcond == true and Xcond == False and CountIF(Close > BBTop, Bars) == Bars Then Sell("매도", AtStop, BBTop); 즐거운 하루되세요 > 승부사1 님이 쓴 글입니다. > 제목 : 볼린저 밴드 수식 점검 문의드립니다. > 아래의 수식을 적용해 보았습니다. 말씀하신대로 시간제한 수식은 정상작동을 합니다. 그러나 당일누적손실 제한 수식은 정해진 틱수보다 항상 많이 나오는 것으로 보아서 적용이 안되고 있는거 같습니다. 한번만 더 봐주실수 있을런지요?? 부탁드립니다. - 아 래 - Inputs: Length(9), StdDev(2), Bars(2); Variables: BBTop(0),BBBot(0); Input : 당일누적수익틱수(500),당일누적손실틱수(50); input : starttime(100000),endtime(200000); VARS: Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),stok(0),stod(0); if (sdate != sdate[1] and stime >= endtime) or (sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then { Tcond = false; if MarketPosition == 1 Then ExitLong("매수청산"); if MarketPosition == -1 Then ExitShort("매도청산"); } if (sdate != sdate[1] and stime >= starttime) or (sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then { Xcond = false; N1 = NetProfit; Tcond = true; } 당일누적수익 = PriceScale*당일누적수익틱수; 당일누적손실 = PriceScale*당일누적손실틱수; daypl = NetProfit-N1; if TotalTrades > TotalTrades[1] then { if daypl >= 당일누적수익 or daypl <= -당일누적손실 Then Xcond = true; if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then Xcond = true; } if MarketPosition == 1 then{ ExitLong("매수수익",atlimit,EntryPrice+((당일누적수익-daypl)/CurrentContracts)); ExitLong("매수손실",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts)); } if MarketPosition == -1 then{ ExitShort("매도수익",atlimit,EntryPrice-((당일누적수익-daypl)/CurrentContracts)); ExitShort("매도손실",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts)); } BBTop = BollBandup(Length, StdDev); BBBot = BollBanddown(Length, StdDev); If Tcond == true and Xcond == False and CountIF(Close < BBBot, Bars) == Bars Then Buy("매수", AtStop, BBBot); If Tcond == true and Xcond == False and CountIF(Close > BBTop, Bars) == Bars Then Sell("매도", AtStop, BBTop);