
이 전략은 RSI 지표와 가격 평균선을 결합하여 주식 가격이 평균선 아래로 떨어질 때 과매매 기회를 찾아 더 많은 포지션을 만듭니다. 주식 가격이 더 떨어질 때, 전략은 평균 포지션 비용의 목적을 달성하기 위해 미리 설정된 비율로 단계적으로 포지션을 추가합니다. 포지션 수익이配置의 스톱 퍼센트를 달성하면 전략은 평평한 포지션을 선택합니다. 동시에, 전략은 점진적 스톱 메커니즘을 도입합니다.
RSI 지표가 초매도선 29보다 낮고, 종식 가격이 평균선보다 낮으면 초개점 1호점을 다.
주가가 첫 번째 단독 하락에 비해 2%에 달할 때 더 많은 포즈를 취하고; 하락이 3%에 달할 때 세 번째 포즈를 취하고, 따라서 최대 8 번까지 포즈를 취한다. 이것은 분량 포즈를 구축하는 효과를 달성한다.
매번 포지션을 열 때, 그 당시의 포지션 개시 가격을 기록한다. 이 가격 지점은 입시 기준 가격이다. 그리고 이 가격 라인을 차트에 그리는 것이다.
포지션 개설 후, 포지션의 평균 가격을 계산한다. 평균 가격의 3%를 각 포지션의 정지 가격으로, 4%를 전체 포지션의 정지 가격으로한다.
가격 상승이 특정 포지션의 스톱 가격보다 높을 때, 해당 포지션을 청산하는 것을 선택합니다.
점진적 정지 계산 방법: 매번 한 포지션을 평정할 때, 전체 정지 가격에서 그 포지션이 달성한 이익을 적립한다. 이렇게 하면 정지 라인이 천천히 아래로 이동할 수 있고, 모든 포지션의 이익이 최대 손실을 보상하기에 충분할 때만 완전히 정지된다.
가격이 점진적 정지선을 촉발했을 때, 전체 평점을 선택하십시오.
RSI 지표는 오버셀 지역을 더 정확하게 판단하여 역전 기회를 잡는 데 도움이 됩니다.
여러 차례에 걸쳐 매장하면, 낮은 지점에서 평균 매장비용을 올릴 수 있다.
점진적 정지는 손실 위험을 줄이고 점진적 탈퇴를 실현할 수 있다. 손실이 발생하더라도 일정 범위 내에서 통제할 수 있다.
설정 가능한 정지 비율과 부채 비율, 시장에 따라 전략적 위험을 조정할 수 있다.
포지션 개시 기준선과 종료 기준선을 그림으로 그려 놓은 그래프에서 포지션 분포를 직관적으로 판단할 수 있다.
불안정한 상황에서는 여러 번 포지션 개시와 정지 시동을 유발할 수 있으며 거래는 종종 슬라이드 포인트 손실을 초래한다. RSI 파라미터를 적절히 느슨하게 하여 거래 횟수를 줄일 수 있다.
저축 횟수와 비율을 잘못 설정하면 과도한 거래로 이어질 수 있으며, 자금 상황에 따라 신중하게 배치해야 한다.
만약 시장이 계속 하락한다면, 바닥이 없는 위험에 직면할 수 있다. 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위 상위
막기 비율이 너무 작다면, 너무 일찍 막기를 초래할 수 있다. 역사 재검토 데이터에 따라 적절한 막기 비율이 설정되어야 한다.
MACD와 같은 지표가 RSI 신호를 필터링하여 무효 거래를 줄일 수 있습니다.
ATR 설정으로 손실을 중지하여 극한 상황으로 인한 엄청난 손실을 피할 수 있습니다.
매장 수, 비율, 정지 비율 등의 매개 변수를 최적화하여 다양한 품종에 더 적합한 전략을 수립할 수 있다.
변동율에 따라 정지 비율을 지능적으로 조정할 수 있으며, 변동이 큰 경우 적절히 느려질 수 있다.
이 전략은 RSI 지표를 최대한 활용하여 과매매 지역을 판단하고 가격 평행선과 함께 역전 거래한다. 동시에 지능형 부가 및 점진적 정지 메커니즘을 사용하여 위험을 통제하는 전제 하에서 효율적인 다중 전략을 달성한다. 지표 매개 변수, 정지 메커니즘 등을 최적화함으로써 전략을 더 안정적이고 효율적으로 만들 수 있다. 이 전략은 주식 지수, 디지털 통화 등이 역전 특성을 가진 금융 품종에 널리 적용되며 실제 투자 가치가 있다.
/*backtest
start: 2023-09-23 00:00:00
end: 2023-10-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
// © A3Sh
// RSI Strategy that buys the dips, uses Price Averaging and Pyramiding.
// When the price drops below specified percentages of the price (8 PA layers), new entries are openend to average the price of the assets.
// Open entries are closed by a specified take profit.
// Entries can be reopened, after closing and consequently crossing a PA layer again.
// This strategy is based on the RSI+PA+DCA strategy I created earlier. The difference is the way the Take Profit is calculated.
// Instead of directly connecting the take profit limit to the decreasing average price level with an X percent above the average price,
// the take profit is calculated for a part on the decreasing average price and for another part on the deduction
// of the profits of the individual closed positions.
// The Take Profit Limit drop less significant then the average price level and the full position only completely exits
// when enough individual closed positions made up for the losses.
// This makes it less risky and more conservative and great for a long term trading strategy
// RSI code is adapted from the build in Relative Strength Index indicator
// MA Filter and RSI concept adapted from the Optimized RSI Buy the Dips strategy, by Coinrule
// https://www.tradingview.com/script/Pm1WAtyI-Optimized-RSI-Strategy-Buy-The-Dips-by-Coinrule/
// Pyramiding entries code adapted from Pyramiding Entries on Early Trends startegy, by Coinrule
// Pyramiding entries code adapted from Pyramiding Entries on Early Trends startegy, by Coinrule
// https://www.tradingview.com/script/7NNJ0sXB-Pyramiding-Entries-On-Early-Trends-by-Coinrule/
// Plot entry layers code adapted from HOWTO Plot Entry Price by vitvlkv
// https://www.tradingview.com/script/bHTnipgY-HOWTO-Plot-Entry-Price/
strategy(title='RSI+PA+PTP', pyramiding=16, overlay=true, initial_capital=400, default_qty_type=strategy.percent_of_equity, default_qty_value=15, commission_type=strategy.commission.percent, commission_value=0.075, close_entries_rule='FIFO')
port = input.float(12, group = "Risk", title='Portfolio % Used To Open The 8 Positions', step=0.1, minval=0.1, maxval=100)
q = strategy.equity / 100 * port / open
// Long position PA entry layers. Percentage from the entry price of the the first long
ps2 = input.float(2, group = "Long Position Entry Layers", title='2nd Long Entry %', step=0.1)
ps3 = input.float(3, group = "Long Position Entry Layers", title='3rd Long Entry %', step=0.1)
ps4 = input.float(5, group = "Long Position Entry Layers", title='4th Long Entry %', step=0.1)
ps5 = input.float(10, group = "Long Position Entry Layers", title='5th Long Entry %', step=0.1)
ps6 = input.float(16, group = "Long Position Entry Layers", title='6th Long Entry %', step=0.1)
ps7 = input.float(25, group = "Long Position Entry Layers" ,title='7th Long Entry %', step=0.1)
ps8 = input.float(40, group = "Long Position Entry Layers", title='8th Long Entry %', step=0.1)
// Calculate Moving Averages
plotMA = input.bool(group = "Moving Average Filter", title='Plot Moving Average', defval=false)
movingaverage_signal = ta.sma(close, input(100, group = "Moving Average Filter", title='MA Length'))
plot (plotMA ? movingaverage_signal : na, color = color.new (color.green, 0))
// RSI inputs and calculations
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
overSold = input.int(29, title="Oversold, Trigger to Enter First Position", group = "RSI Settings")
// Long trigger (co)
co = ta.crossover(rsi, overSold) and close < movingaverage_signal
// Store values to create and plot the different PA layers
long1 = ta.valuewhen(co, close, 0)
long2 = ta.valuewhen(co, close - close / 100 * ps2, 0)
long3 = ta.valuewhen(co, close - close / 100 * ps3, 0)
long4 = ta.valuewhen(co, close - close / 100 * ps4, 0)
long5 = ta.valuewhen(co, close - close / 100 * ps5, 0)
long6 = ta.valuewhen(co, close - close / 100 * ps6, 0)
long7 = ta.valuewhen(co, close - close / 100 * ps7, 0)
long8 = ta.valuewhen(co, close - close / 100 * ps8, 0)
eps1 = 0.00
eps1 := na(eps1[1]) ? na : eps1[1]
eps2 = 0.00
eps2 := na(eps2[1]) ? na : eps2[1]
eps3 = 0.00
eps3 := na(eps3[1]) ? na : eps3[1]
eps4 = 0.00
eps4 := na(eps4[1]) ? na : eps4[1]
eps5 = 0.00
eps5 := na(eps5[1]) ? na : eps5[1]
eps6 = 0.00
eps6 := na(eps6[1]) ? na : eps6[1]
eps7 = 0.00
eps7 := na(eps7[1]) ? na : eps7[1]
eps8 = 0.00
eps8 := na(eps8[1]) ? na : eps8[1]
plot(strategy.position_size > 0 ? eps1 : na, title='Long entry 1', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps2 : na, title='Long entry 2', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps3 : na, title='Long entry 3', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps4 : na, title='Long entry 4', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps5 : na, title='Long entry 5', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps6 : na, title='Long entry 6', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps7 : na, title='Long entry 7', style=plot.style_linebr)
plot(strategy.position_size > 0 ? eps8 : na, title='Long entry 8', style=plot.style_linebr)
// Take Profit Settings
ProfitTarget_Percent = input.float(3.0, group = "Take Profit Settings", title='Take Profit % (Per Position)')
ProfitTarget_Percent_All = input.float(4.0, group = "Take Profit Settings", title='Take Profit % (Exit All, Progressive Take Profit Limit')
TakeProfitProgression = input.float(12, group = "Take Profit Settings", title='Take Profit Progression', tooltip = 'Progression is defined by the position size. By default 12% of the start equity (portfolio) is used to open a position, see Risk. This same % percentage is used to calculate the profit amount that will be deducted from the Take Profit Limit.')
entryOn = input.bool (true, group = "Take Profit Settings", title='New entries affect Take Profit limit', tooltip = 'This option changes the behaviour of the Progressive Take Profit. When switchted on, the difference between the former and current original Take Profit is deducted from the Progressive Take Profit. When switchted off, the Progressive Take Profit is only affected by the profit deduction or each closed position.')
avPricePlot = input.bool (false, group = "Take Profit Settings", title='Plot Average Price (FIFO)')
// Original Take Profit Limit
tpLimit = strategy.position_avg_price + (strategy.position_avg_price / 100 * ProfitTarget_Percent_All)
// Create variables to calculate the Take Profit Limit Progresssion
var endVal = 0.0
var startVal = 0.0
// The value at the the start of the loop is the value of the end of the previous loop
startVal := endVal
// Set variable to the original Take Profit Limit when the first position opens.
if strategy.position_size > 0 and strategy.position_size[1] ==0
endVal := tpLimit
// Everytime a specific position opens, the difference of the previous (original) Take Profit price and the current (original) Take Profit price will be deducted from the Progressive Take Profit Limit
// This feature can be toggled on and off in the settings panel. By default it is toggled on.
entryAmount = 0.0
for i = 1 to strategy.opentrades
entryAmount := i
if entryOn and strategy.position_size > 0 and strategy.opentrades[1] == (entryAmount) and strategy.opentrades == (entryAmount + 1)
endVal := startVal - (tpLimit[1] - tpLimit)
// Everytime a specific position closes, the amount of profit from that specific position will be deducted from the Progressive Take Profit Limit.
exitAmount = 0.0
for id = 1 to strategy.opentrades
exitAmount := id
if strategy.opentrades[1] ==(exitAmount + 1) and strategy.opentrades == (exitAmount)
endVal := startVal - (TakeProfitProgression / 100 * strategy.opentrades.entry_price (id - 1) / 100 * ProfitTarget_Percent )
// The Final Take Profit Price
tpn = (strategy.position_avg_price + (strategy.position_avg_price / 100 * ProfitTarget_Percent_All)) - (strategy.position_avg_price + (strategy.position_avg_price / 100 * ProfitTarget_Percent_All) - endVal)
plot (strategy.position_size > 0 ? tpn : na, title = "Take Profit Limit", color=color.new(color.red, 0), style = plot.style_linebr, linewidth = 1)
// Plot position average price as reference
plot (avPricePlot ? strategy.position_avg_price : na, title= "Average price", color = color.new(color.white, 0), style = plot.style_linebr, linewidth = 1)
// When to trigger the Take Profit per position or the Progressive Take Profit
tpl1 = close < tpn ? eps1 + close * (ProfitTarget_Percent / 100) : tpn
tpl2 = close < tpn ? eps2 + close * (ProfitTarget_Percent / 100) : tpn
tpl3 = close < tpn ? eps3 + close * (ProfitTarget_Percent / 100) : tpn
tpl4 = close < tpn ? eps4 + close * (ProfitTarget_Percent / 100) : tpn
tpl5 = close < tpn ? eps5 + close * (ProfitTarget_Percent / 100) : tpn
tpl6 = close < tpn ? eps6 + close * (ProfitTarget_Percent / 100) : tpn
tpl7 = close < tpn ? eps7 + close * (ProfitTarget_Percent / 100) : tpn
tpl8 = close < tpn ? eps8 + close * (ProfitTarget_Percent / 100) : tpn
// Submit Entry Orders
if co and strategy.opentrades == 0
eps1 := long1
eps2 := long2
eps3 := long3
eps4 := long4
eps5 := long5
eps6 := long6
eps7 := long7
eps8 := long8
strategy.entry('Long1', strategy.long, q)
if strategy.opentrades == 1
strategy.entry('Long2', strategy.long, q, limit=eps2)
if strategy.opentrades == 2
strategy.entry('Long3', strategy.long, q, limit=eps3)
if strategy.opentrades == 3
strategy.entry('Long4', strategy.long, q, limit=eps4)
if strategy.opentrades == 4
strategy.entry('Long5', strategy.long, q, limit=eps5)
if strategy.opentrades == 5
strategy.entry('Long6', strategy.long, q, limit=eps6)
if strategy.opentrades == 6
strategy.entry('Long7', strategy.long, q, limit=eps7)
if strategy.opentrades == 7
strategy.entry('Long8', strategy.long, q, limit=eps8)
// Submit Exit orders
if strategy.position_size > 0
strategy.exit(id='Exit 1', from_entry='Long1', limit=tpl1)
strategy.exit(id='Exit 2', from_entry='Long2', limit=tpl2)
strategy.exit(id='Exit 3', from_entry='Long3', limit=tpl3)
strategy.exit(id='Exit 4', from_entry='Long4', limit=tpl4)
strategy.exit(id='Exit 5', from_entry='Long5', limit=tpl5)
strategy.exit(id='Exit 6', from_entry='Long6', limit=tpl6)
strategy.exit(id='Exit 7', from_entry='Long7', limit=tpl7)
strategy.exit(id='Exit 8', from_entry='Long8', limit=tpl8)
// Make sure that all open limit orders are canceled after exiting all the positions
longClose = strategy.position_size[1] > 0 and strategy.position_size == 0 ? 1 : 0
if longClose
strategy.cancel_all()