커뮤니티

문의드립니다.

프로필 이미지
해암
2025-06-10 15:20:47
213
글번호 191574
답변완료
아래의 트레이딩뷰 수식을 변환부탁드립니다. ===================== / Input parameters lookback = input.int(5, "Pivot Lookback", minval=1, step=1) // Swing high/low lookback period for Liquidity Swings stopLossBuffer = input.float(0.5, "Stop Loss Buffer %", minval=0.1, step=0.1) // Buffer for initial stop loss // --- Liquidity Swings Indicator (Simulated with Pivot High/Low) --- pivotHigh1h = ta.pivothigh(high, lookback, lookback) pivotLow1h = ta.pivotlow(low, lookback, lookback) // Store latest support/resistance levels var float resistance1h = na var float support1h = na if not na(pivotHigh1h) resistance1h := pivotHigh1h if not na(pivotLow1h) support1h := pivotLow1h // --- Entry Signals (Strictly at 1h Support/Resistance) --- // Long: Price crosses above support (swing low) and is below resistance // Short: Price crosses below resistance (swing high) and is above support buySignal = ta.crossover(low, support1h) and close < resistance1h sellSignal = ta.crossunder(high, resistance1h) and close > support1h // --- Stop Loss and Take Profit --- // Initial stop loss: Below support (for long) or above resistance (for short) with buffer slLong = support1h * (1 - stopLossBuffer / 100) slShort = resistance1h * (1 + stopLossBuffer / 100) // --- Take Profit Logic (1:2 Risk-Reward) --- var float entryPrice = na var float initialStopLoss = na var float takeProfitPrice = na // Track entry and stop loss if buySignal entryPrice := close initialStopLoss := slLong takeProfitPrice := entryPrice + 2 * (entryPrice - initialStopLoss) if sellSignal entryPrice := close initialStopLoss := slShort takeProfitPrice := entryPrice - 2 * (initialStopLoss - entryPrice) // --- Stop Loss on Support/Resistance Breakout --- // Breakout: Price closes below support (for long) or above resistance (for short) stopLong = close < support1h stopShort = close > resistance1h // --- Strategy --- if (buySignal) strategy.entry("Long", strategy.long) strategy.exit("Exit Long", "Long", stop=stopLong ? support1h : slLong, limit=takeProfitPrice) if (sellSignal) strategy.entry("Short", strategy.short) strategy.exit("Exit Short", "Short", stop=stopShort ? resistance1h : slShort, limit=takeProfitPrice) // --- Visualization --- plot(resistance1h, "1h Resistance", color=color.red, linewidth=1, offset=-lookback) plot(support1h, "1h Support", color=color.green, linewidth=1, offset=-lookback) plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small) plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small) =================== 생성되는 라인은 차트에 표시되게 또는 안되게 선택할수 있고, 삼각형신호가 확실하게 표현되었으면 합니다. 위 지표를 지표수식과 시스템수식으로 각각 부탁드립니다. 지표값은 변경가능하게 부탁드립니다. 항상 감사드립니다. 수고하세요!!!
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-06-11 10:27:12

