
이 전략은 두 개의 변수가 다른 슈퍼트렌드 지표를 사용하여 시장의 추세를 판단하고 추세 방향에 따라 다중 하위 거래를합니다. 전략의 핵심은 다중 단계 이동 중지 메커니즘을 채택하여 여러 스톱 목표를 설정하여 수익을 점진적으로 고정시키면서 더 큰 상황을 파악하기 위해 일부 위치를 유지합니다.이 방법은 위험을 줄이면서 수익 잠재력을 극대화합니다.
이중 수퍼트렌드 지표: 두 개의 지표가 서로 다른 수퍼트렌드 지표를 설정하여 트렌드를 판단하는 전략을 사용한다. 두 개의 지표가 동시에 상승 추세를 나타낼 때, 다중 신호를 유발한다. 두 개의 지표가 동시에 하향 추세를 나타낼 때, 공백 신호를 유발한다. 이 이중 확인 메커니즘은 가짜 신호를 효과적으로 줄일 수 있다.
다단계 이동 중지: 전략은 4개의 조정 가능한 중지 목표를 설정한다. 각 목표에는 해당하는 중지 비율과 평화 위치 비율이 있다. 예를 들어, 첫 번째 중지 목표는 6%의 수익으로 12%의 위치를 평행하게 설정할 수 있으며, 두 번째 목표는 12%의 수익으로 8%의 위치를 평행하게 설정할 수 있다. 이러한 메커니즘은 수익을 단계적으로 잠금화 할 수 있지만 일부 위치가 계속 유리한 상태를 누릴 수 있습니다.
유연한 거래 방향: 전략은 사용자가 다양한 시장 환경과 거래 선호도에 맞게 다중 거래, 다중 거래 또는 양방향 거래를 선택할 수 있습니다.
다이내믹 스톱: 코드에 명확한 스톱 설정이 없지만, 전략은 슈퍼 트렌드 지표가 반전되면 자동으로 평정됩니다. 이것은 실제로 다이내믹 스톱의 역할을합니다.
리스크 관리 최적화: 다단계 이동 중지 메커니즘은 전략의 리스크 수익률을 크게 향상시킵니다. 수익을 단계적으로 잠금화함으로써 전략은 상승 공간을 유지하면서 철회 위험을 줄일 수 있습니다.
가짜 신호를 줄여: 이중 슈퍼 트렌드 지표의 사용은 가짜 신호의 영향을 크게 줄여 거래의 정확성과 신뢰성을 향상시킵니다.
유연성: 전략은 사용자의 선호도와 시장 상황에 따라 거래 방향과 정지 매개 변수를 유연하게 조정할 수 있으며, 다양한 거래 품종과 기간에 적용됩니다.
높은 자동화: 전략이 완전히 자동화되어, 입단, 정지, 출전에서 인적 개입이 필요하지 않아서, 감정적 인 영향과 조작 오류의 가능성을 크게 줄입니다.
자본 관리의 유연성: 다른 정지 비율을 설정하여 전략은 자본 관리의 유연성을 구현 할 수 있으며, 수익의 일부를 신속하게 잠금 할 수 있으며, 남은 지점이 수익을 계속 얻을 수 있습니다.
변수 민감성: 전략의 성능은 슈퍼트렌드 지표와 정지 변수의 설정에 크게 의존한다. 부적절한 변수는 과도한 거래 또는 중요한 기회를 놓치게 할 수 있다.
트렌드 의존성: 트렌드 추적 전략으로서, 불안정한 시장에서 불필요한 거래 비용을 초래하는 빈번한 출입이 발생할 수 있다.
슬라이드 포인트 위험: 빠른 상황에서, 다단계 스톱의 실행은 슬라이드 포인트에 영향을 받을 수 있으며, 실제 실행 가격은 예상과는 오차가 있을 수 있다.
과도한 최적화 위험: 전략에는 여러 개의 조정 가능한 매개 변수가 있으며, 과도한 최적화 함정에 빠지기 쉽고, 리테스트 결과와 실 디스크 성능의 차이가 크다.
변동성 필터를 도입하십시오. ATR 또는 다른 변동성 지표와 결합하여 낮은 변동성 기간 동안 거래 빈도를 줄이고 다양한 시장 환경에서 전략의 적응력을 향상시킵니다.
동적 변수 조정: 수퍼트렌드 변수와 정지 목표를 동적으로 조정하는 적응 알고리즘을 사용하여 시장 변화에 더 잘 적응할 수 있습니다.
손해 차단 메커니즘을 추가: 슈퍼트렌드는 역으로 약간의 손해 차단 기능을 제공하지만, 더 유연한 손해 차단 메커니즘을 추가하는 것을 고려할 수 있습니다.
다른 기술 지표와 결합: RSI, MACD와 같은 다른 기술 지표를 도입하는 것이 고려 될 수 있습니다.
자금 관리 최적화: 더 복잡한 자금 관리 전략을 탐색 할 수 있습니다. 예를 들어, 계좌 수익성에 따라 포지션 크기를 동적으로 조정하여 위험과 수익을 더 잘 균형을 잡을 수 있습니다.
회귀 최적화: 전략의 최적의 적용 시나리오와 파라미터 설정을 찾기 위해 다양한 시기와 다른 시장 조건의 성과 분석을 포함한 더 포괄적인 회귀를 수행합니다.
이 다단계 이동식 정지 전략은 이중 슈퍼트렌드 지표에 기초하여, 유연한 다단계 정지 메커니즘을 통해 위험과 수익의 균형을 이룬다. 전략의 주요 장점은 우수한 위험 관리 능력과 추세에 대한 민감성이다. 그러나, 사용자는 적용할 때 파라미터 설정과 시장 환경의 영향에 주의를 기울여야 한다.
/*backtest
start: 2024-05-21 00:00:00
end: 2024-06-20 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Strategic Multi-Step Supertrend Trader - Strategy [presentTrading]", overlay=true )
// this strategy utilizes a double Supertrend indicator to determine entry and exit conditions for both long and short trades, with user-configurable take profit levels and trade direction settings.
// The strategy dynamically updates highest and lowest prices during trades and exits positions based on multi-step profit targets or opposing Supertrend signals.
// User inputs for take profit settings
// Grouping Take Profit settings
useTakeProfit = input.bool(true, title="Use Take Profit", group="Take Profit Settings")
takeProfitPercent1 = input.float(6.0, title="Take Profit % Step 1", group="Take Profit Settings")
takeProfitPercent2 = input.float(12.0, title="Take Profit % Step 2", group="Take Profit Settings")
takeProfitPercent3 = input.float(18.0, title="Take Profit % Step 3", group="Take Profit Settings")
takeProfitPercent4 = input.float(50.0, title="Take Profit % Step 4", group="Take Profit Settings")
takeProfitAmount1 = input.float(12, title="Take Profit Amount % Step 1", group="Take Profit Settings")
takeProfitAmount2 = input.float(8, title="Take Profit Amount % Step 2", group="Take Profit Settings")
takeProfitAmount3 = input.float(4, title="Take Profit Amount % Step 3", group="Take Profit Settings")
takeProfitAmount4 = input.float(0, title="Take Profit Amount % Step 4", group="Take Profit Settings")
numberOfSteps = input.int(3, title="Number of Take Profit Steps", minval=1, maxval=4, group="Take Profit Settings")
// Grouping Trade Direction
tradeDirection = input.string("Both", title="Trade Direction", options=["Long", "Short", "Both"], group="Trade Direction")
// Grouping Supertrend settings
atrPeriod1 = input(10, title="ATR Length for Supertrend 1", group="Supertrend Settings")
factor1 = input.float(3.0, title="Factor for Supertrend 1", step=0.01, group="Supertrend Settings")
atrPeriod2 = input(5, title="ATR Length for Supertrend 2", group="Supertrend Settings")
factor2 = input.float(4.0, title="Factor for Supertrend 2", step=0.01, group="Supertrend Settings")
// Function to calculate Supertrend
supertrend(factor, atrPeriod) =>
[a, direction] = ta.supertrend(factor, atrPeriod)
direction
// Calculate Double Supertrend
supertrend1 = supertrend(factor1, atrPeriod1)
supertrend2 = supertrend(factor2, atrPeriod2)
// Entry conditions
longCondition = (supertrend1 < 0 and supertrend2 < 0) and (tradeDirection == "Long" or tradeDirection == "Both")
shortCondition = (supertrend1 > 0 and supertrend2 > 0) and (tradeDirection == "Short" or tradeDirection == "Both")
// Exit conditions
longExitCondition = (supertrend1 > 0 and supertrend2 > 0) and (tradeDirection == "Long" or tradeDirection == "Both")
shortExitCondition = (supertrend1 < 0 and supertrend2 < 0) and (tradeDirection == "Short" or tradeDirection == "Both")
// Variables to store the highest and lowest prices during the trade
var float highestPrice = na
var float lowestPrice = na
// Get the entry price from open trades
entryPrice = strategy.opentrades.entry_price(strategy.opentrades - 1)
// Reset highestPrice or lowestPrice when entering new trades
if (longCondition and strategy.position_size <= 0)
highestPrice := na // Reset the highest price
strategy.entry("My Long Entry Id", strategy.long) // Enter long position
strategy.close("My Short Entry Id", "Short Exit") // Close short position if any
if (shortCondition and strategy.position_size >= 0)
lowestPrice := na // Reset the lowest price
strategy.entry("My Short Entry Id", strategy.short) // Enter short position
strategy.close("My Long Entry Id", "Long Exit") // Close long position if any
// Exit trades based on conditions
if (longExitCondition and strategy.position_size > 0)
strategy.close("My Long Entry Id", "Long Exit") // Exit long position
if (shortExitCondition and strategy.position_size < 0)
strategy.close("My Short Entry Id", "Short Exit") // Exit short position
if (strategy.position_size > 0)
// Update the highest price for long positions
highestPrice := na(highestPrice) ? high : math.max(highestPrice, high)
// Step 1
if (useTakeProfit and numberOfSteps >= 1)
strategy.exit("Take Profit 1", from_entry="My Long Entry Id", qty_percent=takeProfitAmount1, limit=entryPrice * (1 + takeProfitPercent1 / 100))
// Step 2
if (useTakeProfit and numberOfSteps >= 2)
strategy.exit("Take Profit 2", from_entry="My Long Entry Id", qty_percent=takeProfitAmount2, limit=entryPrice * (1 + takeProfitPercent2 / 100))
// Step 3
if (useTakeProfit and numberOfSteps >= 3)
strategy.exit("Take Profit 3", from_entry="My Long Entry Id", qty_percent=takeProfitAmount3, limit=entryPrice * (1 + takeProfitPercent3 / 100))
// Step 4
if (useTakeProfit and numberOfSteps == 4)
strategy.exit("Take Profit 4", from_entry="My Long Entry Id", qty_percent=takeProfitAmount4, limit=entryPrice * (1 + takeProfitPercent4 / 100))
if (strategy.position_size < 0)
// Update the lowest price for short positions
lowestPrice := na(lowestPrice) ? low : math.min(lowestPrice, low)
// Step 1
if (useTakeProfit and numberOfSteps >= 1)
strategy.exit("Take Profit 1", from_entry="My Short Entry Id", qty_percent=takeProfitAmount1, limit=entryPrice * (1 - takeProfitPercent1 / 100))
// Step 2
if (useTakeProfit and numberOfSteps >= 2)
strategy.exit("Take Profit 2", from_entry="My Short Entry Id", qty_percent=takeProfitAmount2, limit=entryPrice * (1 - takeProfitPercent2 / 100))
// Step 3
if (useTakeProfit and numberOfSteps >= 3)
strategy.exit("Take Profit 3", from_entry="My Short Entry Id", qty_percent=takeProfitAmount3, limit=entryPrice * (1 - takeProfitPercent3 / 100))
// Step 4
if (useTakeProfit and numberOfSteps == 4)
strategy.exit("Take Profit 4", from_entry="My Short Entry Id", qty_percent=takeProfitAmount4, limit=entryPrice * (1 - takeProfitPercent4 / 100))