
이 전략은 쌍평선 교차 신호에 기반한 자기 적응 변수 거래 시스템이다. 빠른 이동 평균과 느린 이동 평균의 교차로 거래 신호를 생성하고, 조정 가능한 중지, 중지 및 추적 중단과 같은 위험 관리 변수와 결합하여 유연한 거래 전략 관리를 구현한다. 전략의 핵심은 제어 패널의 동력을 통해 각기 다른 변수를 조정하여 전략을 다양한 시장 환경에 적응시킬 수 있도록 하는 것이다.
이 전략은 빠른 이동 평균이 느린 이동 평균을 상향으로 넘어가면 여러 신호를 발생시키고, 빠른 이동 평균이 느린 이동 평균을 상향으로 넘어가면 평점 신호를 발생시킨다. 또한, 이 전략은 세 가지의 위험 제어 메커니즘을 도입한다. 고정 스톱, 고정 스톱 및 추적 스톱. 이러한 매개 변수는 제어판을 통해 실시간으로 조정할 수 있으며, 0.1%에서 더 큰 비율까지 다양하며, 거래자에게 정확한 위험 제어 능력을 제공합니다.
이 전략은 양평선 교차를 결합하여 유연한 위험 관리 매개 변수를 결합하여 적응 가능한 거래 시스템을 구축합니다. 전략의 장점은 매개 변수가 조정 가능하고 위험 제어가 완벽하다는 것입니다. 그러나 동시에 흔들리는 시장과 매개 변수 최적화로 인한 위험에 주의해야합니다. 트렌드 필터, 최적의 손해 방지 방법 등의 수단을 추가하여 전략에는 큰 최적화 공간이 있습니다. 거래자에게는 합리적으로 매개 변수를 설정하고 전략의 성능을 지속적으로 모니터링하는 것이 전략의 안정성을 보장하는 데 중요합니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © traderhub
//@version=5
strategy("Two Moving Averages Strategy with Adjustable Parameters", overlay=true)
// Adjustable parameters for fast and slow moving averages
fastLength = input.int(10, title="Fast Moving Average Length", minval=1, maxval=100)
slowLength = input.int(30, title="Slow Moving Average Length", minval=1, maxval=100)
// Risk management parameters
stopLossPerc = input.float(1, title="Stop Loss (%)", step=0.1) // Stop-loss percentage
takeProfitPerc = input.float(2, title="Take Profit (%)", step=0.1) // Take-profit percentage
trailStopPerc = input.float(1.5, title="Trailing Stop (%)", step=0.1) // Trailing stop percentage
// Calculate fast and slow moving averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// Plot moving averages on the chart
plot(fastMA, color=color.blue, title="Fast Moving Average")
plot(slowMA, color=color.red, title="Slow Moving Average")
// Conditions for opening and closing positions
longCondition = ta.crossover(fastMA, slowMA) // Buy when fast moving average crosses above the slow moving average
shortCondition = ta.crossunder(fastMA, slowMA) // Sell when fast moving average crosses below the slow moving average
// Variables for stop-loss and take-profit levels
var float longStopLevel = na
var float longTakeProfitLevel = na
// Enter a long position
if (longCondition)
longStopLevel := strategy.position_avg_price * (1 - stopLossPerc / 100)
longTakeProfitLevel := strategy.position_avg_price * (1 + takeProfitPerc / 100)
strategy.entry("Long", strategy.long)
// Manage stop-loss, take-profit, and trailing stop for long positions
if (strategy.position_size > 0)
strategy.exit("Take Profit/Stop Loss", "Long", stop=longStopLevel, limit=longTakeProfitLevel, trail_offset=trailStopPerc)
// Close the long position and enter short when the condition is met
if (shortCondition)
strategy.close("Long")
strategy.entry("Short", strategy.short)