Type/to search
1
Follow
0
Followers
저는 PINE 코드를 배우고 있습니다. 손절매 설정의 문제점은 무엇입니까? 손절매는 백테스팅에서는 실행되지 않지만 실제 거래에서는 실행됩니다. 그러나 이후 주문은 조건에 따라 배치되지 않으며 포지션은 연속적으로 오픈 및 클로즈됩니다. 전문가 여러분, 문제가 무엇인지 물어볼 수 있나요?
Help
Created 2024-10-22 05:50:32  Updated 2024-10-22 05:51:23
 0
 765

//@version=5
strategy("RSI(6) Buy at 30, EMA(34) Sell with Stop Loss", overlay=true)

// 변수 설정
rsiPeriod = 6
emaPeriod = 54
buyLevel = 30
positionSize = 0.02

RSI와 EMA를 계산합니다.
rsiValue = ta.rsi(close, rsiPeriod)
emaValue = ta.ema(close, emaPeriod)

구매 조건: RSI 30 이하
buySignal = ta.crossunder(rsiValue, buyLevel)

판매 조건: EMA 54보다 높습니다.
sellSignal = close > emaValue

// 상장 개시 가격 기록
var float entryPrice = na

구매 논리: 더 많이 해봐

if (buySignal and strategy.position_size == 0)
strategy.entry("Buy", strategy.long, qty=positionSize)
entryPrice:= close // 구매 시의 오픈 가격을 기록합니다.

// Stop Loss 로직: 0.5%로 설정
if (strategy.position_size > 0)
stopLossPrice = entryPrice * 0.995 // 0.5% 스톱로스
if (close <= stopLossPrice)
strategy.close (("Buy", comment="Stop Loss") // 평준화 지점을 막기

EMA 54보다 높을 때 평준화
if (strategy.position_size > 0 and sellSignal)
strategy.close("Buy", comment="Take Profit") // 조건부 평점점

Related Recommendations
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)