이 전략은 전체적으로 사용자 정의 한 1차 균형표 ((Ichimoku Kinko Hyo) 의 모든 매개 변수 및 조건을 통해 매우 유연한 균형표 거래 전략을 구현한다. 이 전략은 균형표의 여러 거래 방법을 복제하여 다양한 시장 환경에 적응할 수 있다.
전략적 원칙:
변환선, 기준선, 전도선 1, 전도선 2, 지연선 등을 계산한다.
사용자 정의 변수에 따라 다중 헤드 및 빈 헤드의 입시 조건 조합.
사용자 정의 변수에 따라 다중 헤드 및 빈 헤드 출전 조건 조합.
시각적으로 표시되는 구성 조건이 충족되는 경우.
입출장 조건에 따라 거래할 때, 스톱로스 스톱을 사용할지 여부를 선택할 수 있다.
이 전략의 장점:
개인 거래 방식에 맞게 완전히 사용자 정의 된 균형 표 파라미터.
조건 포괄 거래, 가짜 신호를 필터링하여 안정성을 높인다.
시각적 판단을 도와 시장 상황을 직관적으로 반영한다.
테스트 최적화 유연성, 다양한 시장 유형에 적응할 수 있다.
이 전략의 위험은:
모든 사용자 정의의 복잡성으로 인해 테스트에 많은 시간이 소요됩니다.
변수는 부득이하게 손실될 수 있으며 신중한 테스트가 필요합니다.
너무 복잡한 조건의 조합으로 인해 기회를 놓칠 수 있습니다.
요약하자면, 이 전략은 균형표 거래 전략의 고도로 사용자 정의를 구현합니다. 사용자는 선호도 및 시장 상황에 따라 파라미터를 조정하여 최적의 효과를 얻을 수 있습니다. 그러나 비 체계적인 위험을 증가시키지 않도록 신중한 테스트가 필요합니다.
/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 2h
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/
// © antondmt
//@version=5
strategy("Ultimate Ichimoku Cloud Strategy", "UIC Strategy", true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, process_orders_on_close = true)
// Inputs {
// Backtest Range
i_time_start = input(timestamp("2015-12-12T00:00:00"), "Start Date", group = "Backtest Range")
i_time_finish = input(timestamp("2022-12-12T00:00:00"), "Finish Date", group = "Backtest Range")
// Ichimoku Lines
i_show_conversion = input(false, "Show Conversion Line (Tenkan Sen)", group = "Ichimoku Lines")
i_show_base = input(false, "Show Base Line (Kijun Sen)", group = "Ichimoku Lines")
i_show_lagging = input(false, "Show Lagging Span (Chikou Span)", group = "Ichimoku Lines")
i_show_span_A = input(false, "Show Leading Span A (Senkou Span A)", group = "Ichimoku Lines")
i_show_span_B = input(false, "Show Leading Span B (Senkou Span B)", group = "Ichimoku Lines")
i_show_all = input(true, "Show All Lines", group = "Ichimoku Lines")
// Ichimoku Periods
i_conversion_line_period = input(9, "Conversion Period", 1, group = "Ichimoku Periods")
i_base_line_period = input(26, "Base Line Period", 1, group = "Ichimoku Periods")
i_leading_span_period = input(52, "Lagging Span Period", 1, group = "Ichimoku Periods")
i_displacement = input(26, "Displacement", 1, group = "Ichimoku Periods")
// Ichimoku Long Conditions
i_long_cond_1 = input(true, "Conversion Crosses Base", "Conversion line crosses up on base line.", group = "Ichimoku Long Conditions")
i_long_cond_2 = input(false, "Conversion Above Base", "Conversion line is above base line", group = "Ichimoku Long Conditions")
i_long_cond_3 = input(true, "Positive Cloud", "Cloud has to be positive. Span A > Span B.", group = "Ichimoku Long Conditions")
i_long_cond_4 = input(true, "Price Above Cloud", "Price has to be above the clouds.", group = "Ichimoku Long Conditions")
i_long_cond_5 = input(true, "Positive Chikou", "Lagging span has to be higher than price at displacement.", group = "Ichimoku Long Conditions")
i_long_cond_6 = input(true, "Price Above Conversion", "Price has to be higher than conversion line.", group = "Ichimoku Long Conditions")
i_long_cond_show = input(false, "Show Condititons Visually", "Draws lines when condition is true.", group = "Ichimoku Long Conditions")
// Ichimoku Short Conditions
i_short_cond_1 = input(true, "Base Crosses Conversion", "Base line crosses up on conversion line.", group = "Ichimoku Short Conditions")
i_short_cond_2 = input(false, "Base Above Conversion", "Base line is above conversion line", group = "Ichimoku Short Conditions")
i_short_cond_3 = input(true, "Negative Cloud", "Cloud has to be negative. Span B > Span A.", group = "Ichimoku Short Conditions")
i_short_cond_4 = input(true, "Price Below Cloud", "Price has to be below the clouds.", group = "Ichimoku Short Conditions")
i_short_cond_5 = input(true, "Negative Chikou", "Lagging span has to be lower than price at displacement.", group = "Ichimoku Short Conditions")
i_short_cond_6 = input(true, "Price Below Base", "Price has to be lower than base line.", group = "Ichimoku Short Conditions")
i_short_cond_show = input(false, "Show Condititons Visually", "Draws lines when condition is true.", group = "Ichimoku Short Conditions")
// Ichimoku Long Exit Conditions
i_sell_long_cond_1 = input(true, "Base Crosses Conversion", "Base line crosses up on conversion line.", group = "Ichimoku Long Exit Conditions")
i_sell_long_cond_2 = input(false, "Negative Chikou", "Lagging span is lower than price at displacement.", group = "Ichimoku Long Exit Conditions")
i_sell_long_cond_show = input(false, "Show Condititons Visually", "Draws lines when condition is true.", group = "Ichimoku Long Exit Conditions")
// Ichimoku Short Exit Conditions
i_sell_short_cond_1 = input(true, "Conversion Crosses Base", "Conversion line crosses up on base line.", group = "Ichimoku Short Exit Conditions")
i_sell_short_cond_2 = input(false, "Positive Chikou", "Lagging span is higher than price at displacement.", group = "Ichimoku Short Exit Conditions")
i_sell_short_cond_show = input(false, "Show Condititons Visually", "Draws lines when condition is true.", group = "Ichimoku Short Exit Conditions")
// Exits vs TP/SL
i_use_SLTP = input(false, "Use SL and TP Instead of Exits", group = "Exits vs TP/SL")
i_TP = input(2, "Take Profit (%)", group = "Exits vs TP/SL")
i_SL = input(1, "Stop Loss (%)", group = "Exits vs TP/SL")
// }
// Ichimoku Calculations {
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
conversion_line = donchian(i_conversion_line_period)
base_line = donchian(i_base_line_period)
leading_span_A = math.avg(conversion_line, base_line)
leading_span_B = donchian(i_leading_span_period)
// }
// Entries and Exits Logic {
long_entry = false
if(i_long_cond_1 or i_long_cond_2 or i_long_cond_3 or i_long_cond_4 or i_long_cond_5 or i_long_cond_6)
long_entry := (i_long_cond_1 ? ta.crossover(conversion_line, base_line) : true)
and (i_long_cond_2 ? conversion_line > base_line : true)
and (i_long_cond_3 ? leading_span_A[i_displacement - 1] > leading_span_B[i_displacement - 1] : true)
and (i_long_cond_4 ? close > leading_span_A[i_displacement - 1] and close > leading_span_B[i_displacement - 1] : true)
and (i_long_cond_5 ? close > nz(close[i_displacement + 1], close) : true)
and (i_long_cond_6 ? close > conversion_line : true)
short_entry = false
if(i_short_cond_1 or i_short_cond_2 or i_short_cond_3 or i_short_cond_4 or i_short_cond_5)
short_entry := (i_short_cond_1 ? ta.crossunder(conversion_line, base_line) : true)
and (i_short_cond_2 ? base_line > conversion_line : true)
and (i_short_cond_3 ? leading_span_A[i_displacement - 1] < leading_span_B[i_displacement - 1] : true)
and (i_short_cond_4 ? close < leading_span_A[i_displacement - 1] and close < leading_span_B[i_displacement - 1] : true)
and (i_short_cond_5 ? close < nz(close[i_displacement + 1], close) : true)
and (i_short_cond_6 ? close < base_line : true)
long_exit = false
if(i_sell_long_cond_1 or i_sell_long_cond_2)
long_exit := (i_sell_long_cond_1 ? ta.crossunder(conversion_line, base_line) : true)
and (i_sell_long_cond_2 ? close < nz(close[i_displacement + 1], close) : true)
short_exit = false
if(i_sell_short_cond_1 or i_sell_short_cond_2)
short_exit := (i_sell_short_cond_1 ? ta.crossover(conversion_line, base_line) : true)
and (i_sell_short_cond_2 ? close > nz(close[i_displacement + 1], close) : true)
dateRange() =>
true
// }
// Entries and Exits {
if(strategy.position_size <= 0 and long_entry and dateRange())
strategy.entry("Long", strategy.long)
if(long_exit and not i_use_SLTP)
strategy.close("Long")
else if(i_use_SLTP)
strategy.exit("TP/SL", "Long", stop = strategy.position_avg_price * (1 - i_SL / 100), limit = strategy.position_avg_price * (1 + i_TP / 100))
if(strategy.position_size >= 0 and short_entry and dateRange())
strategy.entry("Short", strategy.short)
if(short_exit and not i_use_SLTP)
strategy.close("Short")
else if(i_use_SLTP)
strategy.exit("TP/SL", "Short", stop = strategy.position_avg_price * (1 + i_SL / 100), limit = strategy.position_avg_price * (1 - i_TP / 100))
// }
// Plots {
plot(i_show_all or i_show_conversion ? conversion_line : na, "Conversion Line (Tenkan Sen)", color.new(#0496ff, 0), 2)
plot(i_show_all or i_show_base ? base_line : na, "Base Line (Kijun Sen)", color.new(#991515, 0), 2)
plot(i_show_all or i_show_lagging ? close : na, "Lagging Span (Chikou Span)", color.new(color.yellow, 0), 2, offset = -i_displacement + 1)
span_A = plot(i_show_all or i_show_span_A ? leading_span_A : na, "Leading Span A (Senkou Span A)", color.new(color.green, 0), offset = i_displacement - 1)
span_B = plot(i_show_all or i_show_span_B ? leading_span_B : na, "Leading Span B (Senkou Span B)", color.new(color.red, 0), offset = i_displacement - 1)
fill(span_A, span_B, leading_span_A > leading_span_B ? color.new(color.green, 90) : color.new(color.red, 90), "Cloud Colors")
bgcolor(i_long_cond_show and long_entry ? color.new(color.green, 40) : na)
bgcolor(i_short_cond_show and short_entry ? color.new(color.red, 40) : na)
bgcolor(i_sell_long_cond_show and long_exit ? color.new(color.purple, 40) : na)
bgcolor(i_sell_short_cond_show and short_exit ? color.new(color.aqua, 40) : na)
// }