안녕하세요 예스스탁입니다. 1. 시스템 input : lookback(5),stopLossBuffer(0.5); var : pivotHigh1h(0),pivotLow1h(0); var : resistance1h(nan),support1h(Nan); var : buySignal(False),sellSignal(False); var : slLong(0),slShort(0); pivotHigh1h = SwingHigh(1,high, lookback, lookback,lookback*2+1); pivotLow1h = SwingLow(1,low, lookback, lookback,lookback*2+1); if pivotHigh1h > 0 Then resistance1h = pivotHigh1h; if pivotLow1h > 0 Then support1h = pivotLow1h; buySignal = CrossUp(low, support1h) and close < resistance1h; sellSignal = CrossDown(high, resistance1h) and close > support1h; slLong = support1h * (1 - stopLossBuffer / 100); slShort = resistance1h * (1 + stopLossBuffer / 100); // --- Take Profit Logic (1:2 Risk-Reward) --- var : EP(Nan),initialStopLoss(Nan),btakeProfitPrice(Nan),stakeProfitPrice(Nan); var : stopLong(False),stopShort(False); if buySignal Then { EP = close; initialStopLoss = slLong; btakeProfitPrice = EP + 2 * (EP - initialStopLoss); } if sellSignal then { EP = close; initialStopLoss = slShort; stakeProfitPrice = EP - 2 * (initialStopLoss - EP); } stopLong = close < support1h; stopShort = close > resistance1h; if buySignal == true Then { Buy("b"); } if MarketPosition == 1 Then { ExitLong("bx1",AtStop,iff(stoplong, support1h , slLong)); ExitLong("bx2",AtLimit,btakeProfitPrice); } if sellSignal == true Then { Sell("s"); } if MarketPosition == 1 Then { ExitShort("sx1",AtStop,iff(stopShort , resistance1h , slShort)); ExitShort("sx2",AtLimit,stakeProfitPrice); } 2. 지표 input : lookback(5),stopLossBuffer(0.5); var : pivotHigh1h(0),pivotLow1h(0); var : resistance1h(nan),support1h(Nan); var : buySignal(False),sellSignal(False); var : slLong(0),slShort(0); pivotHigh1h = SwingHigh(1,high, lookback, lookback,lookback*2+1); pivotLow1h = SwingLow(1,low, lookback, lookback,lookback*2+1); if pivotHigh1h > 0 Then resistance1h = pivotHigh1h; if pivotLow1h > 0 Then support1h = pivotLow1h; buySignal = CrossUp(low, support1h) and close < resistance1h; sellSignal = CrossDown(high, resistance1h) and close > support1h; slLong = support1h * (1 - stopLossBuffer / 100); slShort = resistance1h * (1 + stopLossBuffer / 100); // --- Take Profit Logic (1:2 Risk-Reward) --- var : EP(Nan),initialStopLoss(Nan),takeProfitPrice(Nan); var : stopLong(False),stopShort(False),tx(0); if buySignal Then { EP = close; initialStopLoss = slLong; takeProfitPrice = EP + 2 * (EP - initialStopLoss); tx = text_new(sDate,sTime,L,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Red); Text_SetSize(tx,20); } if sellSignal then { EP = close; initialStopLoss = slShort; takeProfitPrice = EP - 2 * (initialStopLoss - EP); tx = text_new(sDate,sTime,H,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Blue); Text_SetSize(tx,20); } stopLong = close < support1h; stopShort = close > resistance1h; plot1(resistance1h, "1h Resistance", red); FixPlotShift(1,-lookback); plot2(support1h, "1h Support",green); FixPlotShift(2,-lookback); 즐거운 하루되세요 > 해암 님이 쓴 글입니다. > 제목 : 문의드립니다. > 아래의 트레이딩뷰 수식을 변환부탁드립니다. ===================== / Input parameters lookback = input.int(5, "Pivot Lookback", minval=1, step=1) // Swing high/low lookback period for Liquidity Swings stopLossBuffer = input.float(0.5, "Stop Loss Buffer %", minval=0.1, step=0.1) // Buffer for initial stop loss // --- Liquidity Swings Indicator (Simulated with Pivot High/Low) --- pivotHigh1h = ta.pivothigh(high, lookback, lookback) pivotLow1h = ta.pivotlow(low, lookback, lookback) // Store latest support/resistance levels var float resistance1h = na var float support1h = na if not na(pivotHigh1h) resistance1h := pivotHigh1h if not na(pivotLow1h) support1h := pivotLow1h // --- Entry Signals (Strictly at 1h Support/Resistance) --- // Long: Price crosses above support (swing low) and is below resistance // Short: Price crosses below resistance (swing high) and is above support buySignal = ta.crossover(low, support1h) and close < resistance1h sellSignal = ta.crossunder(high, resistance1h) and close > support1h // --- Stop Loss and Take Profit --- // Initial stop loss: Below support (for long) or above resistance (for short) with buffer slLong = support1h * (1 - stopLossBuffer / 100) slShort = resistance1h * (1 + stopLossBuffer / 100) // --- Take Profit Logic (1:2 Risk-Reward) --- var float entryPrice = na var float initialStopLoss = na var float takeProfitPrice = na // Track entry and stop loss if buySignal entryPrice := close initialStopLoss := slLong takeProfitPrice := entryPrice + 2 * (entryPrice - initialStopLoss) if sellSignal entryPrice := close initialStopLoss := slShort takeProfitPrice := entryPrice - 2 * (initialStopLoss - entryPrice) // --- Stop Loss on Support/Resistance Breakout --- // Breakout: Price closes below support (for long) or above resistance (for short) stopLong = close < support1h stopShort = close > resistance1h // --- Strategy --- if (buySignal) strategy.entry("Long", strategy.long) strategy.exit("Exit Long", "Long", stop=stopLong ? support1h : slLong, limit=takeProfitPrice) if (sellSignal) strategy.entry("Short", strategy.short) strategy.exit("Exit Short", "Short", stop=stopShort ? resistance1h : slShort, limit=takeProfitPrice) // --- Visualization --- plot(resistance1h, "1h Resistance", color=color.red, linewidth=1, offset=-lookback) plot(support1h, "1h Support", color=color.green, linewidth=1, offset=-lookback) plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small) plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small) =================== 생성되는 라인은 차트에 표시되게 또는 안되게 선택할수 있고, 삼각형신호가 확실하게 표현되었으면 합니다. 위 지표를 지표수식과 시스템수식으로 각각 부탁드립니다. 지표값은 변경가능하게 부탁드립니다. 항상 감사드립니다. 수고하세요!!!