Strategi ini mengintegrasikan indikator Ichimoku Kinko Hyo dan beberapa indikator teknis lainnya untuk menggabungkan berbagai sinyal perdagangan, untuk memanfaatkan keuntungan dari sistem Ichimoku sambil mengkonfirmasi entri dengan beberapa sinyal untuk secara efektif menyaring sinyal palsu dan mengendalikan risiko sambil mengejar tingkat kemenangan yang tinggi.
Komponen utama dari strategi ini adalah:
Perhitungan indikator Ichimoku Kinko Hyo termasuk Tenkan-sen, Kijun-sen, Senkou Span A, Senkou Span B, dan Kumo.
Beberapa filter termasuk Kumo, Kijun, MACD, RSI, Fraktal, SuperTrend, Parabolic SAR dan ADX untuk mengkonfirmasi arah tren dan menghindari whipsaws.
Beberapa sinyal perdagangan termasuk price breakout, hubungan Chikou, hubungan Tenkan & Kijun total 23 sinyal Ichimoku, ditambah sinyal dari MACD, RSI, Fraktal dll untuk mengidentifikasi peluang perdagangan potensial.
Filter dua tahap untuk sinyal masuk untuk menghindari terjebak saat masuk.
Filter dua tahap untuk sinyal keluar mirip dengan filter masuk.
Kombinasi sinyal perdagangan yang dipilih dan konfirmasi filter untuk membuat keputusan perdagangan akhir.
Pengaturan mengambil keuntungan dan stop loss dapat dikonfigurasi.
Pengaturan periode backtest.
Keuntungan dari strategi ini meliputi:
Memanfaatkan indikator dan sinyal Ichimoku
Menghindari perangkap saat masuk melalui filter dua tahap dan kontrol risiko yang efektif.
Menyediakan beberapa sinyal yang dapat diperdagangkan yang dapat disesuaikan dengan kondisi pasar yang berbeda.
Menawarkan beberapa filter yang dapat dipilih yang dapat dioptimalkan untuk stok individu.
Ambil keuntungan dan stop loss membantu mengunci keuntungan dan mengontrol risiko.
Periode backtest yang memfasilitasi optimasi strategi.
Risiko dari strategi ini meliputi:
Sinyal Ichimoku mungkin lambat dan melewatkan kesempatan jangka pendek.
Filter yang berlebihan dapat menyebabkan entri yang tidak pasti. Parameter filter mungkin perlu disesuaikan.
Stop loss statis mungkin tidak beradaptasi dengan baik dengan tindakan harga yang kompleks.
Backtest keterbatasan dalam tepat mensimulasikan pasar hidup.
Cara yang mungkin untuk mengoptimalkan strategi:
Sesuaikan parameter Ichimoku seperti periode Tenkan untuk perdagangan jangka pendek.
Uji kombinasi sinyal untuk menemukan pencocokan terbaik untuk stok individu.
Mengoptimalkan parameter filter untuk menyeimbangkan efek penyaringan dan kepastian masuk.
Cobalah stop loss dinamis untuk lebih beradaptasi dengan perubahan pasar.
Gunakan periode backtest yang lebih lama atau mengetik data untuk simulasi yang lebih akurat.
Tambahkan ukuran posisi untuk penggunaan modal yang lebih baik.
Membangun optimasi parameter otomatis untuk penyesuaian yang lebih cerdas.
Strategi ini menggabungkan indikator dan sinyal Ichimoku dengan filter tambahan dan konfirmasi dari indikator teknis lainnya, mewujudkan sistem kuantitatif yang menggabungkan sinyal tren dan sinyal breakout.
/*backtest start: 2023-10-13 00:00:00 end: 2023-11-12 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/ // © ramsay09 //@version=4 strategy(title="The Strategy - Ichimoku Kinko Hyo and more",shorttitle="Strategy ", overlay=true) backtest = input(title= "Backtest (no comment-string)", type= input.bool, defval= false) entry_type = input("Both", title= "Long/Short Entry", options= ["Both", "Long", "Short"]) shared_param = input(false, title= " Shared Filter and Entry Parameters :", type= input.bool) fr_period = input(2, title= "Fractals Period (Filter/Entry)", minval= 1) rsi_period = input(14, title= "RSI Period (Filter/Entry)", minval= 1) mult = input(2, type= input.float, title= "SuperTrend multiplier (Filter/Entry)", minval= 1) len = input(5, type= input.integer, title= "SuperTrend length (Filter/Entry)", minval= 1) start = 0.02//input(0.02, title= "PSAR Start (Filter/Entry)", minval= 0) inc = 0.02//input(0.02, title= "PSAR Increment (Filter/Entry)", minval= 0) max = 0.2//input(.2, title= "PSAR Maximum (Filter/Entry)", minval= 0) adx_period = input(10, title= "ADX Period (Filter/Entry)", minval= 1) adx_tres = input(25, title= "ADX threshold (Filter/Entry)", minval= 1) X_opt = input("Price X Kumo sig", title="Signal", options= ["---", "Inside Bar sig", "Outside Bar sig", "Sandwich Bar sig", "Bar sig", "SMA50 sig", "RSI50 sig", "Fractals sig", "Parabolic SAR sig", "SuperTrend sig", "Price X Kijun sig", "Price X Kumo sig", "Kumo flip sig", "Price filtered Kumo flip sig", "Chikou X Price sig", "Chikou X Kumo sig", "Price X Tenkan sig", "Tenkan X Kumo sig", "Tenkan X Kijun sig", "Kumo filtered Tenkan X Kijun sig", "CB/CS sig", "IB/IS sig", "B1/S1 sig", "B2/S2 sig"]) entry_f_1 = input("---", title="Entry filter 1", options= ["---", "SMA50 filter", "MACD filter", "RSI50 filter", "Fractals filter", "SuperTrend filter", "Parabolic SAR filter", "Cloud filter", "Kijun filter", "ADX filter"]) entry_f_2 = input("---", title="Entry filter 2", options= ["---", "SMA50 filter", "MACD filter", "RSI50 filter", "Fractals filter", "SuperTrend filter", "Parabolic SAR filter", "Cloud filter", "Kijun filter", "ADX filter"]) exit_f_1 = input("---", title="Exit filter 1", options= ["---", "SMA50 filter", "MACD filter", "RSI50 filter", "Fractals filter", "SuperTrend filter", "Parabolic SAR filter", "Cloud filter", "Kijun filter", "ADX filter"]) exit_f_2 = input("---", title="Exit filter 2", options= ["---", "SMA50 filter", "MACD filter", "RSI50 filter", "Fractals filter", "SuperTrend filter", "Parabolic SAR filter", "Cloud filter", "Kijun filter", "ADX filter"]) //-------------------- Ichimoku -------------------- TKlength = 9 //input(9, "Tenkan-sen length", minval= 1) KJlength = 26 //input(26, "Kijun-sen length", minval= 1) CSHSlength = 26 //input(26, "Chikouspan length/horizontal shift", minval= 1) SBlength = 52 //input(52, "SenkouspanB length", minval= 1) SAlength = 26 //input(26, "SenkouspanA length", minval= 1) // calculation TK = avg(lowest(TKlength), highest(TKlength)) KJ = avg(lowest(KJlength), highest(KJlength)) CS = close SB = avg(lowest(SBlength), highest(SBlength)) SA = avg(TK,KJ) kumo_high = max(SA[CSHSlength-1], SB[CSHSlength-1]) kumo_low = min(SA[CSHSlength-1], SB[CSHSlength-1]) //------------------------------------- Filters and entry signals -------------------------------------- //---------------------- Kumo filter ------------------------ kumo_buy = close > kumo_high kumo_sell = close < kumo_low //--------------------- Kijun filter ---------------------- kijun_buy = close > KJ kijun_sell = close < KJ //----------------------- macd filter ----------------------- [macdLine_f, signalLine_f, histLine_f] = macd(close, 12, 26, 9) macd_buy = macdLine_f > signalLine_f macd_sell = macdLine_f < signalLine_f //---------------------- rsi filter and entry signal------------------------ rsi_f_buy = rsi(close, rsi_period) > 50 rsi_f_sell = rsi(close, rsi_period) < 50 //---------------- Bill Williams Fractals (filter and entry signal) ----------------- up_fr = pivothigh(fr_period, fr_period) dn_fr = pivotlow(fr_period, fr_period) fractal_up_v = valuewhen(up_fr, high[fr_period],0) fractal_dn_v = valuewhen(dn_fr, low[fr_period],0) fr_upx = high > fractal_up_v fr_dnx = low < fractal_dn_v //-------------------- SuperTrend filter and entry signal --------------------- [SuperTrend, Dir] = supertrend(mult, len) sup_buy = close > SuperTrend sup_sell = close < SuperTrend //--------------------- Heikin Ashi ----------------------- //heikin_close = security(heikinashi(syminfo.tickerid), timeframe.period, close) //heikin_open = security(heikinashi(syminfo.tickerid), timeframe.period, open) //h_buy = heikin_close[1] > heikin_open[1] //h_sell = heikin_close[1] < heikin_open[1] //----------------- Parabolic SAR Signal (pb/ps) and filter ------------------- psar_buy = high > sar(start, inc, max)[0] psar_sell = low < sar(start, inc, max)[0] //-------------------------- ADX filter --------------------------- [diplus_f, diminus_f, adx_f] = dmi(adx_period, adx_period) //-------------------------- SMA50 filter and entry--------------------------- sma50_buy = close[2] > sma(close, 50) sma50_sell = close[2] < sma(close, 50) //-------------------------- entry filter ------------------------------- //entry buy filter 1 options entry_filter_buy_1 = entry_f_1 == "---" ? true : entry_f_1 == "MACD filter" ? macd_buy : entry_f_1 == "RSI50 filter" ? rsi_f_buy : entry_f_1 == "Fractals filter" ? fr_upx : entry_f_1 == "SuperTrend filter" ? sup_buy : entry_f_1 == "Parabolic SAR filter" ? psar_buy : entry_f_1 == "Cloud filter" ? kumo_buy : entry_f_1 == "Kijun filter" ? kijun_buy : entry_f_1 == "SMA50 filter" ? sma50_buy : entry_f_1 == "ADX filter" ? adx_f > 25 : true //entry sell filter 1 options entry_filter_sell_1 = entry_f_1 == "---" ? true : entry_f_1 == "MACD filter" ? macd_sell : entry_f_1 == "RSI50 filter" ? rsi_f_sell : entry_f_1 == "Fractals filter" ? fr_dnx : entry_f_1 == "SuperTrend filter" ? sup_sell : entry_f_1 == "Parabolic SAR filter" ? psar_sell : entry_f_1 == "Cloud filter" ? kumo_sell : entry_f_1 == "Kijun filter" ? kijun_sell : entry_f_1 == "SMA50 filter" ? sma50_sell : entry_f_1 == "ADX filter" ? adx_f > 25 : true //entry buy filter 2 options entry_filter_buy_2 = entry_f_2 == "---" ? true : entry_f_2 == "MACD filter" ? macd_buy : entry_f_2 == "RSI50 filter" ? rsi_f_buy : entry_f_2 == "Fractals filter" ? fr_upx : entry_f_2 == "SuperTrend filter" ? sup_buy : entry_f_2 == "Parabolic SAR filter" ? psar_buy : entry_f_2 == "Cloud filter" ? kumo_buy : entry_f_2 == "Kijun filter" ? kijun_buy : entry_f_2 == "SMA50 filter" ? sma50_buy : entry_f_2 == "ADX filter" ? adx_f > 25 : true //entry sell filter 2 options entry_filter_sell_2 = entry_f_2 == "---" ? true : entry_f_2 == "MACD filter" ? macd_sell : entry_f_2 == "RSI50 filter" ? rsi_f_sell : entry_f_2 == "Fractals filter" ? fr_dnx : entry_f_2 == "SuperTrend filter" ? sup_sell : entry_f_2 == "Parabolic SAR filter" ? psar_sell : entry_f_2 == "Cloud filter" ? kumo_sell : entry_f_2 == "Kijun filter" ? kijun_sell : entry_f_2 == "SMA50 filter" ? sma50_sell : entry_f_2 == "ADX filter" ? adx_f > 25 : true //------------------------- exit filter ----------------------- //exit buy filter 1 options exit_filter_buy_1 = exit_f_1 == "---" ? false : exit_f_1 == "MACD filter" ? macd_buy : exit_f_1 == "RSI50 filter" ? rsi_f_buy : exit_f_1 == "Fractals filter" ? fr_upx : exit_f_1 == "SuperTrend filter" ? sup_buy : exit_f_1 == "Parabolic SAR filter" ? psar_buy : exit_f_1 == "Cloud filter" ? kumo_buy : exit_f_1 == "Kijun filter" ? kijun_buy : exit_f_1 == "SMA50 filter" ? sma50_buy : exit_f_1 == "ADX filter" ? adx_f > 25 : false //exit sell filter 1 options exit_filter_sell_1 = exit_f_1 == "---" ? false : exit_f_1 == "MACD filter" ? macd_sell : exit_f_1 == "RSI50 filter" ? rsi_f_sell : exit_f_1 == "Fractals filter" ? fr_dnx : exit_f_1 == "SuperTrend filter" ? sup_sell : exit_f_1 == "Parabolic SAR filter" ? psar_sell : exit_f_1 == "Cloud filter" ? kumo_sell : exit_f_1 == "Kijun filter" ? kijun_sell : exit_f_1 == "SMA50 filter" ? sma50_sell : exit_f_1 == "ADX filter" ? adx_f > 25 : false //exit buy filter 2 options exit_filter_buy_2 = exit_f_2 == "---" ? false : exit_f_2 == "MACD filter" ? macd_buy : exit_f_2 == "RSI50 filter" ? rsi_f_buy : exit_f_2 == "Fractals filter" ? fr_upx : exit_f_2 == "SuperTrend filter" ? sup_buy : exit_f_2 == "Parabolic SAR filter" ? psar_buy : exit_f_2 == "Cloud filter" ? kumo_buy : exit_f_2 == "Kijun filter" ? kijun_buy : exit_f_2 == "SMA50 filter" ? sma50_buy : exit_f_2 == "ADX filter" ? adx_f > 25 : false //exit sell filter 2 options exit_filter_sell_2 = exit_f_2 == "---" ? false : exit_f_2 == "MACD filter" ? macd_sell : exit_f_2 == "RSI50 filter" ? rsi_f_sell : exit_f_2 == "Fractals filter" ? fr_dnx : exit_f_2 == "SuperTrend filter" ? sup_sell : exit_f_2 == "Parabolic SAR filter" ? psar_sell : exit_f_2 == "Cloud filter" ? kumo_sell : exit_f_2 == "Kijun filter" ? kijun_sell : exit_f_2 == "SMA50 filter" ? sma50_sell : exit_f_2 == "ADX filter" ? adx_f > 25 : false //----------------------- i-o-s signals ------------------------ i_bar_buy = high[1] < high[2] and low[1] > low[2] and close > high[1] i_bar_sell = high[1] < high[2] and low[1] > low[2] and close < low[1] o_bar_buy = high[1] > high[2] and low[1] < low[2] and high > high[1] o_bar_sell = high[1] > high[2] and low[1] < low[2] and low < low[1] s_bar_buy = high[2] < high[3] and low[2] > low[3] and high[1] > high[2] and low[1] < low[2] and high > high[1] s_bar_sell = high[2] < high[3] and low[2] > low[3] and high[1] > high[2] and low[1] < low[2] and low < low[1] //----------------- Ichimoku Signal B1/S1 ----------------- buy_strong_B1 = (TK >= KJ) and close > kumo_high and CS > high[(26-1)] and CS > kumo_high[26-1] and SA > SB sell_strong_S1 = (TK <= KJ) and close < kumo_low and CS < low[(26-1)] and CS < kumo_low[26-1] and SA < SB var buy_sig = true var sell_sig = true B1_a = buy_strong_B1 and buy_sig S1_a = sell_strong_S1 and sell_sig if sell_strong_S1 buy_sig := true, sell_sig := false if buy_strong_B1 sell_sig := true, buy_sig := false //----------------- Ichimoku Signal B2/S2 ----------------- buy_strong_B2 = (TK >= KJ) and close > kumo_high and CS > high[26-1] sell_strong_S2 = (TK <= KJ) and close < kumo_low and CS < low[26-1] var buy_sig_B2 = true var sell_sig_S2 = true B2_a = buy_strong_B2 and buy_sig_B2 S2_a = sell_strong_S2 and sell_sig_S2 if sell_strong_S2 buy_sig_B2 := true, sell_sig_S2 := false if buy_strong_B2 sell_sig_S2 := true, buy_sig_B2 := false //---------------------------- Confluence Signal ---------------------------- long_short_trig = 7 //input(7, type= input.float, title= "Confluence signal trigger Level", step= 0.1) trig_gap_cbcs = input(2, type= input.float, title= "CB/CS signal sesitivity", minval= 0, maxval= 6, step= 1) //Indicators // ma sma1 = sma(close, 50) sma2 = sma(close, 200) ema1 = ema(close, 50) ema2 = ema(close, 200) [macdLine, signalLine, histLine] = macd(close, 12, 26, 9) rsi = rsi(close, 14) [diplus, diminus, adx] = dmi(7, 7) [superTrend, dir] = supertrend(2, 5) //Klinger Oszillator sv = change(hlc3) >= 0 ? volume : -volume kvo = ema(sv, 34) - ema(sv, 55) sig = ema(kvo, 13) //Vortex Indicator VMP = sum( abs( high - low[1]), 14 ) VMM = sum( abs( low - high[1]), 14 ) STR = sum( atr(1), 14 ) VIP = VMP / STR VIM = VMM / STR //Signals var float sma_sig_w = na var float ema_sig_w = na var float p_kj_sig_w = na var float tk_kj_sig_w = na var float B1_S1_sig_w = na var float B2_S2_sig_w = na var float psar_sig_w = na var float frac_sig_w = na var float macd_sig_w = na var float rsi_sig_w = na var float p_tk_sig_w = na var float dmi_sig_w = na var float klin_sig_w = na var float vort_sig_w = na var float sup_sig_w = na if sma1 > sma2 sma_sig_w := 1 else if sma1 < sma2 sma_sig_w := 0 if ema1 > ema2 ema_sig_w := 1 else if ema1 < ema2 ema_sig_w := 0 if close > KJ p_kj_sig_w := 1 else if close < KJ p_kj_sig_w := 0 if TK > KJ tk_kj_sig_w := 1 else if TK < KJ tk_kj_sig_w := 0 if buy_strong_B1 B1_S1_sig_w := 1 else if sell_strong_S1 B1_S1_sig_w := 0 if buy_strong_B2 B2_S2_sig_w := 1 else if sell_strong_S2 B2_S2_sig_w := 0 if high >= sar(start, inc, max)[0] psar_sig_w := 1 else if low <= sar(start, inc, max)[0] psar_sig_w := 0 if high > fractal_up_v frac_sig_w := 1 else if low < fractal_dn_v frac_sig_w := 0 if macdLine > signalLine macd_sig_w := 1 else if macdLine < signalLine macd_sig_w := 0 if rsi > 50 rsi_sig_w := 1 else if rsi < 50 rsi_sig_w := 0 if close[2] > TK p_tk_sig_w := 1 else if close[2] < TK p_tk_sig_w := 0 if diplus > diminus dmi_sig_w := 1 else if diplus < diminus dmi_sig_w := 0 if sig > 0 klin_sig_w := 1 else if sig < 0 klin_sig_w := 0 if VIP > VIM vort_sig_w := 1 else if VIP < VIM vort_sig_w := 0 if close > superTrend sup_sig_w := 1 else if close < superTrend sup_sig_w := 0 bs_conf_sig = sma_sig_w + ema_sig_w + p_kj_sig_w + tk_kj_sig_w + B1_S1_sig_w + B2_S2_sig_w + psar_sig_w + frac_sig_w + macd_sig_w + rsi_sig_w + dmi_sig_w + klin_sig_w + vort_sig_w + sup_sig_w + p_tk_sig_w long_c = bs_conf_sig > long_short_trig + trig_gap_cbcs //with +- signal is less fluctuating short_c = bs_conf_sig < long_short_trig - trig_gap_cbcs //---------------------------- Pure Ichimoku Confluence Signal ---------------------------- pic_l_s_trig = 4 //input(4, type= input.float, title= "Ichimoku confluence signal trigger Level", step= 0.1) trig_gap_ibis = input(0, type= input.float, title= "IB/IS signal sesitivity", minval= 0, maxval= 3, step= 1) //Signals var float tkkh_sig_w = na var float csh_sig_w = na var float cskh_sig_w = na var float pkj_sig_w = na var float ptk_sig_w = na var float tkkj_sig_w = na var float sasb_sig_w = na var float ckh_sig_w = na if TK > kumo_high tkkh_sig_w := 1 else if TK < kumo_low tkkh_sig_w := 0 if CS > high[(26-1)] csh_sig_w := 1 else if CS < low[(26-1)] csh_sig_w := 0 if CS > kumo_high[26-1] cskh_sig_w := 1 else if CS < kumo_low[26-1] cskh_sig_w := 0 if close > TK ptk_sig_w := 1 else if close < TK ptk_sig_w := 0 if close > KJ pkj_sig_w := 1 else if close < KJ pkj_sig_w := 0 if TK > KJ tkkj_sig_w := 1 else if TK < KJ tkkj_sig_w := 0 if SA > SB sasb_sig_w := 1 else if SA < SB sasb_sig_w := 0 if close > kumo_high ckh_sig_w := 1 else if close < kumo_low ckh_sig_w := 0 bs_pic_sig = tkkh_sig_w + csh_sig_w + cskh_sig_w + ptk_sig_w + pkj_sig_w + tkkj_sig_w + sasb_sig_w + ckh_sig_w long_pic = bs_pic_sig > pic_l_s_trig + trig_gap_ibis short_pic = bs_pic_sig < pic_l_s_trig - trig_gap_ibis //--------------------------- Entry Signal Options --------------------------- var buy_sig_opt = true var sell_sig_opt = true // cross conditions for "Strong" bg's var bool sasb_x = true if crossover(SA, SB) and low > kumo_high sasb_x := true if crossunder(SA, SB) and high < kumo_low sasb_x := false var bool tkkj_x = true if crossover(TK, KJ) and TK > kumo_high and KJ > kumo_high tkkj_x := true if crossunder(TK, KJ) and TK < kumo_low and KJ < kumo_low tkkj_x := false // buy signal options opt_sig_buy = X_opt == "---" ? na : X_opt == "Inside Bar sig" ? i_bar_buy : X_opt == "Outside Bar sig" ? o_bar_buy : X_opt == "Sandwich Bar sig" ? s_bar_buy : X_opt == "Bar sig" ? close > high[1] : X_opt == "SMA50 sig" ? close[2] > sma(close, 50) : X_opt == "Fractals sig" ? fr_upx : X_opt == "RSI50 sig" ? rsi_f_buy : X_opt == "Parabolic SAR sig" ? psar_buy : X_opt == "SuperTrend sig" ? sup_buy : X_opt == "Price X Kijun sig" ? close > KJ : X_opt == "Price X Kumo sig" ? close > kumo_high : X_opt == "Kumo flip sig" ? SA > SB : X_opt == "Price filtered Kumo flip sig" ? sasb_x and low > kumo_high : X_opt == "Chikou X price sig" ? CS > high[(26-1)] : X_opt == "Chikou X Kumo sig" ? CS > kumo_high[26-1] : X_opt == "Price X Tenkan sig" ? close > TK : X_opt == "Tenkan X Kumo sig" ? TK > kumo_high : X_opt == "Tenkan X Kijun sig" ? TK > KJ : X_opt == "Kumo filtered Tenkan X Kijun sig" ? tkkj_x and TK > kumo_high and KJ > kumo_high and TK > KJ : X_opt == "CB/CS sig" ? long_c : X_opt == "IB/IS sig" ? long_pic : X_opt == "B1/S1 sig" ? buy_strong_B1 : X_opt == "B2/S2 sig" ? buy_strong_B2 : na // sell signal options opt_sig_sell = X_opt == "---" ? na : X_opt == "Inside Bar sig" ? i_bar_sell : X_opt == "Outside Bar sig" ? o_bar_sell : X_opt == "Sandwich Bar sig" ? s_bar_sell : X_opt == "Bar sig" ? close < low[1] : X_opt == "SMA50 sig" ? close[2] < sma(close, 50) : X_opt == "Fractals sig" ? fr_dnx : X_opt == "RSI50 sig" ? rsi_f_sell : X_opt == "Parabolic SAR sig" ? psar_sell : X_opt == "SuperTrend sig" ? sup_sell : X_opt == "Price X Kijun sig" ? close < KJ : X_opt == "Price X Kumo sig" ? close < kumo_low : X_opt == "Kumo flip sig" ? SA < SB : X_opt == "Price filtered Kumo flip sig" ? not sasb_x and high < kumo_low : X_opt == "Chikou X price sig" ? CS < low[(26-1)] : X_opt == "Chikou X Kumo sig" ? CS < kumo_high[26-1] : X_opt == "Price X Tenkan sig" ? close < TK : X_opt == "Tenkan X Kumo sig" ? TK < kumo_low : X_opt == "Tenkan X Kijun sig" ? TK < KJ : X_opt == "Kumo filtered Tenkan X Kijun sig" ? not tkkj_x and TK < kumo_low and KJ < kumo_low and TK < KJ : X_opt == "CB/CS sig" ? short_c : X_opt == "IB/IS sig" ? short_pic : X_opt == "B1/S1 sig" ? sell_strong_S1 : X_opt == "B2/S2 sig" ? sell_strong_S2 : na if opt_sig_sell buy_sig := true, sell_sig_opt := false if opt_sig_buy sell_sig := true, buy_sig_opt := false //---------------------------- Take profit and stop loss ------------------------------ tp_en = input(title= "Enable take profit", type= input.bool, defval= false) qty_tp = input(50, title= "Take profit - quantity of position (percent)", type= input.float, minval= 1, maxval= 100, step= 5) tp_ticks = input(1000, title= "Take profit - ticks", type= input.integer, minval= 0, step= 10) sl_en = input(title= "Enable stop loss", type= input.bool, defval= false) sl_ticks = input(1000, title= "Stop loss - ticks", type= input.integer, minval= 0, step= 10) //----------------------- Backtest periode -------------------------------- start_year = input(2018, "Start year") start_month = input(1, "Start month", minval= 1, maxval= 12) start_day = input(1, "Start day", minval= 1, maxval= 31) period_start = timestamp(start_year, start_month, start_day, 0, 0) stop_year = input(2021, "Stop year") stop_month = input(12, "Stop month", minval= 1, maxval= 12) stop_day = input(31, "Stop day", minval= 1, maxval= 31) period_stop = timestamp(stop_year, stop_month, stop_day, 0, 0) backtest_period() => time >= period_start and time <= period_stop ? true : false //--------------------- strategy entry --------------------- long = entry_type != "Short" short = entry_type != "Long" not_both = entry_type != "Both" if not backtest if long strategy.entry("os_buy", strategy.long, when = opt_sig_buy and entry_filter_buy_1 and entry_filter_buy_2, comment= "") strategy.close("os_buy", when = exit_filter_sell_1 or exit_filter_sell_2 or not_both ? opt_sig_sell : na , comment= "") strategy.exit("tpl", "os_buy", qty_percent= tp_en ? qty_tp : na, profit= tp_en ? tp_ticks : na, loss= sl_en ? sl_ticks : na) if short strategy.entry("os_sell",strategy.short, when = opt_sig_sell and entry_filter_sell_1 and entry_filter_sell_2, comment= "") strategy.close("os_sell", when = exit_filter_buy_1 or exit_filter_buy_2 or not_both ? opt_sig_buy : na , comment= "") strategy.exit("tps", "os_sell", qty_percent= tp_en ? qty_tp : na, profit= tp_en ? tp_ticks : na, loss= sl_en ? sl_ticks : na) if backtest_period() and backtest if long strategy.entry("os_buy", strategy.long, when = opt_sig_buy and entry_filter_buy_1 and entry_filter_buy_2) strategy.close("os_buy", when = exit_filter_sell_1 or exit_filter_sell_2 or not_both ? opt_sig_sell : na) strategy.exit("tpl", "os_buy", qty_percent= tp_en ? qty_tp : na, profit= tp_en ? tp_ticks : na, loss= sl_en ? sl_ticks : na) if short strategy.entry("os_sell",strategy.short, when = opt_sig_sell and entry_filter_sell_1 and entry_filter_sell_2) strategy.close("os_sell", when = exit_filter_buy_1 or exit_filter_buy_2 or not_both ? opt_sig_buy : na) strategy.exit("tps", "os_sell", qty_percent= tp_en ? qty_tp : na, profit= tp_en ? tp_ticks : na, loss= sl_en ? sl_ticks : na)