[英]PineScript - Strategy.exit not responding
我對strategy.exit 有一些問題。 這是行不通的。 如下圖所示,兩個退出參數都應該有效!
RSI 腳本:
// RSI parameters
var RSI = "RSI"
overBought = input(title="OverBought RSI",group=RSI, defval=75)
overSold = input(title="OverSold RSI",group=RSI, defval=20)
rsi50 = input(50,title="RSI average",group=RSI)
rsi14exit = input(title="RSI 14 OverSold Exit Strategy", group=RSI, defval=70)
// RSI Short/Long
rsiLong = rsi(close,6) <= overSold
rsiShort = rsi(close,6) >= overBought
rsiBelowAverage = rsi(close,6) <= rsi50
rsi14_exit = rsi(close,14) >= rsi14exit
// Calculating
MACD Script:
fast_ma = sma_source == "SMA" ? sma(src, fast_length) : ema(src, fast_length)
slow_ma = sma_source == "SMA" ? sma(src, slow_length) : ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal
// MACD Long/Short
Macd_long = macd >= signal
Macd_short = macd < signal
// Strategy close
strategy.exit("LongA Closed","LongA", loss=longStop, when= Macd_short or rsi14_exit)
您實際上想要關閉交易,因此請改用strategy.close()
。
strategy.close(id="LongA", when= Macd_short or rsi14_exit)
您可以將止損參數添加到您的strategy.entry
調用中。 它有一個stop
參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.