답변완료
문의드립니다.
아래의 트레이딩뷰수식을 변환부탁드립니다. 가능하다면 볼린저밴드의 기간값과 슈퍼트렌드1, 2, 3의 조건값 그리고 밴드선의 굵기 슈퍼트렌드3개의 선굵기는 변수로 따로 빼서 변경가능하게 부탁드립니다. 도와주시는 것에 항상 감사드립니다. 수고하세요 !!!//@version=5 indicator("BB + Triple Supertrend Regime Signals", overlay=true)// // ① Bollinger Bands // bb_len = 2 bb_mult = 2.0 src_bb = openbasis = ta.sma(src_bb, bb_len) dev = ta.stdev(src_bb, bb_len) upperBB = basis + bb_mult * dev lowerBB = basis - bb_mult * devplot(upperBB, "BB Upper", color=color.red) plot(basis, "BB Basis", color=color.orange) plot(lowerBB, "BB Lower", color=color.blue)sellBB = high >= upperBB buyBB = low <= lowerBB// // ② Supertrend 계산 함수 // f_supertrend(_period, _mult) => _atr = ta.atr(_period) _hl2 = hl2 _up = _hl2 - _mult * _atr _dn = _hl2 + _mult * _atr var float _finalUp = na var float _finalDn = na _finalUp := close[1] > nz(_finalUp[1]) ? math.max(_up, nz(_finalUp[1])) : _up _finalDn := close[1] < nz(_finalDn[1]) ? math.min(_dn, nz(_finalDn[1])) : _dn var int _trend = 1 _trend := close > nz(_finalDn[1]) ? 1 : close < nz(_finalUp[1]) ? -1 : _trend [_finalUp, _finalDn, _trend]// // ③ Supertrend 1, 2, 3 실행 // [up1, dn1, tr1] = f_supertrend(4, 0.2) [up2, dn2, tr2] = f_supertrend(6, 1.0) [up3, dn3, tr3] = f_supertrend(7, 1.4)st1 = tr1 == 1 ? up1 : dn1 st2 = tr2 == 1 ? up2 : dn2 st3 = tr3 == 1 ? up3 : dn3plot(st1, "ST1", color=tr1 == 1 ? color.green : color.red) plot(st2, "ST2", color=tr2 == 1 ? color.green : color.red) plot(st3, "ST3", color=tr3 == 1 ? color.green : color.red)// // ④ Supertrend 기반의 추세 레짐 // allAbove = close > st1 and close > st2 and close > st3 allBelow = close < st1 and close < st2 and close < st3var int regime = 0 var int prevRegime = 0 // (추가) 이전 레짐 저장prevRegime := regime // 레짐 변경 감지를 위해 저장if allAbove regime := 1 else if allBelow regime := -1 // 유지 시 regime 변경 없음// // 🔥 레짐 시작 시 표시 (bull / bear) // bullStart = regime == 1 and prevRegime != 1 bearStart = regime == -1 and prevRegime != -1plotshape(bullStart, title="Bull Regime Start", text="bull", style=shape.labelup, color=color.green, textcolor=color.white, location=location.belowbar, size=size.tiny)plotshape(bearStart, title="Bear Regime Start", text="bear", style=shape.labeldown, color=color.red, textcolor=color.white, location=location.abovebar, size=size.tiny)// // ⑤ 최종 매수/매도 신호 // buySignal = (regime == 1) and buyBB sellSignal = (regime == -1) and sellBB// // ⑥ 화살표 표시 // plotshape(buySignal, title="BUY", style=shape.arrowup, color=color.green, location=location.belowbar, size=size.small, text="BUY") plotshape(sellSignal, title="SELL", style=shape.arrowdown, color=color.red, location=location.abovebar, size=size.small, text="SELL")// // ⑦ 알림 // alertcondition(buySignal, "BUY", "Regime Up + BB Lower Touch") alertcondition(sellSignal, "SELL", "Regime Down + BB Upper Touch")
답변완료
첫진입 이후 두번째 진입
아래 수식은data1 kospi200선물지수 5분봉 사용하여 데이트레이딩 으로 하루 1번 거래하는 수식입니다.요청사항 1. 하루에 Max 2번 거래하는 수식으로 수정하고 싶습니다. a. SetStopLoss 청산했을 경우 : 당일 고점+1.25 돌파하면 진입( 진입명 "손절b") // 세번째 진입 없음 b. SetStopTrailing 청산했을 경우 : 당일 고점+1.50 돌파하면 진입( 진입명 "트레b") // 세번째 진입 없음 c. SetStopProfittarget 청산했을 경우 : 당일 고점+1.75 돌파하면 진입( 진입명 "익절b") // 세번째 진입 없음 d. SetStopInactivity 청산했을 경우 : 당일 고점+2.00 돌파하면 진입( 진입명 "최소b") // 세번째 진입 없음 e. SetStopEndofday 청산했을 경우 : 당일 고점+2.25 돌파하면 진입( 진입명 "종료b") // 세번째 진입 없음 2. 청산수식 추가 요청드립니다. 진입명 "b" 일 경우 input : 손절(1.25), 트레스탑(2.50),익절(7.50),최소가격(0.50),봉수(10),종료(143000); 진입명 "손절b" 일 경우 input : 손절1(1.50), 트레스탑1(2.75),익절1(7.75),최소가격1(1.00),봉수1(15),종료1(143500); 진입명 "트레b" 일 경우 input : 손절2(1.75), 트레스탑2(3.00),익절2(8.00),최소가격2(1.50),봉수2(20),종료2(144000); 진입명 "익절b" 일 경우 input : 손절3(2.00), 트레스탑3(3.25),익절3(8.25),최소가격3(2.00),봉수3(25),종료3(144500); 진입명 "최소b" 일 경우 input : 손절4(2.25), 트레스탑4(3.50),익절4(8.50),최소가격4(2.50),봉수4(30),종료4(145000); 진입명 "종료b" 일 경우 input : 손절5(2.50), 트레스탑5(3.75),익절5(8.75),최소가격5(3.00),봉수5(35),종료5(145500); 항상 고맙습니다.**************************************************************************************************************************input : 거래(1);input : fly(1);input : 손절(1.25),트레스탑(2.50),익절(7.50),최소가격(0.50),봉수(10),종료(143000);var : T1(0),entry(0); if Bdate != Bdate[1] Then T1 = TotalTrades; if MarketPosition == 0 Then entry = TotalTrades-T1; Else entry = (TotalTrades-T1)+1;if c>OpenD(0)+fly and entry < 거래 Then Buy("b");SetStopLoss(손절,PointStop);SetStopTrailing(트레스탑,0,PointStop);SetStopProfittarget(익절,PointStop);SetStopInactivity(최소가격,봉수,PointStop);SetStopEndofday(종료);