커뮤니티

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

프로필 이미지
승부사1
2021-04-13 23:32:19
790
글번호 148002
답변완료
아래의 수식으로 항생지수 시뮬레이션 챠트에 적용해 보았습니다. 그런데 당일누적손실틱수 제한 수식과 starttime과 endtime의 시간이 먹히지 않고 적상작동하지 않는거 같습니다. 점검 부탁드리겠습니다. - 아 래 - 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] and (daypl >= 당일누적수익 or daypl <= -당일누적손실) then Xcond = false; 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 CountIF(Close < BBBot, Bars) == Bars Then Buy("매수", AtStop, BBBot); If CountIF(Close > BBTop, Bars) == Bars Then Sell("매도", AtStop, BBTop);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-04-14 15:00:09

안녕하세요 예스스탁입니다. 진입수식 if문에 지정한 시간안에만 진입을 제한하는 내용과 당일누적손실이나 당일누적수익을 달성한 이후에 진입을 막는 내용이 없습니다. 각 제한 조건에 따라 변수에 값만 저장된 상태입니다. 해당 변수를 이용해 진입식에 조건식을 지정해 주셔야 합니다. 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 님이 쓴 글입니다. > 제목 : 볼린저 밴드 수식 문의드립니다. > 아래의 수식으로 항생지수 시뮬레이션 챠트에 적용해 보았습니다. 그런데 당일누적손실틱수 제한 수식과 starttime과 endtime의 시간이 먹히지 않고 적상작동하지 않는거 같습니다. 점검 부탁드리겠습니다. - 아 래 - 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] and (daypl >= 당일누적수익 or daypl <= -당일누적손실) then Xcond = false; 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 CountIF(Close < BBBot, Bars) == Bars Then Buy("매수", AtStop, BBBot); If CountIF(Close > BBTop, Bars) == Bars Then Sell("매도", AtStop, BBTop);