adxlen = input(7, title="ADX Smoothing") dilen = input(7, title="DI Length") dirmov(len) => up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) truerange = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(plusDM, len) / truerange) minus = fixnan(100 * ta.rma(minusDM, len) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) sig = adx(dilen, adxlen) plot(sig, color=color.red, title="ADX") // 多头进场条件:超级趋势向下变化,RSI(21)小于70,RSI(3)大于80 if ta.change(direction) < 0 and ta.rsi(close, 21) < 70 and ta.rsi(close,3) > 80 and sig > 20 strategy.entry("My Long Entry Id", strategy.long)
// 平仓多头条件:超级趋势向上变化,RSI(21)大于30,RSI(3)小于20 if ta.change(direction) > 0 and ta.rsi(close, 21) > 30 and ta.rsi(close,3) < 20 strategy.close("My Long Entry Id")
// 空头进场条件:超级趋势向上变化,RSI(21)大于70,RSI(3)小于20 if ta.change(direction) > 0 and ta.rsi(close, 21) > 70 and ta.rsi(close,3) < 20 and sig < 80 strategy.entry("My Short Entry Id", strategy.short)
// 平仓空头条件:超级趋势向下变化,RSI(21)小于30,RSI(3)大于80 if ta.change(direction) < 0 and ta.rsi(close, 21) < 30 and ta.rsi(close,3) > 80 strategy.close("My Short Entry Id")
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.