
이 전략은 시간 프레임에 걸쳐 이동 평균의 조합을 사용하여, 큰 중간 시간 차트에서 트렌드 회전을 식별하고, 낮은 위험 트렌드 추적 거래를 구현한다. 이 전략은 구성이 유연하고, 간단한, 자본 효율성이 높은 장점을 구현하며, 중장선 포지션 추격 트렌드를 보유하는 거래자에게 적합하다.
전략은 5일, 20일, 40일 세 개의 이동 평균을 사용하여 다양한 시간 프레임에 따른 트렌드의 배열 조합을 판단한다. 중대 시간 차트 트렌드 일관성 원칙에 따라 다공간 주기를 결정한다.
구체적으로, 5일 고속선에서 20일 중선을 통과하면 짧은 선의 오 신호로, 20일 중선에서 40일 느린 선을 통과하면 중선의 오 신호로 간주한다. 급속도로 느린 3선이 정렬되었을 때 ((5일>20일>40일), 다중주기로 판단된다. 급속도로 느린 3선이 역렬되었을 때 ((5일<20일<40일), 공허주기로 판단된다.
이렇게, 대주기 트렌드 판단 방향에 따라, 그리고 소주기 강도 검출 구체적인 입구를 결합한다. 즉, 큰 트렌드 동방향과 소주기가 강한 경우에만 포지션을 개설할 수 있으며, 반전假突破를 효과적으로 필터링하여 높은 승률을 달성한다.
또한, 이 전략은 ATR의 손해배상 제어를 통해 단편적 위험을 통제하고, 수익률을 더욱 높여줍니다.
유연한 구성, 사용자가 다양한 품종과 거래 선호도에 맞게 이동 평균 변수를 조정할 수 있습니다.
이 프로젝트의 핵심은 ‘이미트’입니다.
자금의 효율적인 사용, 자금의 최대한의 활용
위험은 통제할 수 있고, 손실을 막는 메커니즘은 큰 손실을 방지할 수 있습니다.
트렌드 추적 능력, 대주기가 방향을 결정한 후 지속적인 수익
승률이 높고, 거래 신호 품질이 좋고, 교차로 오작동이 적다.
대주기 판단은 이동 평균선 배열에 의존하며, 지연된 잘못된 판단의 위험이 있다.
소주기 강도 검사는 단 하나의 K선으로, 예전에 발사될 수 있으며, 적절히 휴식을 취할 수 있다.
정지폭이 고정되어 있고, 동적 정지폭으로 최적화될 수 있다.
거래량 에너지와 같은 추가 필터링 조건을 추가하는 것을 고려할 수 있습니다.
다른 이동 평균 변수 조합을 시도할 수 있고, 최적화 전략
이 전략은 다중 시간 프레임 분석과 손해 관리를 통합하여 낮은 위험의 트렌드 추적 거래를 실현합니다. 파라미터를 조정하여 트렌드 추종자의 요구를 충족시키기 위해 다양한 품종에 적용 할 수 있습니다. 전통적인 단일 시간 프레임 시스템과 비교하여 거래 결정이 더 안정적이며 신호가 더 효율적입니다.
This strategy uses a combination of moving averages across timeframes to identify trend rotations on the hourly, daily and weekly charts. It allows low-risk trend following trading. The strategy is flexible, simple to implement, capital efficient and suitable for medium-long term trend traders.
The strategy employs 5, 20 and 40-day moving averages to determine the alignment of trends across different timeframes. Based on the consistency between larger and smaller timeframes, it identifies bullish and bearish cycles.
Specifically, the crossing of 5-day fast MA above 20-day medium MA indicates an uptrend in the short term. The crossing of 20-day medium MA above 40-day slow MA signals an uptrend in the medium term. When the fast, medium and slow MAs are positively aligned (5-day > 20-day > 40-day), it is a bull cycle. When they are negatively aligned (5-day < 20-day < 40-day), it is a bear cycle.
By determining direction from the larger cycles and confirming strength on the smaller cycles, this strategy opens positions only when major trend and minor momentum align. This effectively avoids false breakouts and achieves high win rate.
The strategy also utilizes ATR trailing stops to control single trade risks and further improve profitability.
Flexible configurations to suit different instruments and trading styles
Simple to implement even for beginner traders
High capital efficiency to maximize leverage
Effective risk control to avoid significant losses
Strong trend following ability for sustained profits
High win rate due to robust signals and fewer whipsaws
MA crossovers may lag and cause late trend detection
Single candle strength detection could trigger premature entry, relax condition
Fixed ATR stop loss, optimize to dynamic stops
Consider adding supplementary filters like volume
Explore different MA parameters for optimization
This strategy integrates multiple timeframe analysis and risk management for low-risk trend following trading. By adjusting parameters, it can be adapted to different instruments to suit trend traders. Compared to single timeframe systems, it makes more robust trading decisions and generates higher efficiency signals. In conclusion, this strategy has good market adaptiveness and development potential.
/*backtest
start: 2023-10-17 00:00:00
end: 2023-11-16 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/
// © kgynofomo
//@version=5
strategy(title="[Salavi] | Andy Advance Pro Strategy [BTC|M15]",overlay = true, pyramiding = 1,initial_capital = 10000, default_qty_type = strategy.cash,default_qty_value = 10000)
ema_short = ta.ema(close,5)
ema_middle = ta.ema(close,20)
ema_long = ta.ema(close,40)
cycle_1 = ema_short>ema_middle and ema_middle>ema_long
cycle_2 = ema_middle>ema_short and ema_short>ema_long
cycle_3 = ema_middle>ema_long and ema_long>ema_short
cycle_4 = ema_long>ema_middle and ema_middle>ema_short
cycle_5 = ema_long>ema_short and ema_short>ema_middle
cycle_6 = ema_short>ema_long and ema_long>ema_middle
bull_cycle = cycle_1 or cycle_2 or cycle_3
bear_cycle = cycle_4 or cycle_5 or cycle_6
// label.new("cycle_1")
// bgcolor(color=cycle_1?color.rgb(82, 255, 148, 60):na)
// bgcolor(color=cycle_2?color.rgb(82, 255, 148, 70):na)
// bgcolor(color=cycle_3?color.rgb(82, 255, 148, 80):na)
// bgcolor(color=cycle_4?color.rgb(255, 82, 82, 80):na)
// bgcolor(color=cycle_5?color.rgb(255, 82, 82, 70):na)
// bgcolor(color=cycle_6?color.rgb(255, 82, 82, 60):na)
// Inputs
a = input(2, title='Key Vaule. \'This changes the sensitivity\'')
c = input(7, title='ATR Period')
h = false
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
atr = ta.atr(14)
atr_length = input.int(25)
atr_rsi = ta.rsi(atr,atr_length)
atr_valid = atr_rsi>50
long_condition = buy and bull_cycle and atr_valid
short_condition = sell and bear_cycle and atr_valid
Exit_long_condition = short_condition
Exit_short_condition = long_condition
if long_condition
strategy.entry("Andy Buy",strategy.long, limit=close,comment="Andy Buy Here")
if Exit_long_condition
strategy.close("Andy Buy",comment="Andy Buy Out")
// strategy.entry("Andy fandan Short",strategy.short, limit=close,comment="Andy 翻單 short Here")
// strategy.close("Andy fandan Buy",comment="Andy short Out")
if short_condition
strategy.entry("Andy Short",strategy.short, limit=close,comment="Andy short Here")
// strategy.exit("STR","Long",stop=longstoploss)
if Exit_short_condition
strategy.close("Andy Short",comment="Andy short Out")
// strategy.entry("Andy fandan Buy",strategy.long, limit=close,comment="Andy 翻單 Buy Here")
// strategy.close("Andy fandan Short",comment="Andy Buy Out")
inLongTrade = strategy.position_size > 0
inLongTradecolor = #58D68D
notInTrade = strategy.position_size == 0
inShortTrade = strategy.position_size < 0
// bgcolor(color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)
plotshape(close!=0,location = location.bottom,color = inLongTrade?color.rgb(76, 175, 79, 70):inShortTrade?color.rgb(255, 82, 82, 70):na)
plotshape(long_condition, title='Buy', text='Andy Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(short_condition, title='Sell', text='Andy Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
//atr > close *0.01* parameter
// MONTHLY TABLE PERFORMANCE - Developed by @QuantNomad
// *************************************************************************************************************************************************************************************************************************************************************************
show_performance = input.bool(true, 'Show Monthly Performance ?', group='Performance - credits: @QuantNomad')
prec = input(2, 'Return Precision', group='Performance - credits: @QuantNomad')
if show_performance
new_month = month(time) != month(time[1])
new_year = year(time) != year(time[1])
eq = strategy.equity
bar_pnl = eq / eq[1] - 1
cur_month_pnl = 0.0
cur_year_pnl = 0.0
// Current Monthly P&L
cur_month_pnl := new_month ? 0.0 :
(1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1
// Current Yearly P&L
cur_year_pnl := new_year ? 0.0 :
(1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1
// Arrays to store Yearly and Monthly P&Ls
var month_pnl = array.new_float(0)
var month_time = array.new_int(0)
var year_pnl = array.new_float(0)
var year_time = array.new_int(0)
last_computed = false
if (not na(cur_month_pnl[1]) and (new_month or barstate.islastconfirmedhistory))
if (last_computed[1])
array.pop(month_pnl)
array.pop(month_time)
array.push(month_pnl , cur_month_pnl[1])
array.push(month_time, time[1])
if (not na(cur_year_pnl[1]) and (new_year or barstate.islastconfirmedhistory))
if (last_computed[1])
array.pop(year_pnl)
array.pop(year_time)
array.push(year_pnl , cur_year_pnl[1])
array.push(year_time, time[1])
last_computed := barstate.islastconfirmedhistory ? true : nz(last_computed[1])
// Monthly P&L Table
var monthly_table = table(na)
if (barstate.islastconfirmedhistory)
monthly_table := table.new(position.bottom_center, columns = 14, rows = array.size(year_pnl) + 1, border_width = 1)
table.cell(monthly_table, 0, 0, "", bgcolor = #cccccc)
table.cell(monthly_table, 1, 0, "Jan", bgcolor = #cccccc)
table.cell(monthly_table, 2, 0, "Feb", bgcolor = #cccccc)
table.cell(monthly_table, 3, 0, "Mar", bgcolor = #cccccc)
table.cell(monthly_table, 4, 0, "Apr", bgcolor = #cccccc)
table.cell(monthly_table, 5, 0, "May", bgcolor = #cccccc)
table.cell(monthly_table, 6, 0, "Jun", bgcolor = #cccccc)
table.cell(monthly_table, 7, 0, "Jul", bgcolor = #cccccc)
table.cell(monthly_table, 8, 0, "Aug", bgcolor = #cccccc)
table.cell(monthly_table, 9, 0, "Sep", bgcolor = #cccccc)
table.cell(monthly_table, 10, 0, "Oct", bgcolor = #cccccc)
table.cell(monthly_table, 11, 0, "Nov", bgcolor = #cccccc)
table.cell(monthly_table, 12, 0, "Dec", bgcolor = #cccccc)
table.cell(monthly_table, 13, 0, "Year", bgcolor = #999999)
for yi = 0 to array.size(year_pnl) - 1
table.cell(monthly_table, 0, yi + 1, str.tostring(year(array.get(year_time, yi))), bgcolor = #cccccc)
y_color = array.get(year_pnl, yi) > 0 ? color.new(color.teal, transp = 40) : color.new(color.gray, transp = 40)
table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor = y_color, text_color=color.new(color.white, 0))
for mi = 0 to array.size(month_time) - 1
m_row = year(array.get(month_time, mi)) - year(array.get(year_time, 0)) + 1
m_col = month(array.get(month_time, mi))
m_color = array.get(month_pnl, mi) > 0 ? color.new(color.teal, transp = 40) : color.new(color.gray, transp = 40)
table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor = m_color, text_color=color.new(color.white, 0))