오시슬레이션과 함께의 수익 그리드 전략은 가격 오시슬레이션에 따라 지속적으로 수익을 창출하기 위해 가격 변동에 따라 자동으로 그리드를 설정하는 트렌드를 따르는 전략입니다.
이 전략의 핵심 아이디어는 가격 범위의 그리드를 구축하는 것입니다. 가격이 다른 범위로 들어갈 때 새로운 거래 신호가 생성됩니다. 예를 들어, 그리드 격차가 500 USD로 설정되면 가격이 500 USD 이상 상승하면 새로운 긴 신호가 유발됩니다.
구체적으로, 전략은 새로운 높은 가격이나 낮은 가격을 추적하여 그리드를 계속 움직입니다.re_grid
현재 네트워크 가격을 저장하기 위해 정의됩니다. 가격이 정의된 네트워크 격차를 넘어 이 네트워크 가격을 통과하는 한 다음 네트워크 가격이 재 계산됩니다.
따라서, 새로운 거래 신호는 가격이 충분히 변동할 때 생성된다. 그에 따라 길거나 짧게 이동하여 수익을 얻을 수 있다. 가격이 그리드 격차를 초과하는 반대 방향으로 움직이기 시작하면 이전 포지션은 이익으로 중단된다.
이 전략의 가장 큰 장점은 자동으로 가격 트렌드를 추적하고 지속적으로 수익을 창출 할 수 있다는 것입니다. 가격이 강하게 변동하는 동안, 우리의 위치 크기와 이익은 지속적으로 증가 할 것입니다.
또한 네트워크 매개 변수를 합리적으로 설정함으로써 위험을 효과적으로 제어 할 수 있습니다. 이치모쿠 클라우드와 같은 기술 지표와 결합하여 신호를 필터하면 전략의 안정성을 향상시킬 수 있습니다.
이 전략의 주요 위험은 가격이 갑자기 역전되어 스톱 로스로 이어질 수 있다는 것입니다. 축적 된 이익은 감소하거나 손실로 변할 수도 있습니다.
이러한 위험을 통제하기 위해 우리는 스톱 로스 라인을 설정하고, 그리드 매개 변수를 합리적으로 조정하고, 더 강한 트렌드를 가진 제품을 선택하고, 여러 기술적 지표로 신호를 필터링할 수 있습니다.
우리는 다음과 같은 측면에서 전략을 최적화 할 수 있습니다:
그리드 매개 변수를 최적화하여 그리드 간격, 위치 크기 등을 최적화합니다.
스톱 로스 메커니즘을 개선하거나 조정하여 위험을 더 잘 제어합니다.
다른 거래 상품을 테스트하고 더 높은 변동과 더 명확한 트렌드를 가진 제품을 선택하십시오.
신호를 판단하고 안정성을 향상시키기 위해 더 많은 기술적 지표를 추가합니다.
오스실레이션과 함께 수익 그리드 전략은 가격 그리드를 설정함으로써 트렌드를 자동으로 추적함으로써 지속적인 이익을 효과적으로 창출 할 수 있습니다. 동시에 특정 드라우다운 리스크가 있습니다. 매개 변수 최적화, 스톱 로스 설정, 제품 선택 등으로 리스크를 효과적으로 제어하고 전략을 더욱 견고하게 할 수 있습니다.
/*backtest start: 2023-01-16 00:00:00 end: 2024-01-22 00:00:00 period: 1d basePeriod: 1h 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="Grid Tool",shorttitle= "Grid", overlay= true ) backtest = input(title= "Backtest (no comment-string, disable for API-trading)", type= input.bool, defval= true) entry_type = input("Long", title= "Long/Short Entry", options= ["Long", "Short"]) X_opt = input("Grid - reentry", title="--- 1st ENTRY SIGNAL ---", options= ["---", "Grid - reentry", "Grid - counter trend", "Fractals", "Reverse fractal"]) X_opt_2 = input("---", title="--- 2nd ENTRY SIGNAL ---", options= ["---", "Grid - reentry", "Grid - counter trend", "Fractals", "Reverse fractal"]) entry_f_1 = input("---", title="Entry filter 1", options= ["---", "Bar breakout 1 filter", "Bar breakout 2 filter", "SMA filter", "MACD filter", "RSI50 filter", "Fractals filter", "Segments filter", "Fractals 1-2-3 filter", "Reverse fractal filter", "EMA21/SMA20 filter", "TRIX filter", "SuperTrend filter", "Parabolic SAR filter", "ADX filter", "Price X Kumo filter", "Price X Kijun filter", "Kumo flip filter", "Price filtered Kumo flip filter", "Chikou X price filter", "Chikou X Kumo filter", "Price X Tenkan filter", "Tenkan X Kumo filter", "Tenkan X Kijun filter"]) entry_f_2 = input("---", title="Entry filter 2", options= ["---", "Bar breakout 1 filter", "Bar breakout 2 filter", "SMA filter", "MACD filter", "RSI50 filter", "Fractals filter", "Segments filter", "Fractals 1-2-3 filter", "Reverse fractal filter", "EMA21/SMA20 filter", "TRIX filter", "SuperTrend filter", "Parabolic SAR filter", "ADX filter", "Price X Kumo filter", "Price X Kijun filter", "Kumo flip filter", "Price filtered Kumo flip filter", "Chikou X price filter", "Chikou X Kumo filter", "Price X Tenkan filter", "Tenkan X Kumo filter", "Tenkan X Kijun filter"]) exit_f_1 = input("---", title="Exit filter 1", options= ["---", "TRIX exit", "Reverse fractal exit", "SMA exit", "MACD exit", "RSI50 exit", "Fractals exit", "SuperTrend exit", "Parabolic SAR exit", "ADX exit", "Cloud exit", "Kijun exit"]) exit_f_2 = input("---", title="Exit filter 2", options= ["---", "TRIX exit", "Reverse fractal exit", "SMA exit", "MACD exit", "RSI50 exit", "Fractals exit", "SuperTrend exit", "Parabolic SAR exit", "ADX exit", "Cloud exit", "Kijun exit"]) //--------------------- Signal inputs ----------------------- grid_gap = input(500, type= input.float, title= "Grid gap - base currency", minval= 0, step= 10) //--------------------- filter inputs -------------------- shared_param = input(false, title= " Shared filter and entry parameters :", type= input.bool) sb = input(title="Segment max bars", defval= 10, minval= 0, step= 1) fr_period = input(2, title= "Fractals period", minval= 1) rsi_period = input(14, title= "RSI period", minval= 1) ma_period = input(50, title= "MA period", minval= 1) mult = input(3, type= input.float, title= "SuperTrend multiplier", minval= 1, step= 0.1) len = input(6, type= input.integer, title= "SuperTrend length", 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) di_length_s = input(10, title= "DI length (signals)", minval= 1) adx_smooth_s = input(10, title= "ADX smooth (signals)", minval= 1) adx_thres_s = input(25, title= "ADX threshold (signals)", minval= 1) trix_len_f = input(14, title= "TRIX Length", type=input.integer, minval=1) smooth_length_f = input(6, title= "Signal Smoothing Length (TRIX)", type=input.integer, minval=1) //--------------------- exit inputs -------------------- exit_param = input(false, title= " Exit Parameters :", type= input.bool) trix_len_x = input(14, title= "TRIX Length", type=input.integer, minval=1) smooth_length_x = input(6, title= "Signal Smoothing Length (TRIX)", type=input.integer, minval=1) fr_period_x = input(2, title= "Exit fractals - period", minval= 1) fr_past_x = input(0, title= "Exit fractals - past fractal", minval= 0) rsi_period_x = input(14, title= "Exit RSI period", minval= 1) ma_period_x = input(50, title= "Exit MA period", minval= 1) mult_x = input(2, type= input.float, title= "Exit SuperTrend multiplier", minval= 1) len_x = input(5, type= input.integer, title= "Exit SuperTrend length", minval= 1) di_length_x = input(10, title= "Exit ADX period", minval= 1) adx_smooth_x = input(10, title= "Exit ADX smooth", minval= 1) adx_thres_x = input(25, title= "Exit ADX threshold", minval= 1) //----------------------- Backtest periode -------------------------------- b_t_per_start = input(false, title= " Set backtest start or/and trend start :", type= input.bool) start_year = input(2020, "Start year") start_month = input(3, "Start month", minval= 1, maxval= 12) start_day = input(13, "Start day", minval= 1, maxval= 31) period_start = timestamp(start_year, start_month, start_day, 0, 0) stop_year = input(2120, "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 //-------------------- 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 -------------------------------------- //---------------------- Ichimoku filter ------------------------ // cross conditions for "Strong" filtered signals 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 // Ichimoku filters kijun_buy_f = close > KJ kumo_buy_f = close > kumo_high kumo_flip_buy_f = SA > SB price_filtered_kumo_flip_buy_f = sasb_x and low > kumo_high chikou_X_price_buy_f = CS > high[(26-1)] chikou_X_kumo_buy_f = CS > kumo_high[26-1] price_X_tenkan_buy_f = close > TK tenkan_X_kumo_buy_f = TK > kumo_high tenkan_X_kijun_buy_f = TK > KJ kumo_filtered_tenkan_X_kijun_buy_f = tkkj_x and TK > kumo_high and KJ > kumo_high and TK > KJ kijun_sell_f = close < KJ kumo_sell_f = close < kumo_low kumo_flip_sell_f = SA < SB price_filtered_kumo_flip_sell_f = not sasb_x and high < kumo_low chikou_X_price_sell_f = CS < low[(26-1)] chikou_X_kumo_sell_f = CS < kumo_low[26-1] price_X_tenkan_sell_f = close < TK tenkan_X_kumo_sell_f = TK < kumo_low tenkan_X_kijun_sell_f = TK < KJ kumo_filtered_tenkan_X_kijun_sell_f = not tkkj_x and TK < kumo_low and KJ < kumo_low and TK < KJ // Ichimoku exits kijun_buy_x = close > KJ kumo_buy_x = close > kumo_high kijun_sell_x = close < KJ kumo_sell_x = close < kumo_low //------------------------ grid -------------------------- //up_grid = 0. //up_grid := nz(high > up_grid[1] + grid_gap and backtest_period() ? close : up_grid[1]) // forward grid long //dn_grid = 0. //dn_grid := nz(low < dn_grid[1] - grid_gap and backtest_period() ? close : dn_grid[1]) // forward grid short re_grid = 0. re_grid := nz(high > re_grid[1] + grid_gap or low < re_grid[1] - grid_gap ? close : re_grid[1]) //grid_up_buy = up_grid > up_grid[1] //grid_dn_sell = dn_grid < dn_grid[1] grid_ct_buy = re_grid < re_grid[1] grid_ct_sell = re_grid > re_grid[1] grid_re_buy = re_grid > re_grid[1] grid_re_sell = re_grid < re_grid[1] //plot(re_grid,"Plot", color= color.yellow, linewidth= 2) //---------------------- reverse fractal signal and filter -------------------------- up_bar = close[0] > open[0] dn_bar = close[0] < open[0] hl = low[0] > low[1] lh = high[0] < high[1] rev_up_fr_sell = pivothigh(high, 3, 0) and dn_bar and up_bar[1] or pivothigh(high, 4, 1) and dn_bar and up_bar[1] or pivothigh(high, 4, 1) and lh and up_bar and up_bar[1] rev_dn_fr_buy = pivotlow(low, 3, 0) and up_bar and dn_bar[1] or pivotlow(low, 4, 1) and up_bar and dn_bar[1] or pivotlow(low, 4, 1) and hl and dn_bar and dn_bar[1] ema_f(src, ema_len) => ema(src, ema_len) // ma function definition sma_f(src, sma_len) => sma(src, sma_len) ema_21 = ema_f(close, 21) // ema21/sma20 signal sma_20 = sma_f(close, 20) ma_cross_buy = close > ema_21 and close > sma_20 and ema_21 > sma_20 ma_cross_sell = close < ema_21 and close < sma_20 and ema_21 < sma_20 //--------------------- TRIX ------------------------ triple_ema_f = ema(ema(ema(close, trix_len_f), trix_len_f), trix_len_f) trix_f = roc(triple_ema_f, 1) signal_f = sma(trix_f, smooth_length_f) triple_ema_x = ema(ema(ema(close, trix_len_x), trix_len_x), trix_len_x) trix_x = roc(triple_ema_x, 1) signal_x = sma(trix_x, smooth_length_x) //filters trix_buy_f = trix_f > signal_f trix_sell_f = trix_f < signal_f //exits trix_buy_x = trix_x > signal_x trix_sell_x = trix_x < signal_x //----------------------- macd filter ----------------------- [macdLine_f, signalLine_f, histLine_f] = macd(close, 12, 26, 9) //filters macd_buy = macdLine_f > signalLine_f macd_sell = macdLine_f < signalLine_f //exit macd_buy_x = macdLine_f > signalLine_f macd_sell_x = macdLine_f < signalLine_f //---------------------- rsi filter and entry signal------------------------ //entry rsi_f = rsi(close, rsi_period) rsi_f_buy = rsi_f > 50 rsi_f_sell = rsi_f < 50 //filters rsi_f_buy_f = rsi_f > 50 rsi_f_sell_f = rsi_f < 50 //exit rsi_f_x = rsi(close, rsi_period_x) rsi_f_buy_x = rsi_f_x > 50 rsi_f_sell_x = rsi_f_x < 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) //entry signal fr_upx = crossover(high, fractal_up_v) fr_dnx = crossunder(low, fractal_dn_v) //filters fr_upx_f = high > fractal_up_v fr_dnx_f = low < fractal_dn_v //exit up_fr_x = pivothigh(fr_period_x, fr_period_x) dn_fr_x = pivotlow(fr_period_x, fr_period_x) fractal_up_v_x = valuewhen(up_fr_x, high[fr_period_x], fr_past_x) fractal_dn_v_x = valuewhen(dn_fr_x, low[fr_period_x], fr_past_x) fr_upx_x = high > fractal_up_v_x fr_dnx_x = low < fractal_dn_v_x //higher low and higher high - lower high and lower low - entry fractal_dn_v_1 = valuewhen(dn_fr, low[fr_period],1) fractal_up_v_1 = valuewhen(up_fr, high[fr_period],1) hl_hh_buy = fractal_dn_v > fractal_dn_v_1 and high > fractal_up_v // 123 signal and filter lh_ll_sell = fractal_up_v < fractal_up_v_1 and low < fractal_dn_v //-------------------- SuperTrend filter and entry signal --------------------- //entry [SuperTrend, Dir] = supertrend(mult, len) sup_buy = close > SuperTrend sup_sell = close < SuperTrend //filters sup_buy_f = close > SuperTrend sup_sell_f = close < SuperTrend //exit [SuperTrend_x, Dir_x] = supertrend(mult_x, len_x) sup_buy_x = close > SuperTrend_x sup_sell_x = close < SuperTrend_x //----------------- Parabolic SAR Signal (pb/ps) and filter ------------------- psar_buy = high > sar(start, inc, max)[0] psar_sell = low < sar(start, inc, max)[0] //filters psar_buy_f = high > sar(start, inc, max)[0] psar_sell_f = low < sar(start, inc, max)[0] //-------------------------- ADX entry and filter --------------------------- //exit [diplus_f_x, diminus_f_X, adx_f_x] = dmi(di_length_x, adx_smooth_x) adx_thres_f_x = adx_f_x < adx_thres_x //adx signal 1/2 and filters [diplus_s, diminus_s, adx_s] = dmi(di_length_s, adx_smooth_s) adx_above_thres = adx_s > adx_thres_s long_1 = diplus_s > diminus_s and adx_s < diplus_s and adx_s > diminus_s short_1 = diplus_s < diminus_s and adx_s > diplus_s and adx_s < diminus_s long_2 = diplus_s > diminus_s and adx_above_thres short_2 = diplus_s < diminus_s and adx_above_thres //-------------------------- SMA50 filter and entry--------------------------- //entry sma_buy = close[2] > ema_f(close, ma_period) sma_sell = close[2] < ema_f(close, ma_period) //filters sma_buy_f = close[2] > sma_f(close, ma_period) sma_sell_f = close[2] < sma_f(close, ma_period) //exit sma_buy_x = close[1] > sma_f(close, ma_period_x) sma_sell_x = close[1] < sma_f(close, ma_period_x) //--------------------------- Segments signal ---------------------------- count1_l = 0 count2_l = 0 segment_1_stat_l = false segment_2_stat_l = false segment_3_stat_l = false higher_low = low > low[1] var line segment_low_1_l = na var line segment_low_2_l = na var line segment_low_3_l = na // long segments for i=0 to sb count1_l := count1_l + 1 if low[1] > low[i+2] and higher_low segment_1_stat_l := true break for i=count1_l to sb+count1_l count2_l := count2_l + 1 if low[1+count1_l] > low[i+2] and segment_1_stat_l segment_2_stat_l := true break for i=count2_l to sb+count2_l if low[1+count1_l+count2_l] > low[i+2+count1_l] and segment_2_stat_l segment_3_stat_l := true break // short segments count1_s = 0 count2_s = 0 segment_1_stat_s = false segment_2_stat_s = false segment_3_stat_s = false lower_high = high < high[1] var line segment_high_1 = na var line segment_high_2 = na var line segment_high_3 = na for i=0 to sb count1_s := count1_s + 1 if high[1] < high[i+2] and lower_high segment_1_stat_s := true break for i=count1_s to sb+count1_s count2_s := count2_s + 1 if high[1+count1_s] < high[i+2] and segment_1_stat_s segment_2_stat_s := true break for i=count2_s to sb+count2_s if high[1+count1_s+count2_s] < high[i+2+count1_s] and segment_2_stat_s segment_3_stat_s := true break // segments signals seg_stat_l = segment_1_stat_l and segment_2_stat_l and segment_3_stat_l seg_stat_s = segment_1_stat_s and segment_2_stat_s and segment_3_stat_s //entry segments_buy = high > high[1] and seg_stat_l[1] segments_sell = low < low[1] and seg_stat_s[1] //filters segments_buy_f = high > high[1] and seg_stat_l[1] segments_sell_f = low < low[1] and seg_stat_s[1] //--------------------------- Entry Signal Options --------------------------- // buy signal options 1 opt_sig_buy = X_opt == "---" ? na : // X_opt == "Grid - forward sig" ? grid_up_buy : X_opt == "Grid - counter trend" ? grid_ct_buy : X_opt == "Grid - reentry" ? grid_re_buy : X_opt == "Fractals" ? fr_upx : X_opt == "Reverse fractal" ? rev_dn_fr_buy : na // sell signal options 1 opt_sig_sell = X_opt == "---" ? na : // X_opt == "Grid - forward sig" ? grid_dn_sell : X_opt == "Grid - counter trend" ? grid_ct_sell : X_opt == "Grid - reentry" ? grid_re_sell : X_opt == "Fractals" ? fr_dnx : X_opt == "Reverse fractal" ? rev_up_fr_sell : na // buy signal options 2 opt_sig_buy_2 = X_opt_2 == "---" ? na : // X_opt_2 == "Grid - forward sig" ? grid_up_buy : X_opt_2 == "Grid - counter trend" ? grid_ct_buy : X_opt_2 == "Grid - reentry" ? grid_re_buy : X_opt_2 == "Fractals" ? fr_upx : X_opt_2 == "Reverse fractal" ? rev_dn_fr_buy : na // sell signal options 2 opt_sig_sell_2 = X_opt_2 == "---" ? na : // X_opt_2 == "Grid - forward sig" ? grid_dn_sell : X_opt_2 == "Grid - counter trend" ? grid_ct_sell : X_opt_2 == "Grid - reentry" ? grid_re_sell : X_opt_2 == "Fractals" ? fr_dnx : X_opt_2 == "Reverse fractal" ? rev_up_fr_sell : na //-------------------------- 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_f : entry_f_1 == "Fractals filter" ? fr_upx_f : entry_f_1 == "SuperTrend filter" ? sup_buy_f : entry_f_1 == "Parabolic SAR filter" ? psar_buy_f : entry_f_1 == "SMA filter" ? sma_buy_f : entry_f_1 == "ADX filter" ? adx_above_thres : entry_f_1 == "Segments filter" ? segments_buy : entry_f_1 == "Fractals 1-2-3 filter" ? hl_hh_buy : entry_f_1 == "Reverse fractal filter" ? rev_dn_fr_buy : entry_f_1 == "EMA21/SMA20 filter" ? ma_cross_buy : entry_f_1 == "TRIX filter" ? trix_buy_f : entry_f_1 == "Price X Kumo filter" ? kumo_buy_f : entry_f_1 == "Price X Kijun filter" ? kijun_buy_f : entry_f_1 == "Kumo flip filter" ? kumo_flip_buy_f : entry_f_1 == "Price filtered Kumo flip filter" ? price_filtered_kumo_flip_buy_f : entry_f_1 == "Chikou X price filter" ? chikou_X_price_buy_f : entry_f_1 == "Chikou X Kumo filter" ? chikou_X_kumo_buy_f : entry_f_1 == "Price X Tenkan filter" ? price_X_tenkan_buy_f : entry_f_1 == "Tenkan X Kumo filter" ? tenkan_X_kumo_buy_f : entry_f_1 == "Tenkan X Kijun filter" ? tenkan_X_kijun_buy_f : 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_f : entry_f_1 == "Fractals filter" ? fr_dnx_f : entry_f_1 == "SuperTrend filter" ? sup_sell_f : entry_f_1 == "Parabolic SAR filter" ? psar_sell_f : entry_f_1 == "SMA filter" ? sma_sell_f : entry_f_1 == "ADX filter" ? adx_above_thres : entry_f_1 == "Segments filter" ? segments_sell : entry_f_1 == "Fractals 1-2-3 filter" ? lh_ll_sell : entry_f_1 == "Reverse fractal filter" ? rev_up_fr_sell : entry_f_1 == "EMA21/SMA20 filter" ? ma_cross_sell : entry_f_1 == "TRIX filter" ? trix_sell_f : entry_f_1 == "Price X Kumo filter" ? kumo_sell_f : entry_f_1 == "Price X Kijun filter" ? kijun_sell_f : entry_f_1 == "Kumo flip filter" ? kumo_flip_sell_f : entry_f_1 == "Price filtered Kumo flip filter" ?price_filtered_kumo_flip_sell_f : entry_f_1 == "Chikou X price filter" ? chikou_X_price_sell_f : entry_f_1 == "Chikou X Kumo filter" ? chikou_X_kumo_sell_f : entry_f_1 == "Price X Tenkan filter" ? price_X_tenkan_sell_f : entry_f_1 == "Tenkan X Kumo filter" ? tenkan_X_kumo_sell_f : entry_f_1 == "Tenkan X Kijun filter" ? tenkan_X_kijun_sell_f : 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_f : entry_f_2 == "Fractals filter" ? fr_upx_f : entry_f_2 == "SuperTrend filter" ? sup_buy_f : entry_f_2 == "Parabolic SAR filter" ? psar_buy_f : entry_f_2 == "SMA filter" ? sma_buy_f : entry_f_2 == "ADX filter" ? adx_above_thres : entry_f_2 == "Segments filter" ? segments_buy : entry_f_2 == "Fractals 1-2-3 filter" ? hl_hh_buy : entry_f_2 == "Reverse fractal filter" ? rev_dn_fr_buy : entry_f_2 == "EMA21/SMA20 filter" ? ma_cross_buy : entry_f_2 == "TRIX filter" ? trix_buy_f : entry_f_2 == "Price X Kumo filter" ? kumo_buy_f : entry_f_2 == "Price X Kijun filter" ? kijun_buy_f : entry_f_2 == "Kumo flip filter" ? kumo_flip_buy_f : entry_f_2 == "Price filtered Kumo flip filter" ? price_filtered_kumo_flip_buy_f : entry_f_2 == "Chikou X price filter" ? chikou_X_price_buy_f : entry_f_2 == "Chikou X Kumo filter" ? chikou_X_kumo_buy_f : entry_f_2 == "Price X Tenkan filter" ? price_X_tenkan_buy_f : entry_f_2 == "Tenkan X Kumo filter" ? tenkan_X_kumo_buy_f : entry_f_2 == "Tenkan X Kijun filter" ? tenkan_X_kijun_buy_f : 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_f : entry_f_2 == "Fractals filter" ? fr_dnx_f : entry_f_2 == "SuperTrend filter" ? sup_sell_f : entry_f_2 == "Parabolic SAR filter" ? psar_sell_f : entry_f_2 == "SMA filter" ? sma_sell_f : entry_f_2 == "ADX filter" ? adx_above_thres : entry_f_2 == "Segments filter" ? segments_sell : entry_f_2 == "Fractals 1-2-3 filter" ? lh_ll_sell : entry_f_2 == "Reverse fractal filter" ? rev_up_fr_sell : entry_f_2 == "EMA21/SMA20 filter" ? ma_cross_sell : entry_f_2 == "TRIX filter" ? trix_sell_f : entry_f_2 == "Price X Kumo filter" ? kumo_sell_f : entry_f_2 == "Price X Kijun filter" ? kijun_sell_f : entry_f_2 == "Kumo flip filter" ? kumo_flip_sell_f : entry_f_2 == "Price filtered Kumo flip filter" ? price_filtered_kumo_flip_sell_f : entry_f_2 == "Chikou X price filter" ? chikou_X_price_sell_f : entry_f_2 == "Chikou X Kumo filter" ? chikou_X_kumo_sell_f : entry_f_2 == "Price X Tenkan filter" ? price_X_tenkan_sell_f : entry_f_2 == "Tenkan X Kumo filter" ? tenkan_X_kumo_sell_f : entry_f_2 == "Tenkan X Kijun filter" ? tenkan_X_kijun_sell_f : true //------------------------- exit filter ----------------------- //short exit buy filter 1 options exit_filter_buy_1 = exit_f_1 == "---" ? false : exit_f_1 == "TRIX exit" ? trix_buy_x : exit_f_1 == "Reverse fractal exit" ? rev_dn_fr_buy : exit_f_1 == "MACD exit" ? macd_buy_x : exit_f_1 == "RSI50 exit" ? rsi_f_buy_x : exit_f_1 == "Fractals exit" ? fr_upx_x : exit_f_1 == "SuperTrend exit" ? sup_buy_x : exit_f_1 == "Parabolic SAR exit" ? psar_buy : exit_f_1 == "SMA exit" ? sma_buy_x : exit_f_1 == "ADX exit" ? adx_thres_f_x : exit_f_1 == "Cloud exit" ? kumo_buy_x : exit_f_1 == "Kijun exit" ? kijun_buy_x : false //long exit sell filter 1 options exit_filter_sell_1 = exit_f_1 == "---" ? false : exit_f_1 == "TRIX exit" ? trix_sell_x : exit_f_1 == "Reverse fractal exit" ? rev_up_fr_sell : exit_f_1 == "MACD exit" ? macd_sell_x : exit_f_1 == "RSI50 exit" ? rsi_f_sell_x : exit_f_1 == "Fractals exit" ? fr_dnx_x : exit_f_1 == "SuperTrend exit" ? sup_sell_x : exit_f_1 == "Parabolic SAR exit" ? psar_sell : exit_f_1 == "SMA exit" ? sma_sell_x : exit_f_1 == "ADX exit" ? adx_thres_f_x : exit_f_1 == "Cloud exit" ? kumo_sell_x : exit_f_1 == "Kijun exit" ? kijun_sell_x : false //short exit buy filter 2 options exit_filter_buy_2 = exit_f_2 == "---" ? false : exit_f_2 == "TRIX exit" ? trix_buy_x : exit_f_2 == "Reverse fractal exit" ? rev_dn_fr_buy : exit_f_2 == "MACD exit" ? macd_buy_x : exit_f_2 == "RSI50 exit" ? rsi_f_buy_x : exit_f_2 == "Fractals exit" ? fr_upx_x : exit_f_2 == "SuperTrend exit" ? sup_buy_x : exit_f_2 == "Parabolic SAR exit" ? psar_buy : exit_f_2 == "SMA exit" ? sma_buy_x : exit_f_2 == "ADX exit" ? adx_thres_f_x : exit_f_2 == "Cloud exit" ? kumo_buy_x : exit_f_2 == "Kijun exit" ? kijun_buy_x : false //long exit sell filter 2 options exit_filter_sell_2 = exit_f_2 == "---" ? false : exit_f_2 == "TRIX exit" ? trix_sell_x : exit_f_2 == "Reverse fractal exit" ? rev_up_fr_sell : exit_f_2 == "MACD exit" ? macd_sell_x : exit_f_2 == "RSI50 exit" ? rsi_f_sell_x : exit_f_2 == "Fractals exit" ? fr_dnx_x : exit_f_2 == "SuperTrend exit" ? sup_sell_x : exit_f_2 == "Parabolic SAR exit" ? psar_sell : exit_f_2 == "SMA exit" ? sma_sell_x : exit_f_2 == "ADX exit" ? adx_thres_f_x : exit_f_2 == "Cloud exit" ? kumo_sell_x : exit_f_2 == "Kijun exit" ? kijun_sell_x : false //--------------------- strategy entry --------------------- long = entry_type != "Short" short = entry_type != "Long" exit_long = exit_filter_sell_1 or exit_filter_sell_2 exit_short = exit_filter_buy_1 or exit_filter_buy_2 if backtest_period() if long strategy.entry("os_b", strategy.long, when = opt_sig_buy and entry_filter_buy_1 and entry_filter_buy_2 and not exit_long, comment= not backtest ? "BybitAPI(BTCUSD) { market(side=buy, amount=100); }" : na) strategy.entry("os_b", strategy.long, when = opt_sig_buy_2 and entry_filter_buy_1 and entry_filter_buy_2 and not exit_long, comment= not backtest ? "BybitAPI(BTCUSD) { market(side=buy, amount=100); }" : na) strategy.close("os_b", when = exit_long) if short strategy.entry("os_s",strategy.short, when = opt_sig_sell and entry_filter_sell_1 and entry_filter_sell_2 and not exit_short, comment= not backtest ? "BybitAPI(BTCUSD) { market(side=sell, amount=100); }" : na) strategy.entry("os_s",strategy.short, when = opt_sig_sell_2 and entry_filter_sell_1 and entry_filter_sell_2 and not exit_short, comment= not backtest ? "BybitAPI(BTCUSD) { market(side=sell, amount=100); }" : na) strategy.close("os_s", when = exit_short) // {{strategy.order.comment}} #bot - altert message