Pine Script v5 · Strategy
The Strategy - Ichimoku Kinko Hyo and more
A Pine Script v5 strategy built on Lowest or Highest (TKlength), Crossover (close, KJ) and Crossunder (close, KJ). It has 12 order rules, 4 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is 0.05 contracts and pays 0.075% commission. 75 settings; defaults include Position Entry-Direction Both, Repainting Allowed and Time Frame - 1st ENTRY SIGNAL Current.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does The Strategy - Ichimoku Kinko Hyo and more repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 8 of 8 trades.
- How did The Strategy - Ichimoku Kinko Hyo and more do on BTCUSDT 1D with default settings?
- +10.29%
- From 26 Jan 2024 to 21 Oct 2026, over 57 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- What alerts does The Strategy - Ichimoku Kinko Hyo and more have?
- 5
- BybitAPI(BTCUSD) { continue(if=positionShort); market(position= 0); } BybitAPI(BTCUSD) { wait(0.5s); market(side=buy, amount=' + str.tostring(lot_size) + '); } \n #bot; BybitAPI(BTCUSD) { continue(if=positionLong); market(position= 0); } BybitAPI(BTCUSD) { wait(0.5s); market(side=sell, amount=' + str.tostring(lot_size) + '); } \n #bot; BybitAPI(BTCUSD) { market(position= 0 %p); } \n #bot; BybitAPI(BTCUSD) { market(position=' + str.tostring(av_tp_qty_var) + '%p); } \n #bot; and more.
- Does The Strategy - Ichimoku Kinko Hyo and more run in Pine Script v6?
- Yes
- Same 57 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
- Does The Strategy - Ichimoku Kinko Hyo and more use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
BTCUSDT · 1D · default settings
- position_avg_price
- Winning trade
- Losing trade
- Equity
- Buy and hold
| Unrealized Profit/Loss: 809.13 |
- Net profit
- +10.29%
- $1,029.07
- Buy and hold
- +102.5%
- same period
- Closed trades
- 57
- 36 won · 21 lost
- Profitable
- 63.2%
- of closed trades
- Profit factor
- 1.27
- gross profit ÷ gross loss
- Max drawdown
- 16.61%
- −$1,726.41
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Likely bug
ta.crossunder(rsi_f, 50) ignores the settings line 326
Line 326 hard-codes 50 where line 375 uses “Exit ADX Threshold”. Changing those settings moves one band but not this one.
ta.crossunder(rsi_f, 50)ta.crossunder(rsi_f, adx_thres_x) -
Likely bug
ta.crossunder(rsi_f_x, 50) ignores the settings line 333
Line 333 hard-codes 50 where line 375 uses “Exit ADX Threshold”. Changing those settings moves one band but not this one.
ta.crossunder(rsi_f_x, 50)ta.crossunder(rsi_f_x, adx_thres_x) -
Likely bug
ta.rising(trix_f, 1) ignores the settings line 242
Line 242 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(trix_f, 1)ta.rising(trix_f, slope_len) -
Likely bug
ta.rising(trix_f, 1) ignores the settings line 242
Line 242 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(trix_f, 1)ta.rising(trix_f, slope_len) -
Likely bug
ta.rising(trix_f, 1) ignores the settings line 244
Line 244 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(trix_f, 1)ta.rising(trix_f, slope_len) -
Likely bug
ta.rising(trix_x, 1) ignores the settings line 245
Line 245 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(trix_x, 1)ta.rising(trix_x, slope_len) -
Likely bug
ta.rising(trix_x, 1) ignores the settings line 245
Line 245 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(trix_x, 1)ta.rising(trix_x, slope_len) -
Likely bug
ta.rising(hma_f, 1) ignores the settings line 266
Line 266 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(hma_f, 1)ta.rising(hma_f, slope_len) -
Likely bug
ta.rising(hma_f, 1) ignores the settings line 266
Line 266 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(hma_f, 1)ta.rising(hma_f, slope_len) -
Likely bug
ta.rising(hma_f, 1) ignores the settings line 268
Line 268 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(hma_f, 1)ta.rising(hma_f, slope_len) -
Likely bug
ta.rising(hma_x, 1) ignores the settings line 269
Line 269 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(hma_x, 1)ta.rising(hma_x, slope_len) -
Likely bug
ta.rising(hma_x, 1) ignores the settings line 269
Line 269 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(hma_x, 1)ta.rising(hma_x, slope_len) -
Likely bug
ta.rising(alma, 1) ignores the settings line 301
Line 301 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(alma, 1)ta.rising(alma, slope_len) -
Likely bug
ta.rising(alma, 1) ignores the settings line 301
Line 301 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(alma, 1)ta.rising(alma, slope_len) -
Likely bug
ta.rising(alma, 1) ignores the settings line 304
Line 304 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(alma, 1)ta.rising(alma, slope_len) -
Likely bug
ta.rising(adx_s, 1) ignores the settings line 379
Line 379 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(adx_s, 1)ta.rising(adx_s, slope_len) -
Likely bug
ta.rising(f_hma(15), 1) ignores the settings line 547
Line 547 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(f_hma(15),1)ta.rising(f_hma(15), slope_len) -
Likely bug
ta.rising(ta.alma(close, 9, 0.85, 6), 1) ignores the settings line 549
Line 549 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(ta.alma(close, 9, 0.85, 6),1)ta.rising(ta.alma(close, 9, 0.85, 6), slope_len) -
Likely bug
ta.rising(macdLine, 1) ignores the settings line 551
Line 551 hard-codes 1 where line 314 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.rising(macdLine, 1)ta.rising(macdLine, slope_len) -
Likely bug
ta.falling(trix_f, 1) ignores the settings line 243
Line 243 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(trix_f, 1)ta.falling(trix_f, slope_len) -
Likely bug
ta.falling(trix_f, 1) ignores the settings line 243
Line 243 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(trix_f, 1)ta.falling(trix_f, slope_len) -
Likely bug
ta.falling(trix_x, 1) ignores the settings line 246
Line 246 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(trix_x, 1)ta.falling(trix_x, slope_len) -
Likely bug
ta.falling(trix_x, 1) ignores the settings line 246
Line 246 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(trix_x, 1)ta.falling(trix_x, slope_len) -
Likely bug
ta.falling(hma_f, 1) ignores the settings line 267
Line 267 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(hma_f, 1)ta.falling(hma_f, slope_len) -
Likely bug
ta.falling(hma_f, 1) ignores the settings line 267
Line 267 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(hma_f, 1)ta.falling(hma_f, slope_len) -
Likely bug
ta.falling(hma_x, 1) ignores the settings line 270
Line 270 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(hma_x, 1)ta.falling(hma_x, slope_len) -
Likely bug
ta.falling(hma_x, 1) ignores the settings line 270
Line 270 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(hma_x, 1)ta.falling(hma_x, slope_len) -
Likely bug
ta.falling(alma, 1) ignores the settings line 302
Line 302 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(alma, 1)ta.falling(alma, slope_len) -
Likely bug
ta.falling(alma, 1) ignores the settings line 302
Line 302 hard-codes 1 where line 316 uses “MACD MacdlLine Slope Lenth”. Changing those settings moves one band but not this one.
ta.falling(alma, 1)ta.falling(alma, slope_len) -
Likely bug
ta.pivothigh(high, 3, 0) ignores the settings line 284
Line 284 hard-codes high where line 335 uses “Fractals Period” and 3 where line 335 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivothigh(high, 3, 0)ta.pivothigh(fr_period, fr_period, 0) -
Likely bug
ta.pivothigh(high, 4, 1) ignores the settings line 284
Line 284 hard-codes high where line 335 uses “Fractals Period” and 4 where line 335 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivothigh(high, 4, 1)ta.pivothigh(fr_period, fr_period, 1) -
Likely bug
ta.pivothigh(high, 4, 1) ignores the settings line 284
Line 284 hard-codes high where line 335 uses “Fractals Period” and 4 where line 335 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivothigh(high, 4, 1)ta.pivothigh(fr_period, fr_period, 1) -
Likely bug
ta.pivothigh(2, 2) ignores the settings line 402
Line 402 hard-codes 2 where line 335 uses “Fractals Period” and 2 where line 335 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivothigh(2, 2)ta.pivothigh(fr_period, fr_period) -
Likely bug
ta.pivothigh(high, p_bar_sens_2, 0) ignores the settings line 508
Line 508 hard-codes high where line 335 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivothigh(high, p_bar_sens_2, 0)ta.pivothigh(fr_period, p_bar_sens_2, 0) -
Likely bug
ta.pivotlow(low, 3, 0) ignores the settings line 285
Line 285 hard-codes low where line 336 uses “Fractals Period” and 3 where line 336 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivotlow(low, 3, 0)ta.pivotlow(fr_period, fr_period, 0) -
Likely bug
ta.pivotlow(low, 4, 1) ignores the settings line 285
Line 285 hard-codes low where line 336 uses “Fractals Period” and 4 where line 336 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivotlow(low, 4, 1)ta.pivotlow(fr_period, fr_period, 1) -
Likely bug
ta.pivotlow(low, 4, 1) ignores the settings line 285
Line 285 hard-codes low where line 336 uses “Fractals Period” and 4 where line 336 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivotlow(low, 4, 1)ta.pivotlow(fr_period, fr_period, 1) -
Likely bug
ta.pivotlow(2, 2) ignores the settings line 403
Line 403 hard-codes 2 where line 336 uses “Fractals Period” and 2 where line 336 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivotlow(2, 2)ta.pivotlow(fr_period, fr_period) -
Likely bug
ta.pivotlow(low, p_bar_sens_2, 0) ignores the settings line 509
Line 509 hard-codes low where line 336 uses “Fractals Period”. Changing those settings moves one band but not this one.
ta.pivotlow(low, p_bar_sens_2, 0)ta.pivotlow(fr_period, p_bar_sens_2, 0) -
Likely bug
ta.alma(close, 9, 0.85, 6) ignores the settings line 549
Line 549 hard-codes 9 where line 299 uses “ALMA Window Size” and 0.85 where line 299 uses “ALMA Offset” and 6 where line 299 uses “ALMA Sigma”. Changing those settings moves one band but not this one.
ta.alma(close, 9, 0.85, 6)ta.alma(close, windowsize, offset, sigma) -
Likely bug
ta.valuewhen(up_fr, high[fr_period], 0) ignores the settings line 337
Line 337 hard-codes 0 where line 348 uses “Exit Fractals - Past Fractal”. Changing those settings moves one band but not this one.
ta.valuewhen(up_fr, high[fr_period], 0)ta.valuewhen(up_fr, high[fr_period], fr_past_x) -
Likely bug
ta.valuewhen(dn_fr, low[fr_period], 0) ignores the settings line 338
Line 338 hard-codes 0 where line 348 uses “Exit Fractals - Past Fractal”. Changing those settings moves one band but not this one.
ta.valuewhen(dn_fr, low[fr_period], 0)ta.valuewhen(dn_fr, low[fr_period], fr_past_x) -
Likely bug
ta.valuewhen(up_w_fr, high[2], 1) ignores the settings line 404
Line 404 hard-codes 1 where line 348 uses “Exit Fractals - Past Fractal”. Changing those settings moves one band but not this one.
ta.valuewhen(up_w_fr, high[2], 1)ta.valuewhen(up_w_fr, high[2], fr_past_x) -
Likely bug
ta.valuewhen(up_w_fr, high[2], 0) ignores the settings line 405
Line 405 hard-codes 0 where line 348 uses “Exit Fractals - Past Fractal”. Changing those settings moves one band but not this one.
ta.valuewhen(up_w_fr, high[2], 0)ta.valuewhen(up_w_fr, high[2], fr_past_x) -
Likely bug
ta.valuewhen(dn_w_fr, low[2], 1) ignores the settings line 406
Line 406 hard-codes 1 where line 348 uses “Exit Fractals - Past Fractal”. Changing those settings moves one band but not this one.
ta.valuewhen(dn_w_fr, low[2], 1)ta.valuewhen(dn_w_fr, low[2], fr_past_x) -
Likely bug
ta.valuewhen(dn_w_fr, low[2], 0) ignores the settings line 407
Line 407 hard-codes 0 where line 348 uses “Exit Fractals - Past Fractal”. Changing those settings moves one band but not this one.
ta.valuewhen(dn_w_fr, low[2], 0)ta.valuewhen(dn_w_fr, low[2], fr_past_x) -
Likely bug
ta.supertrend(2, 5) ignores the settings line 535
Line 535 hard-codes 2 where line 354 uses “SuperTrend Multiplier” and 5 where line 354 uses “SuperTrend Length”. Changing those settings moves one band but not this one.
ta.supertrend(2, 5)ta.supertrend(mult, len) -
Likely bug
ta.dmi(7, 7) ignores the settings line 534
Line 534 hard-codes 7 where line 374 uses “Exit ADX Period” and 7 where line 374 uses “Exit ADX Smooth”. Changing those settings moves one band but not this one.
ta.dmi(7, 7)ta.dmi(di_length_x, adx_smooth_x) -
Likely bug
ta.atr(1) ignores the settings line 543
Line 543 hard-codes 1 where line 1162 uses “ATR Length”. Changing those settings moves one band but not this one.
ta.atr(1)ta.atr(atr_l) -
Check
1 setting does nothing
“General Description” is declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Note
2 settings have no label
In the settings dialog period_start (line 74), period_stop (line 75) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| General DescriptionThis script offers you the opportunity to backtest many signals and filters to compare the results. Make yourself familiar with the signals and the options and become creative ... At least you will be able to see what and on what circumstances works or not. Note the \'KISS\' principle and that \'context\' matters. The key feature of technical analysis is that every market participant is an interface to the world or market-environment and all market relevant information is visible in the chart. The default values are suitable for Bitcoin on ByBit (one tick = 0.5). Deselect \'Signal Labels\' at strategy properties -> Style to avoid signal label strings. | false | bool | unused |
| Position Entry-DirectionLong= long entries only, Short= short entries only, Both= long and short entries are possible. | Both | string · options ['Both', 'Long', 'Short'] | long short both |
| RepaintingIf repainting "Not allowed" is selected, then signals from higher time frames have a lag of an additional bar from the higher time frame but you trade what you have backtested. Otherwise singals can occure multiple times as long as the higher time frame bar is not closed but the first signal of these possible multiple signals is much earlier. | Allowed | string · options ['Not allowed', 'Allowed'] | entry_filter_buy_1 entry_filter_buy_11 entry_filter_sell_1 entry_filter_sell_11 entry_filter_buy_2 entry_filter_buy_22 entry_filter_sell_2 entry_filter_sell_22 exit_filter_buy_1 exit_filter_sig_buy_11 exit_filter_sell_1 exit_filter_sig_sell_11 exit_filter_buy_2 exit_filter_sig_buy_22 exit_filter_sell_2 exit_filter_sig_sell_22 opt_sig_buy_1 opt_sig_buy_11 opt_sig_sell_1 opt_sig_sell_11 opt_sig_buy_2 opt_sig_buy_22 opt_sig_sell_2 opt_sig_sell_22 line 716 |
| Plot Info PanelInfo panel for current unrealized profit or loss for the open position | true | bool | line 148 |
| Plot Position Avarage Price Line.This plots the position avarage price line. | true | bool | position_avg_price |
| Pyramiding ModeIf disabled: as long as the signal is valid a new trade can be opened on each bar (more filter sensitive). If not \'Both\' as direction is selected, the opposite signal closes the current position. If enabled: a new trade is opened with every signal. Use Properties -> Pyramiding to increase the maximum amount of orders. | false | bool | kijun_buy kumo_buy kumo_flip_buy chikou_X_price_buy chikou_X_kumo_buy price_X_tenkan_buy tenkan_X_kumo_buy tenkan_X_kijun_buy kijun_sell kumo_sell kumo_flip_sell chikou_X_price_sell chikou_X_kumo_sell price_X_tenkan_sell tenkan_X_kumo_sell tenkan_X_kijun_sell rsi_f_buy rsi_f_sell fr_upx fr_dnx sup_buy sup_sell psar_buy psar_sell long_1 short_1 long_2 short_2 sma_buy sma_sell buy_up_line sell_dn_line long_c short_c long_pic short_pic entry os_b close os_b close os_b entry os_s close os_s close os_s line 1201 line 1205 line 1208 line 1218 line 1220 line 1222 line 1230 line 1234 line 1237 line 1238 line 1240 line 1241 |
| entry signals: | |||
| Time Frame - 1st ENTRY SIGNALChoose always a higher time frame than the current. Lower time frames than the current may result in false values. | Current | string · options ['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'] | opt_sig_buy_1 opt_sig_sell_1 |
| Time Frame - 2nd ENTRY SIGNALChoose always a higher time frame than the current. Lower time frames than the current may result in false values. | Current | string · options ['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'] | opt_sig_buy_2 opt_sig_sell_2 |
| --- 1st ENTRY SIGNAL ---Various entry signals. 1st ENTRY SIGNAL and 2nd ENTRY SIGNAL are OR connected. | Price X Kumo sig | string · options ['---', 'Fractals trend lines sig (no tf filter)', 'Segments sig (no tf filter)', 'DMI ADX classic sig', 'DMI ADX mod sig', 'DMI ADX-slope sig', 'EMA1 x EMA2 sig', 'TRIX slope sig', 'ALMA slope sig', 'MACD(fast) slope sig', 'HMA slope sig', 'Grid - reentry sig (no tf filter)', 'Grid - counter trend sig (no tf filter)', 'Pin bar sig', 'Inside bar sig', 'Outside bar sig', 'Sandwich bar sig', 'Bar breakout 1 sig', 'Bar breakout 2 sig', 'Higher-low/lower-high bar sig', 'Entry on every bar-open sig', 'Fractals sig', 'Reverse fractal sig', 'SMA sig', 'RSI50 sig', 'Parabolic SAR sig', 'SuperTrend sig', 'Price X Kijun sig', 'Price X Kumo sig', 'Kumo flip sig', 'Chikou X price sig', 'Chikou X Kumo sig', 'Price X Tenkan sig', 'Tenkan X Kumo sig', 'Tenkan X Kijun sig', 'CB/CS sig (no tf filter)', 'IB/IS sig (no tf filter)', 'B1/S1 sig', 'B2/S2 sig'] | entry_opt_sig_buy_1 entry_opt_sig_sell_1 opt_sig_buy_11 opt_sig_sell_11 |
| --- 2nd ENTRY SIGNAL --- (Enable Pyramiding Mode)Various entry signals. Signal 1 and signal 2 are OR connected. Works with pyramiding mode only | --- | string · options ['---', 'Fractals trend lines sig (no tf filter)', 'Segments sig (no tf filter)', 'DMI ADX classic sig', 'DMI ADX mod sig', 'DMI ADX-slope sig', 'EMA1 x EMA2 sig', 'TRIX slope sig', 'ALMA slope sig', 'MACD(fast) slope sig', 'HMA slope sig', 'Grid - reentry sig (no tf filter)', 'Grid - counter trend sig (no tf filter)', 'Pin bar sig', 'Inside bar sig', 'Outside bar sig', 'Sandwich bar sig', 'Bar breakout 1 sig', 'Bar breakout 2 sig', 'Higher-low/lower-high bar sig', 'Entry on every bar-open sig', 'Fractals sig', 'Reverse fractal sig', 'SMA sig', 'RSI50 sig', 'Parabolic SAR sig', 'SuperTrend sig', 'Price X Kijun sig', 'Price X Kumo sig', 'Kumo flip sig', 'Chikou X price sig', 'Chikou X Kumo sig', 'Price X Tenkan sig', 'Tenkan X Kumo sig', 'Tenkan X Kijun sig', 'CB/CS sig (no tf filter)', 'IB/IS sig (no tf filter)', 'B1/S1 sig', 'B2/S2 sig'] | entry_opt_sig_buy_2 entry_opt_sig_sell_2 opt_sig_buy_22 opt_sig_sell_22 |
| Entry filters: | |||
| Time Frame - Entry Filter 1The time frame for the 1st ENTRY SIGNAL filter. Choose always a higher time frame than the current. Lower time frames than the current may result in false values. | Current | string · options ['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'] | entry_filter_buy_1 entry_filter_sell_1 |
| Time Frame - Entry Filter 2The time frame for the 2st ENTRY SIGNAL filter. Choose always a higher time frame than the current. Lower time frames than the current may result in false values. | Current | string · options ['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'] | entry_filter_buy_2 entry_filter_sell_2 |
| Entry Filter 1Various entry filter signals. Entry filter 1 and Entry filter 2 are AND connected. | --- | string · options ['---', 'Fractals trend lines filter (no tf filter)', 'Bar breakout 1 filter', 'Bar breakout 2 filter', 'SMA filter', 'MACD filter', 'EMA1 x EMA2 filter', 'RSI Stochastic filter', 'TRIX slope filter', 'ALMA slope filter','HMA slope filter', 'MACD(fast) slope filter', 'RSI50 filter', 'Segments filter (no tf filter)', 'Reverse fractal filter', 'Fractals filter', 'SuperTrend filter', 'Parabolic SAR filter', 'ADX Threshold filter', 'DMI filter', 'Price X Kumo filter', 'Price X Kijun filter', 'Kumo flip filter', 'Price filtered Kumo flip filter (no tf filter)', 'Chikou X price filter', 'Chikou X Kumo filter', 'Price X Tenkan filter', 'Tenkan X Kumo filter', 'Tenkan X Kijun filter', 'B1/S1 sig', 'B2/S2 sig', 'IB/IS sig (no tf filter)'] | entry_filter_sig_buy_1 entry_filter_sig_sell_1 entry_filter_buy_11 entry_filter_sell_11 |
| Entry Filter 2Various entry filter signals. Filter 1 and filter 2 are AND connected. | --- | string · options ['---', 'Fractals trend lines filter (no tf filter)', 'Bar breakout 1 filter', 'Bar breakout 2 filter', 'SMA filter', 'MACD filter', 'EMA1 x EMA2 filter', 'RSI Stochastic filter', 'TRIX slope filter', 'ALMA slope filter','HMA slope filter', 'MACD(fast) slope filter', 'RSI50 filter', 'Segments filter (no tf filter)', 'Reverse fractal filter', 'Fractals filter', 'SuperTrend filter', 'Parabolic SAR filter', 'ADX Threshold filter', 'DMI filter', 'Price X Kumo filter', 'Price X Kijun filter', 'Kumo flip filter', 'Price filtered Kumo flip filter (no tf filter)', 'Chikou X price filter', 'Chikou X Kumo filter', 'Price X Tenkan filter', 'Tenkan X Kumo filter', 'Tenkan X Kijun filter', 'B1/S1 sig', 'B2/S2 sig', 'IB/IS sig (no tf filter)'] | entry_filter_sig_buy_2 entry_filter_sig_sell_2 entry_filter_buy_22 entry_filter_sell_22 |
| exit filters: | |||
| Time Frame - Exit Filter 1Choose always a higher time frame than the current. Lower time frames than the current may result in false values. | Current | string · options ['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'] | exit_filter_buy_1 exit_filter_sell_1 |
| Time Frame - Exit Filter 2Choose always a higher time frame than the current. Lower time frames than the current may result in false values. | Current | string · options ['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'] | exit_filter_buy_2 exit_filter_sell_2 |
| Exit Filter 1Some exit filter signals. Exit filter 1 and Exit filter 2 are OR connected. | --- | string · options ['---', 'Reverse bar exit', 'Reverse fractal exit', 'Bar breakout 2 exit', 'SMA exit', 'MACD exit', 'MACD(fast) slope exit', 'RSI50 exit', 'RSI Stochastic exit', 'TRIX slope exit', 'HMA slope exit', 'EMA1 x EMA2 exit', 'Fractals exit', 'SuperTrend exit', 'Parabolic SAR exit', 'ADX Threshold exit', 'Cloud exit', 'Kijun exit', 'IB/IS exit (no tf filter)'] | exit_filter_sig_buy_1 exit_filter_sig_sell_1 exit_filter_sig_buy_11 exit_filter_sig_sell_11 |
| Exit Filter 2Some exit filter signals. Exit filter 1 and Exit filter 2 are OR connected. | --- | string · options ['---', 'Reverse bar exit', 'Reverse fractal exit', 'Bar breakout 2 exit', 'SMA exit', 'MACD exit', 'MACD(fast) slope exit', 'RSI50 exit', 'RSI Stochastic exit', 'TRIX slope exit', 'HMA slope exit', 'EMA1 x EMA2 exit', 'Fractals exit', 'SuperTrend exit', 'Parabolic SAR exit', 'ADX Threshold exit', 'Cloud exit', 'Kijun exit', 'IB/IS exit (no tf filter)'] | exit_filter_sig_buy_2 exit_filter_sig_sell_2 exit_filter_sig_buy_22 exit_filter_sig_sell_22 |
| Live trading Parameter (does not affect backtesting): | |||
| Lot SizeAlertatron lot size string for Bybit exchange. Affects live trading only. | 300 | int · min 1 · step 100 | alert |
| Grid parameter: | |||
| Grid Gap - Base CurrencyThe minimum trigger-gap between two trades in case of a selected grid signal. | 500 | float · min 1 · step 50 | re_grid |
| Define the backtest period or start of trend: | |||
| Period start (no label in the script)Backtest period start. | timestamp('13 Mar 2020 00:00 +0000') | time | line 154 |
| Period stop (no label in the script)Backtest period end. | timestamp('31 Dec 2120 00:00 +0000') | time | line 154 |
| Take profit based on average position price: | |||
| Enable take Profit - Average Position Price ProfitProfit taking condition: current price >= average position price of positions + ATR | true | bool | close os_b close os_s line 1210 line 1224 line 1246 line 1247 |
| Take Average Position Price Profit - Quantity Of Position (Percent)Reduction of the current position in percent. | 10 | float · min 1 · max 100 · step 5 | av_tp_qty_var close os_b close os_s |
| ATR LengthATR length for profit and step calculation | 50 | int · min 0 · step 5 | atr_sec |
| ATR Time FrameATR time frame for profit and step calculation | W | string · options ['60', '120', '240', '480', '960', 'D', '3D', 'W', 'M'] | atr_sec |
| ATR FactorATR factor to increase/decrease ATR for profit and step calculation | 1 | float · min 0 · step 0.1 | atr_calc |
| Stop loss based on average position price: | |||
| Enable Stop Loss - Average Position Price LossStop loss condition: current price <= average position price of positions - \'Stop average-entry loss...\' AND current price <= average position price of positions - \'Stop loss step...\' | true | bool | close os_b close os_s line 1213 line 1226 line 1250 line 1251 |
| Stop Average Position Price Loss - Quantity Of Position (Percent)Reduction of the current position in percent. | 50 | float · min 0 · max 100 · step 5 | av_sl_qty_var close os_b close os_s |
| ATR LengthATR length for loss and step calculation | 50 | int · min 0 · step 5 | atr_sec_l |
| ATR Time FrameATR time frame for loss and step calculation | W | string · options ['60', '120', '240', '480', '960', 'D', '3D', 'W', 'M'] | atr_sec_l |
| ATR FactorATR factor to increase/decrease ATR for loss and step calculation | 1 | float · min 0 · step 0.1 | atr_calc_l |
| Confluence signal offsets: | |||
| CB/CS Signal OffsetDecreasing this parameter increases the sensitivity of the signal. | 2 | float · min -6 · max 9 · step 1 | long_c short_c |
| IB/IS Signal OffsetDecreasing this parameter increases the sensitivity of the signal. | 0 | float · min -5 · max 4 · step 1 | long_pic short_pic |
| Shared filter and entry signal parameters: | |||
| Segment Max Bars | 10 | int · min 0 · step 1 | line 452 line 457 line 462 line 476 line 481 line 486 |
| Pin Bar Sensitivity 1Condition: candle wick > candle body * \'Pin bar sensitivity\' . The smaller the factor, the more wicks are detected as part of a pin bar. | 0.6 | float · step 0.02 | pin_up_def pin_dn_def |
| Pin Bar Sensitivity 2Condition: high/low >< last two high/low\'. | 1 | int · min 1 · step 1 | pivot_up pivot_dn |
| Fractals Period | 2 | int · min 1 | up_fr dn_fr fractal_up_v fractal_dn_v |
| RSI Period | 14 | int · min 1 | rsi_f |
| SMA Period | 50 | int · min 1 · step 5 | sma_buy sma_sell sma_buy_f sma_sell_f |
| SuperTrend Multiplier | 3 | float · min 1 · step 0.2 | SuperTrend Dir |
| SuperTrend Length | 6 | int · min 1 | SuperTrend Dir |
| ADX DI Length | 10 | int · min 1 | diplus_s diminus_s adx_s |
| ADX Smooth | 10 | int · min 1 | diplus_s diminus_s adx_s |
| ADX Threshold | 25 | int · min 1 · step 2 | adx_above_thres long_2 short_2 |
| ALMA Window Size | 9 | int · min 1 · step 1 | alma |
| ALMA Offset | 0.85 | float · min 0 · step 0.05 | alma |
| ALMA Sigma | 6 | float · min 1 · step 1 | alma |
| MACD MacdlLine Slope LenthMACD\'s fast line | 1 | int · min 1 | macd_slope_up_e macd_slope_dn_e macd_slope_up_f |
| HMA Length | 100 | int · min 1 · step 5 | hma_f |
| EMA1 Length | 10 | int · min 1 · step 2 | ema1_f |
| EMA2 Length | 20 | int · min 1 · step 2 | ema2_f |
| RSI-Stoch K-lineRSI Stochastic\'s fast line | 3 | int · min 1 | k_f |
| RSI-Stoch D-lineRSI Stochastic\'s slow line | 3 | int · min 1 | d_f |
| RSI-Stoch Stochastic Length | 14 | int · min 1 | k_f |
| RSI-Stoch RSI Length | 14 | int · min 1 | rsi_rs_f |
| TRIX Length | 10 | int · min 1 | trix_f |
| Exit filter Parameters: | |||
| Exit Fractals - Period | 2 | int · min 1 | up_fr_x dn_fr_x fractal_up_v_x fractal_dn_v_x |
| Exit Fractals - Past Fractal | 0 | int · min 0 | fractal_up_v_x fractal_dn_v_x |
| Exit RSI Period | 14 | int · min 1 | rsi_f_x |
| Exit SMA Period | 50 | int · min 1 · step 5 | sma_buy_x sma_sell_x |
| Exit SuperTrend Multiplier | 2 | float · min 1 | SuperTrend_x Dir_x |
| Exit SuperTrend Length | 5 | int · min 1 | SuperTrend_x Dir_x |
| Exit ADX Period | 10 | int · min 1 | diplus_f_x diminus_f_X adx_f_x |
| Exit ADX Smooth | 10 | int · min 1 | diplus_f_x diminus_f_X adx_f_x |
| Exit ADX Threshold | 25 | int · min 1 · step 2 | adx_thres_f_x |
| Exit MACD MacdlLine Slope LenthMACD\'s fast line | 1 | int · min 1 | macd_slope_up_x macd_slope_dn_x |
| Exit HMA Length | 100 | int · min 1 · step 5 | hma_x |
| Exit EMA1 Length | 10 | int · min 1 · step 2 | ema1_x |
| Exit EMA2 Length | 20 | int · min 1 · step 2 | ema2_x |
| Exit RSI-Stoch K-lineRSI Stochastic\'s fast line | 3 | int · min 1 | k_x |
| Exit RSI-Stoch D-lineRSI Stochastic\'s slow line | 3 | int · min 1 | d_x |
| Exit RSI-Stoch Stochastic Length | 14 | int · min 1 | k_x |
| Exit RSI-Stoch RSI Length | 14 | int · min 1 | rsi_rs_x |
| Exit TRIX Length | 10 | int · min 1 | trix_x |
What it calculates
- Lowest / HighestTKlength
TK · line 162 - Lowest / HighestKJlength
KJ · line 163 - Lowest / HighestSBlength
SB · line 165 - Crossoverclose, KJ
kijun_buy · line 179 - Crossoverclose, kumo_high
kumo_buy · line 180 - CrossoverSA, SB
kumo_flip_buy · line 181 - CrossoverCS, high[26 - 1]
chikou_X_price_buy · line 182 - CrossoverCS, kumo_high[26 - 1]
chikou_X_kumo_buy · line 183 - Crossoverclose, TK
price_X_tenkan_buy · line 184 - CrossoverTK, kumo_high
tenkan_X_kumo_buy · line 185 - CrossoverTK, KJ
tenkan_X_kijun_buy · line 186 - Crossunderclose, KJ
kijun_sell · line 187 - Crossunderclose, kumo_low
kumo_sell · line 188 - CrossunderSA, SB
kumo_flip_sell · line 189 - CrossunderCS, low[26 - 1]
chikou_X_price_sell · line 190 - CrossunderCS, kumo_low[26 - 1]
chikou_X_kumo_sell · line 191 - Crossunderclose, TK
price_X_tenkan_sell · line 192 - CrossunderTK, kumo_low
tenkan_X_kumo_sell · line 193 - CrossunderTK, KJ
tenkan_X_kijun_sell · line 194 - Crossoverhigh, KJ
kijun_buy_x · line 215 - Crossunderlow, KJ
kijun_sell_x · line 216 - Crossoverhigh, kumo_high
kumo_buy_x · line 217 - Crossunderlow, kumo_low
kumo_sell_x · line 218 - Risingtrix_f, 1
trix_slo_up_f · line 244 - RSIclose, RSI-Stoch RSI Length (14)
rsi_rs_f · line 249 - SMA / Stochta.stoch(rsi_rs_f, rsi_rs_f, rsi_rs_f, stoch_length_f), RSI-Stoch K-line (3)
k_f · line 250 - SMAk_f, RSI-Stoch D-line (3)
d_f · line 251 - RSIclose, Exit RSI-Stoch RSI Length (14)
rsi_rs_x · line 256 - SMA / Stochta.stoch(rsi_rs_x, rsi_rs_x, rsi_rs_x, stoch_length_x), Exit RSI-Stoch K-line (3)
k_x · line 257 - SMAk_x, Exit RSI-Stoch D-line (3)
d_x · line 258 - Risinghma_f, 1
hma_up_f · line 268 - Crossoverema1_f, ema2_f
ema_1x2_buy_s · line 293 - Crossunderema1_f, ema2_f
ema_1x2_sell_s · line 294 - Crossoverema1_x, ema2_x
ema_1x2_buy_x · line 296 - Crossunderema1_x, ema2_x
ema_1x2_sell_x · line 297 - ALMAclose, ALMA Window Size (9), ALMA Offset (0.85), ALMA Sigma (6)
alma · line 299 - Risingalma, 1
alma_slo_up_f · line 304 - MACDclose, 12, 26, 9
macdLine_f · line 306 - MACDclose, 12, 26, 9
signalLine_f · line 306 - MACDclose, 12, 26, 9
histLine_f · line 306 - CrossovermacdLine_f, signalLine_f
macd_buy_x · line 311 - CrossundermacdLine_f, signalLine_f
macd_sell_x · line 312 - RisingmacdLine_f, MACD MacdlLine Slope Lenth (1)
macd_slope_up_f · line 318 - Crossoverrsi_f, 50
rsi_f_buy · line 325 - Crossunderrsi_f, 50
rsi_f_sell · line 326 - Crossoverrsi_f_x, 50
rsi_f_buy_x · line 332 - Crossunderrsi_f_x, 50
rsi_f_sell_x · line 333 - PivothighFractals Period (2), Fractals Period (2)
up_fr · line 335 - PivotlowFractals Period (2), Fractals Period (2)
dn_fr · line 336 - Valuewhenup_fr, high[fr_period], 0
fractal_up_v · line 337 - Valuewhendn_fr, low[fr_period], 0
fractal_dn_v · line 338 - Crossoverhigh, fractal_up_v
fr_upx · line 340 - Crossunderlow, fractal_dn_v
fr_dnx · line 341 - PivothighExit Fractals - Period (2), Exit Fractals - Period (2)
up_fr_x · line 346 - PivotlowExit Fractals - Period (2), Exit Fractals - Period (2)
dn_fr_x · line 347 - Valuewhenup_fr_x, high[fr_period_x], Exit Fractals - Past Fractal (0)
fractal_up_v_x · line 348 - Valuewhendn_fr_x, low[fr_period_x], Exit Fractals - Past Fractal (0)
fractal_dn_v_x · line 349 - Crossoverhigh, fractal_up_v_x
fr_upx_x · line 350 - Crossunderlow, fractal_dn_v_x
fr_dnx_x · line 351 - SupertrendSuperTrend Multiplier (3), SuperTrend Length (6)
SuperTrend · line 354 - SupertrendSuperTrend Multiplier (3), SuperTrend Length (6)
Dir · line 354 - Crossoverhigh, SuperTrend
sup_buy · line 355 - Crossunderlow, SuperTrend
sup_sell · line 356 - SupertrendExit SuperTrend Multiplier (2), Exit SuperTrend Length (5)
SuperTrend_x · line 361 - SupertrendExit SuperTrend Multiplier (2), Exit SuperTrend Length (5)
Dir_x · line 361 - Crossoverhigh, SuperTrend_x
sup_buy_x · line 362 - Crossunderlow, SuperTrend_x
sup_sell_x · line 363 - Crossover / SARhigh, ta.sar(start, inc, max)[0]
psar_buy · line 365 - Crossunder / SARlow, ta.sar(start, inc, max)[0]
psar_sell · line 366 - Crossover / SARhigh, ta.sar(start, inc, max)[0]
psar_buy_x · line 370 - Crossunder / SARlow, ta.sar(start, inc, max)[0]
psar_sell_x · line 371 - DMIExit ADX Period (10), Exit ADX Smooth (10)
diplus_f_x · line 374 - DMIExit ADX Period (10), Exit ADX Smooth (10)
diminus_f_X · line 374 - DMIExit ADX Period (10), Exit ADX Smooth (10)
adx_f_x · line 374 - Crossunderadx_f_x, Exit ADX Threshold (25)
adx_thres_f_x · line 375 - DMIADX DI Length (10), ADX Smooth (10)
diplus_s · line 377 - DMIADX DI Length (10), ADX Smooth (10)
diminus_s · line 377 - DMIADX DI Length (10), ADX Smooth (10)
adx_s · line 377 - Risingadx_s, 1
adx_slope_up · line 379 - Crossoverdiplus_s, diminus_s
long_1 · line 384 - Crossunderdiplus_s, diminus_s
short_1 · line 385 - Crossoverdiplus_s, diminus_s
long_2 · line 386 - Crossunderdiplus_s, diminus_s
short_2 · line 387 - Crossoverclose[1], f_sma(ma_period)
sma_buy · line 393 - Crossunderclose[1], f_sma(ma_period)
sma_sell · line 394 - Crossoverclose[1], f_sma(ma_period_x)
sma_buy_x · line 399 - Crossunderclose[1], f_sma(ma_period_x)
sma_sell_x · line 400 - Pivothigh2, 2
up_w_fr · line 402 - Pivotlow2, 2
dn_w_fr · line 403 - Valuewhenup_w_fr, high[2], 1
y1_frup_1 · line 404 - Valuewhenup_w_fr, high[2], 0
y0_frup_0 · line 405 - Valuewhendn_w_fr, low[2], 1
y1_frdn_1 · line 406 - Valuewhendn_w_fr, low[2], 0
y0_frdn_0 · line 407 - Crossoverhigh, y_up_lvl
buy_up_line · line 439 - Crossunderlow, y_dn_lvl
sell_dn_line · line 440 - Pivothighhigh, Pin Bar Sensitivity 2 (1), 0
pivot_up · line 508 - Pivotlowlow, Pin Bar Sensitivity 2 (1), 0
pivot_dn · line 509 - MACDclose, 12, 26, 9
macdLine · line 532 - MACDclose, 12, 26, 9
signalLine · line 532 - MACDclose, 12, 26, 9
histLine · line 532 - DMI7, 7
diplus · line 534 - DMI7, 7
diminus · line 534 - DMI7, 7
adx · line 534 - Supertrend2, 5
superTrend · line 535 - Supertrend2, 5
dir · line 535 - Changehlc3
sv · line 537 - EMAsv, 34
kvo · line 538 - EMAkvo, 13
sig · line 539 - ATR1
STR · line 543 - Risingf_hma(15), 1
hma_slo_up · line 547 - Rising / ALMAta.alma(close, 9, 0.85, 6), 1
alma_slo_up · line 549 - RisingmacdLine, 1
macd_slo_up · line 551 - Crossoverbs_conf_sig, (long_short_trig + trig_gap_cbcs)
long_c · line 650 - Crossunderbs_conf_sig, (long_short_trig - trig_gap_cbcs)
short_c · line 651 - Crossoverbs_pic_sig, pic_l_s_trig + trig_gap_ibis
long_pic · line 711 - Crossunderbs_pic_sig, pic_l_s_trig - trig_gap_ibis
short_pic · line 712 - ATRATR Length (50) · chosen by ATR Time Frame
atr_sec · line 1162 - ATRATR Length (50) · chosen by ATR Time Frame
atr_sec_l · line 1171
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
The script has 344 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open os_b long | entry_long_1 | On | 1200 |
| Open os_b long | one_side_pyr and entry_long_2 | On | 1202 |
| Close os_b | not both and not one_side_pyr ? exit_long_2 : exit_long_1 | On | 1206 |
| Close os_b | not both and one_side_pyr ? exit_long_1 and not exit_long_1[1] : na | On | 1209 |
| Close os_b | av_tp_en and av_profit_l | On | 1211 |
| Close os_b | sl_en and sl_t_l | On | 1214 |
| Open os_s short | entry_short_1 | On | 1217 |
| Open os_s short | one_side_pyr and entry_short_2 | On | 1219 |
| Close os_s | not both and not one_side_pyr ? exit_short_2 : exit_short_1 | On | 1221 |
| Close os_s | not both and one_side_pyr ? exit_short_1 and not exit_short_1[1] : na | On | 1223 |
| Close os_s | av_tp_en and av_profit_s | On | 1225 |
| Close os_s | sl_en and sl_t_s | On | 1227 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| (no title) | alert | BybitAPI(BTCUSD) { continue(if=positionShort); market(position= 0); } BybitAPI(BTCUSD) { wait(0.5s); market(side=buy, amount=' + str.tostring(lot_size) + '); } \n #bot | 1231 |
| (no title) | alert | BybitAPI(BTCUSD) { continue(if=positionLong); market(position= 0); } BybitAPI(BTCUSD) { wait(0.5s); market(side=sell, amount=' + str.tostring(lot_size) + '); } \n #bot | 1235 |
| (no title) | alert | BybitAPI(BTCUSD) { market(position= 0 %p); } \n #bot | 1243 |
| (no title) | alert | BybitAPI(BTCUSD) { market(position=' + str.tostring(av_tp_qty_var) + '%p); } \n #bot | 1249 |
| (no title) | alert | BybitAPI(BTCUSD) { market(position=' + str.tostring(av_sl_qty_var) + '%p); } \n #bot | 1253 |
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- ClearHigher-timeframe data3 request.security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +10.3% | +102.5% | 57 | 63% | 1.27 | 16.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +5.2% | +5.5% | 22 | 50% | 1.53 | 5.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.9% | +9.8% | 43 | 67% | 1.46 | 0.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 30 | 23% | 0.99 | 0.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 49 | 55% | 1.02 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 20 | 35% | 2.03 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.3% | +148.3% | 55 | 76% | 2.52 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.1% | +17.1% | 34 | 21% | 0.42 | 0.1% | 8 May 2026 – 21 Oct 2026 |
Higher-timeframe data for request.security(): BINANCE:BTCUSDT W (Binance BTCUSDT 1w), fetched from Binance's public market data for each market.
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 15 | 47% | −$785.90 |
| Sideways market | 39 | 69% | $1,232.77 |
| Falling market | 3 | 67% | $584.16 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
17.1%
The 95th percentile of the worst drawdown when the same 57 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 7.5% to 17.1%; the tick is what actually happened, 15.8%. Order luck alone moves it this much.
All 57 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 12 Apr 2024 70,006.20 | 14 Apr 2024 63,924.50 | 2 | −$154.55 |
| long | 12 Apr 2024 70,006.20 | 18 Apr 2024 61,277.40 | 6 | −$110.34 |
| long | 12 Apr 2024 70,006.20 | 1 May 2024 60,672.00 | 19 | −$58.95 |
| long | 12 Apr 2024 70,006.20 | 1 May 2024 60,672.00 | 19 | −$58.95 |
| short | 1 May 2024 60,672.00 | 18 May 2024 67,024.00 | 17 | −$322.39 |
| long | 18 May 2024 67,024.00 | 21 May 2024 71,446.60 | 3 | $21.59 |
| long | 18 May 2024 67,024.00 | 22 Jun 2024 64,143.60 | 35 | −$134.05 |
| short | 22 Jun 2024 64,143.60 | 6 Jul 2024 56,628.80 | 14 | $37.12 |
| short | 22 Jun 2024 64,143.60 | 20 Jul 2024 66,660.00 | 28 | −$117.66 |
| long | 20 Jul 2024 66,660.00 | 3 Aug 2024 61,498.30 | 14 | −$131.44 |
| long | 20 Jul 2024 66,660.00 | 5 Aug 2024 58,161.00 | 16 | −$214.82 |
| short | 5 Aug 2024 58,161.00 | 24 Aug 2024 64,037.20 | 19 | −$149.20 |
| short | 5 Aug 2024 58,161.00 | 14 Sep 2024 60,498.00 | 40 | −$60.65 |
| long | 14 Sep 2024 60,498.00 | 16 Sep 2024 59,132.00 | 2 | −$72.79 |
| short | 16 Sep 2024 59,132.00 | 18 Sep 2024 60,314.00 | 2 | −$63.58 |
| long | 18 Sep 2024 60,314.00 | 15 Oct 2024 66,084.00 | 27 | $28.38 |
| long | 18 Sep 2024 60,314.00 | 30 Oct 2024 72,736.40 | 42 | $55.45 |
| long | 18 Sep 2024 60,314.00 | 7 Nov 2024 75,572.00 | 50 | $61.38 |
| long | 18 Sep 2024 60,314.00 | 11 Nov 2024 80,370.00 | 54 | $72.72 |
| long | 18 Sep 2024 60,314.00 | 12 Nov 2024 88,648.00 | 55 | $92.58 |
| long | 18 Sep 2024 60,314.00 | 21 Nov 2024 94,286.60 | 64 | $99.96 |
| long | 18 Sep 2024 60,314.00 | 6 Dec 2024 96,945.60 | 79 | $97.02 |
| long | 18 Sep 2024 60,314.00 | 16 Dec 2024 104,464.00 | 89 | $105.29 |
| long | 18 Sep 2024 60,314.00 | 16 Jan 2025 100,497.00 | 120 | $86.23 |
| long | 18 Sep 2024 60,314.00 | 21 Jan 2025 102,260.00 | 125 | $81.02 |
| long | 18 Sep 2024 60,314.00 | 3 Feb 2025 97,700.60 | 138 | $649.73 |
| short | 3 Feb 2025 97,700.60 | 4 Feb 2025 101,329.00 | 1 | −$188.86 |
| long | 4 Feb 2025 101,329.00 | 5 Feb 2025 97,763.10 | 1 | −$185.73 |
| short | 5 Feb 2025 97,763.10 | 26 Feb 2025 88,680.40 | 21 | $44.71 |
| short | 5 Feb 2025 97,763.10 | 1 Mar 2025 84,349.90 | 24 | $59.74 |
| short | 5 Feb 2025 97,763.10 | 4 Mar 2025 86,221.20 | 27 | $46.19 |
| short | 5 Feb 2025 97,763.10 | 11 Mar 2025 78,595.90 | 34 | $69.38 |
| short | 5 Feb 2025 97,763.10 | 7 Apr 2025 78,430.00 | 61 | $62.99 |
| short | 5 Feb 2025 97,763.10 | 23 Apr 2025 93,443.00 | 77 | $123.32 |
| long | 23 Apr 2025 93,443.00 | 9 May 2025 103,262.00 | 16 | $48.36 |
| long | 23 Apr 2025 93,443.00 | 22 May 2025 109,644.00 | 29 | $72.22 |
| long | 23 Apr 2025 93,443.00 | 10 Jun 2025 110,263.00 | 48 | $67.50 |
| long | 23 Apr 2025 93,443.00 | 30 Jun 2025 108,357.00 | 68 | $53.81 |
| long | 23 Apr 2025 93,443.00 | 11 Jul 2025 116,010.00 | 79 | $73.52 |
| long | 23 Apr 2025 93,443.00 | 14 Aug 2025 123,306.00 | 113 | $87.69 |
| long | 23 Apr 2025 93,443.00 | 26 Aug 2025 110,112.00 | 125 | $438.87 |
| short | 26 Aug 2025 110,112.00 | 19 Sep 2025 117,074.00 | 24 | −$356.60 |
| long | 19 Sep 2025 117,074.00 | 23 Sep 2025 112,651.00 | 4 | −$229.74 |
| short | 23 Sep 2025 112,651.00 | 2 Oct 2025 118,595.00 | 9 | −$305.87 |
| long | 2 Oct 2025 118,595.00 | 11 Oct 2025 112,774.00 | 9 | −$299.70 |
| short | 11 Oct 2025 112,774.00 | 5 Nov 2025 101,497.00 | 25 | $55.58 |
| short | 11 Oct 2025 112,774.00 | 17 Nov 2025 94,261.40 | 37 | $82.61 |
| short | 11 Oct 2025 112,774.00 | 21 Nov 2025 86,637.20 | 41 | $105.25 |
| short | 11 Oct 2025 112,774.00 | 15 Jan 2026 96,951.80 | 96 | $571.00 |
| long | 15 Jan 2026 96,951.80 | 26 Jan 2026 86,670.40 | 11 | −$520.96 |
| short | 26 Jan 2026 86,670.40 | 6 Feb 2026 62,909.90 | 11 | $118.24 |
| short | 26 Jan 2026 86,670.40 | 16 Apr 2026 74,810.00 | 80 | $528.27 |
| long | 16 Apr 2026 74,810.00 | 1 Jun 2026 73,674.40 | 46 | −$62.35 |
| short | 1 Jun 2026 73,674.40 | 26 Jun 2026 59,794.60 | 25 | $68.90 |
| short | 1 Jun 2026 73,674.40 | 19 Aug 2026 64,725.40 | 79 | $398.03 |
| long | 19 Aug 2026 64,725.40 | 22 Aug 2026 78,338.00 | 3 | $67.53 |
| long | 19 Aug 2026 64,725.40 | 22 Sep 2026 86,620.00 | 34 | $98.01 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| The Strategy - Ichimoku Kinko Hyo and more this page | — | v5 strategy | +10.3% | 57 | 16.6% |
| Grid Tool by ramsay09 | lowest rising falling pivothigh pivotlow valuewhen alma macd rsi supertrend dmi | v5 strategy | No trades on this market | ||
| VXD Supercycle by Vvaz_ | supertrend ema sma pivothigh pivotlow valuewhen highest lowest rsi | v5 strategy | does not run in Zeal Terminal | ||
| supertrend with multiple filter strategy by mathlabel | supertrend sma highest lowest macd ema atr stoch pivothigh pivotlow rsi | v5 strategy | does not run in Zeal Terminal | ||
| X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 by X4815162342 | ema rsi sma highest lowest pivothigh pivotlow valuewhen | v5 strategy | does not run in Zeal Terminal | ||
| -Backtesting System by HALDRO | alma dmi rising falling highest lowest rsi atr | v5 strategy | +1.2% | 2 | 2.6% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
Yes
Same 57 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6strategy(title='The Strategy - Ichimoku Kinko Hyo and more', shorttitle='Strategy', overlay=true, initial_capital=10000, pyramiding=1, default_qty_type=strategy.fixed, default_qty_value=0.05, currency=currency.USD, ⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 400 ms | With a workaround 1,000 bars in 790 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0///@version=5strategy(title='The Strategy - Ichimoku Kinko Hyo and more', shorttitle='Strategy', overlay=true, initial_capital=10000, pyramiding=1, default_qty_type=strategy.fixed, default_qty_value=0.05, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.075, margin_long=0, margin_short=0)//-------------------------------------------------------------------- inputs ---------------------------------------------------------------general_info = input.bool(title='General Description', defval=false, tooltip='This script offers you the opportunity to backtest many signals and filters to compare the results. Make yourself familiar with the signals and the options and become creative ... At least you will be able to see what and on what circumstances works or not. Note the \'KISS\' principle and that \'context\' matters. The key feature of technical analysis is that every market participant is an interface to the world or market-environment and all market relevant information is visible in the chart. The default values are suitable for Bitcoin on ByBit (one tick = 0.5). Deselect \'Signal Labels\' at strategy properties -> Style to avoid signal label strings.')entry_type = input.string('Both', title='Position Entry-Direction', options=['Both', 'Long', 'Short'], tooltip='Long= long entries only, Short= short entries only, Both= long and short entries are possible.')repaint = input.string('Allowed', title='Repainting', options=['Not allowed', 'Allowed'], tooltip='If repainting "Not allowed" is selected, then signals from higher time frames have a lag of an additional bar from the higher time frame but you trade what you have backtested. Otherwise singals can occure multiple times as long as the higher time frame bar is not closed but the first signal of these possible multiple signals is much earlier.')panel = input.bool(true, title='Plot Info Panel', tooltip='Info panel for current unrealized profit or loss for the open position')plot_avg_price = input.bool(true, title='Plot Position Avarage Price Line.', tooltip='This plots the position avarage price line.')one_side_pyr = input.bool(title='Pyramiding Mode', defval=false, tooltip='If disabled: as long as the signal is valid a new trade can be opened on each bar (more filter sensitive). If not \'Both\' as direction is selected, the opposite signal closes the current position. If enabled: a new trade is opened with every signal. Use Properties -> Pyramiding to increase the maximum amount of orders.')htf_entr_opt_1 = input.string('Current', title='Time Frame - 1st ENTRY SIGNAL', options=['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'], tooltip='Choose always a higher time frame than the current. Lower time frames than the current may result in false values.', group='entry signals:')htf_entr_opt_2 = input.string('Current', title='Time Frame - 2nd ENTRY SIGNAL', options=['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'], tooltip='Choose always a higher time frame than the current. Lower time frames than the current may result in false values.', group='entry signals:')X_opt = input.string('Price X Kumo sig', title='--- 1st ENTRY SIGNAL ---', options=['---', 'Fractals trend lines sig (no tf filter)', 'Segments sig (no tf filter)', 'DMI ADX classic sig', 'DMI ADX mod sig', 'DMI ADX-slope sig', 'EMA1 x EMA2 sig', 'TRIX slope sig', 'ALMA slope sig', 'MACD(fast) slope sig', 'HMA slope sig', 'Grid - reentry sig (no tf filter)', 'Grid - counter trend sig (no tf filter)', 'Pin bar sig', 'Inside bar sig', 'Outside bar sig', 'Sandwich bar sig', 'Bar breakout 1 sig', 'Bar breakout 2 sig', 'Higher-low/lower-high bar sig', 'Entry on every bar-open sig', 'Fractals sig', 'Reverse fractal sig', 'SMA sig', 'RSI50 sig', 'Parabolic SAR sig', 'SuperTrend sig', 'Price X Kijun sig', 'Price X Kumo sig', 'Kumo flip sig', 'Chikou X price sig', 'Chikou X Kumo sig', 'Price X Tenkan sig', 'Tenkan X Kumo sig', 'Tenkan X Kijun sig', 'CB/CS sig (no tf filter)', 'IB/IS sig (no tf filter)', 'B1/S1 sig', 'B2/S2 sig'], tooltip='Various entry signals. 1st ENTRY SIGNAL and 2nd ENTRY SIGNAL are OR connected.', group='entry signals:')X_opt_2 = input.string('---', title='--- 2nd ENTRY SIGNAL --- (Enable Pyramiding Mode)', options=['---', 'Fractals trend lines sig (no tf filter)', 'Segments sig (no tf filter)', 'DMI ADX classic sig', 'DMI ADX mod sig', 'DMI ADX-slope sig', 'EMA1 x EMA2 sig', 'TRIX slope sig', 'ALMA slope sig', 'MACD(fast) slope sig', 'HMA slope sig', 'Grid - reentry sig (no tf filter)', 'Grid - counter trend sig (no tf filter)', 'Pin bar sig', 'Inside bar sig', 'Outside bar sig', 'Sandwich bar sig', 'Bar breakout 1 sig', 'Bar breakout 2 sig', 'Higher-low/lower-high bar sig', 'Entry on every bar-open sig', 'Fractals sig', 'Reverse fractal sig', 'SMA sig', 'RSI50 sig', 'Parabolic SAR sig', 'SuperTrend sig', 'Price X Kijun sig', 'Price X Kumo sig', 'Kumo flip sig', 'Chikou X price sig', 'Chikou X Kumo sig', 'Price X Tenkan sig', 'Tenkan X Kumo sig', 'Tenkan X Kijun sig', 'CB/CS sig (no tf filter)', 'IB/IS sig (no tf filter)', 'B1/S1 sig', 'B2/S2 sig'], tooltip='Various entry signals. Signal 1 and signal 2 are OR connected. Works with pyramiding mode only', group='entry signals:')htf_filt_opt_1 = input.string('Current', title='Time Frame - Entry Filter 1', options=['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'], tooltip='The time frame for the 1st ENTRY SIGNAL filter. Choose always a higher time frame than the current. Lower time frames than the current may result in false values.', group='Entry filters:')htf_filt_opt_2 = input.string('Current', title='Time Frame - Entry Filter 2', options=['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'], tooltip='The time frame for the 2st ENTRY SIGNAL filter. Choose always a higher time frame than the current. Lower time frames than the current may result in false values.', group='Entry filters:')entry_f_1 = input.string('---', title='Entry Filter 1', options=['---', 'Fractals trend lines filter (no tf filter)', 'Bar breakout 1 filter', 'Bar breakout 2 filter', 'SMA filter', 'MACD filter', 'EMA1 x EMA2 filter', 'RSI Stochastic filter', 'TRIX slope filter', 'ALMA slope filter','HMA slope filter', 'MACD(fast) slope filter', 'RSI50 filter', 'Segments filter (no tf filter)', 'Reverse fractal filter', 'Fractals filter', 'SuperTrend filter', 'Parabolic SAR filter', 'ADX Threshold filter', 'DMI filter', 'Price X Kumo filter', 'Price X Kijun filter', 'Kumo flip filter', 'Price filtered Kumo flip filter (no tf filter)', 'Chikou X price filter', 'Chikou X Kumo filter', 'Price X Tenkan filter', 'Tenkan X Kumo filter', 'Tenkan X Kijun filter', 'B1/S1 sig', 'B2/S2 sig', 'IB/IS sig (no tf filter)'], group='Entry filters:', tooltip='Various entry filter signals. Entry filter 1 and Entry filter 2 are AND connected.')entry_f_2 = input.string('---', title='Entry Filter 2', options=['---', 'Fractals trend lines filter (no tf filter)', 'Bar breakout 1 filter', 'Bar breakout 2 filter', 'SMA filter', 'MACD filter', 'EMA1 x EMA2 filter', 'RSI Stochastic filter', 'TRIX slope filter', 'ALMA slope filter','HMA slope filter', 'MACD(fast) slope filter', 'RSI50 filter', 'Segments filter (no tf filter)', 'Reverse fractal filter', 'Fractals filter', 'SuperTrend filter', 'Parabolic SAR filter', 'ADX Threshold filter', 'DMI filter', 'Price X Kumo filter', 'Price X Kijun filter', 'Kumo flip filter', 'Price filtered Kumo flip filter (no tf filter)', 'Chikou X price filter', 'Chikou X Kumo filter', 'Price X Tenkan filter', 'Tenkan X Kumo filter', 'Tenkan X Kijun filter', 'B1/S1 sig', 'B2/S2 sig', 'IB/IS sig (no tf filter)'], group='Entry filters:', tooltip='Various entry filter signals. Filter 1 and filter 2 are AND connected.')htf_exit_opt_1 = input.string('Current', title='Time Frame - Exit Filter 1', options=['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'], tooltip='Choose always a higher time frame than the current. Lower time frames than the current may result in false values.', group='exit filters:')htf_exit_opt_2 = input.string('Current', title='Time Frame - Exit Filter 2', options=['Current', '5m', '10m', '15m', '30m', '1H', '2H', '3H', '4H', '6H', '12H', 'D', '3D', 'W', 'M'], tooltip='Choose always a higher time frame than the current. Lower time frames than the current may result in false values.', group='exit filters:')exit_f_1 = input.string('---', title='Exit Filter 1', options=['---', 'Reverse bar exit', 'Reverse fractal exit', 'Bar breakout 2 exit', 'SMA exit', 'MACD exit', 'MACD(fast) slope exit', 'RSI50 exit', 'RSI Stochastic exit', 'TRIX slope exit', 'HMA slope exit', 'EMA1 x EMA2 exit', 'Fractals exit', 'SuperTrend exit', 'Parabolic SAR exit', 'ADX Threshold exit', 'Cloud exit', 'Kijun exit', 'IB/IS exit (no tf filter)'], group='exit filters:', tooltip='Some exit filter signals. Exit filter 1 and Exit filter 2 are OR connected.')exit_f_2 = input.string('---', title='Exit Filter 2', options=['---', 'Reverse bar exit', 'Reverse fractal exit', 'Bar breakout 2 exit', 'SMA exit', 'MACD exit', 'MACD(fast) slope exit', 'RSI50 exit', 'RSI Stochastic exit', 'TRIX slope exit', 'HMA slope exit', 'EMA1 x EMA2 exit', 'Fractals exit', 'SuperTrend exit', 'Parabolic SAR exit', 'ADX Threshold exit', 'Cloud exit', 'Kijun exit', 'IB/IS exit (no tf filter)'], group='exit filters:', tooltip='Some exit filter signals. Exit filter 1 and Exit filter 2 are OR connected.')//------------------------ lot size for live trading --------------------------//Alertatron lot size on Bybitlot_size = input.int(300, title='Lot Size', minval=1, step=100, tooltip='Alertatron lot size string for Bybit exchange. Affects live trading only.', group='Live trading Parameter (does not affect backtesting):')grid_gap = input.float(500, title='Grid Gap - Base Currency', minval=1, step=50, group='Grid parameter:', tooltip='The minimum trigger-gap between two trades in case of a selected grid signal.')//------------------------ Backtest periode inputs ----------------------------period_start = input.time(title='', inline='start_timestamp', defval=timestamp('13 Mar 2020 00:00 +0000'), group='Define the backtest period or start of trend:', tooltip='Backtest period start.')period_stop = input.time(title='', inline='end_timestamp', defval=timestamp('31 Dec 2120 00:00 +0000'), group='Define the backtest period or start of trend:', tooltip='Backtest period end.')//---------------------- take profit inputs -----------------------------av_tp_en = input.bool(title='Enable take Profit - Average Position Price Profit', defval=true, group='Take profit based on average position price:', tooltip='Profit taking condition: current price >= average position price of positions + ATR')av_tp_qty = input.float(10, title='Take Average Position Price Profit - Quantity Of Position (Percent)', minval=1, step=5, maxval=100, group='Take profit based on average position price:', tooltip='Reduction of the current position in percent.')atr_l = input.int(50, title='ATR Length', minval=0, step=5, group='Take profit based on average position price:', tooltip='ATR length for profit and step calculation')atr_tf = input.string('W', title='ATR Time Frame', options=['60', '120', '240', '480', '960', 'D', '3D', 'W', 'M'], group='Take profit based on average position price:', tooltip='ATR time frame for profit and step calculation')atr_fact = input.float(1, title='ATR Factor', minval=0, step=0.1, group='Take profit based on average position price:', tooltip='ATR factor to increase/decrease ATR for profit and step calculation')//---------------------- stop loss inputs --------------------------sl_en = input.bool(title='Enable Stop Loss - Average Position Price Loss', defval=true, group='Stop loss based on average position price:', tooltip='Stop loss condition: current price <= average position price of positions - \'Stop average-entry loss...\' AND current price <= average position price of positions - \'Stop loss step...\'')av_sl_qty = input.float(50, title='Stop Average Position Price Loss - Quantity Of Position (Percent)', minval=0, step=5, maxval=100, group='Stop loss based on average position price:', tooltip='Reduction of the current position in percent.')atr_l_l = input.int(50, title='ATR Length', minval=0, step=5, group='Stop loss based on average position price:', tooltip='ATR length for loss and step calculation')atr_tf_l = input.string('W', title='ATR Time Frame', options=['60', '120', '240', '480', '960', 'D', '3D', 'W', 'M'], group='Stop loss based on average position price:', tooltip='ATR time frame for loss and step calculation')atr_fact_l = input.float(1, title='ATR Factor', minval=0, step=0.1, group='Stop loss based on average position price:', tooltip='ATR factor to increase/decrease ATR for loss and step calculation')//------------------------ Signal inputs CB/CS and IB/IS ---------------------------trig_gap_cbcs = input.float(2, title='CB/CS Signal Offset', minval=-6, maxval=9, step=1, group='Confluence signal offsets:', tooltip='Decreasing this parameter increases the sensitivity of the signal.')trig_gap_ibis = input.float(0, title='IB/IS Signal Offset', minval=-5, maxval=4, step=1, group='Confluence signal offsets:', tooltip='Decreasing this parameter increases the sensitivity of the signal.')//----------------------- entry signals and filters -----------------------sb = input.int(10, title='Segment Max Bars', minval=0, step=1, group='Shared filter and entry signal parameters:')p_bar_sens_1 = input.float(0.6, title='Pin Bar Sensitivity 1', step=0.02, tooltip='Condition: candle wick > candle body * \'Pin bar sensitivity\' . The smaller the factor, the more wicks are detected as part of a pin bar.', group='Shared filter and entry signal parameters:')p_bar_sens_2 = input.int(1, title='Pin Bar Sensitivity 2', step=1, minval=1, tooltip='Condition: high/low >< last two high/low\'.', group='Shared filter and entry signal parameters:')fr_period = input.int(2, title='Fractals Period', minval=1, group='Shared filter and entry signal parameters:')rsi_period = input.int(14, title='RSI Period', minval=1, group='Shared filter and entry signal parameters:')ma_period = input.int(50, title='SMA Period', minval=1, step=5, group='Shared filter and entry signal parameters:')mult = input.float(3, title='SuperTrend Multiplier', minval=1, step=0.2, group='Shared filter and entry signal parameters:')len = input.int(6, title='SuperTrend Length', minval=1, group='Shared filter and entry signal parameters:')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.int(10, title='ADX DI Length', minval=1, group='Shared filter and entry signal parameters:')adx_smooth_s = input.int(10, title='ADX Smooth', minval=1, group='Shared filter and entry signal parameters:')adx_thres_s = input.int(25, title='ADX Threshold', step=2, minval=1, group='Shared filter and entry signal parameters:')windowsize = input.int(9, title="ALMA Window Size", minval=1, step=1, group='Shared filter and entry signal parameters:', tooltip='')offset = input.float(0.85, title="ALMA Offset", minval=0, step=0.05, group='Shared filter and entry signal parameters:', tooltip='')sigma = input.float(6, title="ALMA Sigma", minval=1, step=1, group='Shared filter and entry signal parameters:', tooltip='')slope_len = input.int(1, minval=1, title='MACD MacdlLine Slope Lenth', tooltip='MACD\'s fast line', group='Shared filter and entry signal parameters:')hma_len_f = input.int(100, minval=1, step=5, title='HMA Length', group='Shared filter and entry signal parameters:')ema1_len_f = input.int(10, minval=1, step=2, title='EMA1 Length', group='Shared filter and entry signal parameters:')ema2_len_f = input.int(20, minval=1, step=2, title='EMA2 Length', group='Shared filter and entry signal parameters:')k_smoo_f = input.int(3, title='RSI-Stoch K-line', minval=1, tooltip='RSI Stochastic\'s fast line', group='Shared filter and entry signal parameters:')d_smoo_f = input.int(3, title='RSI-Stoch D-line', minval=1, tooltip='RSI Stochastic\'s slow line', group='Shared filter and entry signal parameters:')stoch_length_f = input.int(14, title='RSI-Stoch Stochastic Length', minval=1, group='Shared filter and entry signal parameters:')rsi_length_sto_f = input.int(14, title='RSI-Stoch RSI Length', minval=1, group='Shared filter and entry signal parameters:')trix_len_f = input.int(10, title="TRIX Length", minval=1, group='Shared filter and entry signal parameters:')// exit filtersfr_period_x = input.int(2, title='Exit Fractals - Period', minval=1, group='Exit filter Parameters:')fr_past_x = input.int(0, title='Exit Fractals - Past Fractal', minval=0, group='Exit filter Parameters:')rsi_period_x = input.int(14, title='Exit RSI Period', minval=1, group='Exit filter Parameters:')ma_period_x = input.int(50, title='Exit SMA Period', step=5, minval=1, group='Exit filter Parameters:')mult_x = input.float(2, title='Exit SuperTrend Multiplier', minval=1, group='Exit filter Parameters:')len_x = input.int(5, title='Exit SuperTrend Length', minval=1, group='Exit filter Parameters:')di_length_x = input.int(10, title='Exit ADX Period', minval=1, group='Exit filter Parameters:')adx_smooth_x = input.int(10, title='Exit ADX Smooth', minval=1, group='Exit filter Parameters:')adx_thres_x = input.int(25, title='Exit ADX Threshold', step=2, minval=1, group='Exit filter Parameters:')slope_len_x = input.int(1, title='Exit MACD MacdlLine Slope Lenth', minval=1, tooltip='MACD\'s fast line', group='Exit filter Parameters:')hma_len_x = input.int(100, minval=1, step=5, title='Exit HMA Length', group='Exit filter Parameters:')ema1_len_x = input.int(10, title='Exit EMA1 Length', minval=1, step=2, group='Exit filter Parameters:')ema2_len_x = input.int(20, title='Exit EMA2 Length', minval=1, step=2, group='Exit filter Parameters:')k_smoo_x = input.int(3, title='Exit RSI-Stoch K-line', minval=1, tooltip='RSI Stochastic\'s fast line', group='Exit filter Parameters:')d_smoo_x = input.int(3, title='Exit RSI-Stoch D-line', minval=1, tooltip='RSI Stochastic\'s slow line', group='Exit filter Parameters:')stoch_length_x = input.int(14, title='Exit RSI-Stoch Stochastic Length', minval=1, group='Exit filter Parameters:')rsi_length_sto_x = input.int(14, title='Exit RSI-Stoch RSI Length', minval=1, group='Exit filter Parameters:')trix_len_x = input.int(10, title="Exit TRIX Length", minval=1, group='Exit filter Parameters:')//--------------- Current unrealized profit or loss for the open position -------------------if panel var info_panel = table.new(position = position.bottom_left, columns = 1, rows = 1, bgcolor=color.new(color.blue, 92), frame_width=1, border_width=1) text1 = "Unrealized Profit/Loss:\n" + str.tostring(strategy.openprofit, "#.00") table.cell(table_id=info_panel, column=0, row=0, text=text1, text_size= size.normal, text_color=color.new(color.silver, 0))//----------------------- Backtest periode --------------------------------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)// calculationTK = math.avg(ta.lowest(TKlength), ta.highest(TKlength))KJ = math.avg(ta.lowest(KJlength), ta.highest(KJlength))CS = closeSB = math.avg(ta.lowest(SBlength), ta.highest(SBlength))SA = math.avg(TK, KJ)kumo_high = math.max(SA[CSHSlength - 1], SB[CSHSlength - 1])kumo_low = math.min(SA[CSHSlength - 1], SB[CSHSlength - 1])//--------------------------------------------------------------------------------- Filters and entry signals -----------------------------------------------------------------------------------//---------------------- Ichimoku filter ------------------------var bool tkkj_x = trueif ta.crossover(TK, KJ) and TK > kumo_high and KJ > kumo_high tkkj_x := true tkkj_xif ta.crossunder(TK, KJ) and TK < kumo_low and KJ < kumo_low tkkj_x := false tkkj_x//Ichimoku entry signalskijun_buy = one_side_pyr ? ta.crossover(close, KJ) : close > KJkumo_buy = one_side_pyr ? ta.crossover(close, kumo_high) : close > kumo_highkumo_flip_buy = one_side_pyr ? ta.crossover(SA, SB) : SA > SBchikou_X_price_buy = one_side_pyr ? ta.crossover(CS, high[26 - 1]) : CS > high[26 - 1]chikou_X_kumo_buy = one_side_pyr ? ta.crossover(CS, kumo_high[26 - 1]) : CS > kumo_high[26 - 1]price_X_tenkan_buy = one_side_pyr ? ta.crossover(close, TK) : close > TKtenkan_X_kumo_buy = one_side_pyr ? ta.crossover(TK, kumo_high) : TK > kumo_hightenkan_X_kijun_buy = one_side_pyr ? ta.crossover(TK, KJ) : TK > KJkijun_sell = one_side_pyr ? ta.crossunder(close, KJ) : close < KJkumo_sell = one_side_pyr ? ta.crossunder(close, kumo_low) : close < kumo_lowkumo_flip_sell = one_side_pyr ? ta.crossunder(SA, SB) : SA < SBchikou_X_price_sell = one_side_pyr ? ta.crossunder(CS, low[26 - 1]) : CS < low[26 - 1]chikou_X_kumo_sell = one_side_pyr ? ta.crossunder(CS, kumo_low[26 - 1]) : CS < kumo_low[26 - 1]price_X_tenkan_sell = one_side_pyr ? ta.crossunder(close, TK) : close < TKtenkan_X_kumo_sell = one_side_pyr ? ta.crossunder(TK, kumo_low) : TK < kumo_lowtenkan_X_kijun_sell = one_side_pyr ? ta.crossunder(TK, KJ) : TK < KJ// Ichimoku filterskijun_buy_f = close > KJkumo_buy_f = close > kumo_highkumo_flip_buy_f = SA > SBchikou_X_price_buy_f = CS > high[26 - 1]chikou_X_kumo_buy_f = CS > kumo_high[26 - 1]price_X_tenkan_buy_f = close > TKtenkan_X_kumo_buy_f = TK > kumo_hightenkan_X_kijun_buy_f = TK > KJkumo_filtered_tenkan_X_kijun_buy_f = tkkj_x and TK > kumo_high and KJ > kumo_high and TK > KJkijun_sell_f = close < KJkumo_sell_f = close < kumo_lowkumo_flip_sell_f = SA < SBchikou_X_price_sell_f = CS < low[26 - 1]chikou_X_kumo_sell_f = CS < kumo_low[26 - 1]price_X_tenkan_sell_f = close < TKtenkan_X_kumo_sell_f = TK < kumo_lowtenkan_X_kijun_sell_f = TK < KJkumo_filtered_tenkan_X_kijun_sell_f = not tkkj_x and TK < kumo_low and KJ < kumo_low and TK < KJ// Ichimoku exitskijun_buy_x = ta.crossover(high, KJ)kijun_sell_x = ta.crossunder(low, KJ)kumo_buy_x = ta.crossover(high, kumo_high)kumo_sell_x = ta.crossunder(low, kumo_low)//----------------------- bar signals -----------------------//entry signalbar_sig_1_buy = close > high[1] // bar breakout signal 1bar_sig_1_sell = close < low[1]//filterbar_sig_1_buy_f = close > high[1] // bar breakout signal 1 - filterbar_sig_1_sell_f = close < low[1]//entrybar_sig_2_buy = high > high[1] // bar breakout signal 2bar_sig_2_sell = low < low[1]//filterbar_sig_2_buy_f = high > high[1] // bar breakout signal 2 - filterbar_sig_2_sell_f = low < low[1]rev_bar_sig_buy = close > open // reverse bar exitrev_bar_sig_sell = close < openhllh_buy = low > low[1] // higher-low/lower-high bar sighllh_sell = high < high[1]open_buy = close != 0 // entry on every open bar sigopen_sell = close != 0//-------------------------- trix --------------------------f_trix(_trix_len) => 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(close), _trix_len), _trix_len), _trix_len))trix_f = f_trix(trix_len_f)trix_x = f_trix(trix_len_x)trix_buy_s = ta.rising(trix_f, 1) and not ta.rising(trix_f, 1)[1] //one_side_pyr ? ta.rising(trix_f, 1) and not ta.rising(trix_f, 1)[1] : ta.rising(trix_f, 1) trix_sell_s = ta.falling(trix_f, 1) and not ta.falling(trix_f, 1)[1] //one_side_pyr ? ta.falling(trix_f, 1) and not ta.falling(trix_f, 1)[1] : ta.falling(trix_f, 1) trix_slo_up_f = ta.rising(trix_f, 1) trix_slo_up_x = ta.rising(trix_x, 1) and not ta.rising(trix_x, 1)[1]trix_slo_dn_x = ta.falling(trix_x, 1) and not ta.falling(trix_x, 1)[1]//----------------------- rsi stochastic ----------------------------//filterrsi_rs_f = ta.rsi(close, rsi_length_sto_f)k_f = ta.sma(ta.stoch(rsi_rs_f, rsi_rs_f, rsi_rs_f, stoch_length_f), k_smoo_f)d_f = ta.sma(k_f, d_smoo_f)//signalkd_mom_up_f = k_f > 20 and d_f > 20 and not(k_f < d_f and k_f < 80 and d_f < 80)kd_mom_dn_f = k_f < 80 and d_f < 80 and not(k_f > d_f and k_f > 80 and d_f > 80)//exitrsi_rs_x = ta.rsi(close, rsi_length_sto_x)k_x = ta.sma(ta.stoch(rsi_rs_x, rsi_rs_x, rsi_rs_x, stoch_length_x), k_smoo_x)d_x = ta.sma(k_x, d_smoo_x)//signalkd_mom_up_x = k_x > 20 and d_x > 20 and not(k_x < d_x and k_x < 80 and d_x < 80)kd_mom_dn_x = k_x < 80 and d_x < 80 and not(k_x > d_x and k_x > 80 and d_x > 80)//------------------------- hma ----------------------------f_hma(_hma_len) => ta.hma(close, _hma_len) hma_f = f_hma(hma_len_f) // entry filterhma_x = f_hma(hma_len_x) // exit hma_up_e = ta.rising(hma_f, 1) and not ta.rising(hma_f, 1)[1] //one_side_pyr ? ta.rising(hma_f, 1) and not ta.rising(hma_f, 1)[1] : ta.rising(hma_f, 1) // entry signalhma_dn_e = ta.falling(hma_f, 1) and not ta.falling(hma_f, 1)[1] //one_side_pyr ? ta.falling(hma_f, 1) and not ta.falling(hma_f, 1)[1] : ta.falling(hma_f, 1) hma_up_f = ta.rising(hma_f, 1) // entry filterhma_up_x = ta.rising(hma_x, 1) and not ta.rising(hma_x, 1)[1] // exit hma_dn_x = ta.falling(hma_x, 1) and not ta.falling(hma_x, 1)[1] //------------------------ grid --------------------------re_grid = 0.re_grid := nz(high > re_grid[1] + grid_gap or low < re_grid[1] - grid_gap ? close : re_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 = ta.pivothigh(high, 3, 0) and dn_bar and up_bar[1] or ta.pivothigh(high, 4, 1) and dn_bar and up_bar[1] or ta.pivothigh(high, 4, 1) and lh and up_bar and up_bar[1]rev_dn_fr_buy = ta.pivotlow(low, 3, 0) and up_bar and dn_bar[1] or ta.pivotlow(low, 4, 1) and up_bar and dn_bar[1] or ta.pivotlow(low, 4, 1) and hl and dn_bar and dn_bar[1]//------------------------- ema1 x ema2 ------------------------f_ema(_ema_len) => ta.ema(close, _ema_len) // ma function definitionf_sma(_sma_len) => ta.sma(close, _sma_len) // ma function definitionema1_f = f_ema(ema1_len_f)ema2_f = f_ema(ema2_len_f)ema1_x = f_ema(ema1_len_x)ema2_x = f_ema(ema2_len_x)ema_1x2_buy_s = ta.crossover(ema1_f, ema2_f)ema_1x2_sell_s = ta.crossunder(ema1_f, ema2_f)ema_1x2_buy_f = ema1_f > ema2_fema_1x2_buy_x = ta.crossover(ema1_x, ema2_x)ema_1x2_sell_x = ta.crossunder(ema1_x, ema2_x)//--------------------- ALMA ------------------------alma = ta.alma(close, windowsize, offset, sigma)//entry signalsalma_slo_up_e = ta.rising(alma, 1) and not ta.rising(alma, 1)[1] //one_side_pyr ? ta.rising(alma, 1) and not ta.rising(alma, 1)[1] : ta.rising(alma, 1) alma_slo_dn_e = ta.falling(alma, 1) and not ta.falling(alma, 1)[1] //one_side_pyr ? ta.falling(alma, 1) and not ta.falling(alma, 1)[1] : ta.falling(alma, 1) //filtersalma_slo_up_f = ta.rising(alma, 1) //----------------------- macd filter and macd slope-----------------------[macdLine_f, signalLine_f, histLine_f] = ta.macd(close, 12, 26, 9)//filtersmacd_buy = macdLine_f > signalLine_fmacd_sell = macdLine_f < signalLine_f//exitmacd_buy_x = ta.crossover(macdLine_f, signalLine_f)macd_sell_x = ta.crossunder(macdLine_f, signalLine_f)//macd fast line slopemacd_slope_up_e = ta.rising(macdLine_f, slope_len) and not ta.rising(macdLine_f, slope_len)[1] //one_side_pyr ? ta.rising(macdLine_f, slope_len) and not ta.rising(macdLine_f, slope_len)[1] : ta.rising(macdLine_f, slope_len) // entrymacd_slope_dn_e = ta.falling(macdLine_f, slope_len) and not ta.falling(macdLine_f, slope_len)[1] //one_side_pyr ? ta.falling(macdLine_f, slope_len) and not ta.falling(macdLine_f, slope_len)[1] : ta.falling(macdLine_f, slope_len)macd_slope_up_f = ta.rising(macdLine_f, slope_len) // filtermacd_slope_up_x = ta.rising(macdLine_f, slope_len_x) and not ta.rising(macdLine_f, slope_len_x)[1] // exitmacd_slope_dn_x = ta.falling(macdLine_f, slope_len_x) and not ta.falling(macdLine_f, slope_len_x)[1]//---------------------- rsi filter and entry signal------------------------f_rsi(_rsi_period) => ta.rsi(close, _rsi_period)//entryrsi_f = f_rsi(rsi_period)rsi_f_buy = one_side_pyr ? ta.crossover(rsi_f, 50) : rsi_f > 50rsi_f_sell = one_side_pyr ? ta.crossunder(rsi_f, 50) : rsi_f < 50//filtersrsi_f_buy_f = rsi_f > 50rsi_f_sell_f = rsi_f < 50//exitrsi_f_x = f_rsi(rsi_period_x)rsi_f_buy_x = ta.crossover(rsi_f_x, 50)rsi_f_sell_x = ta.crossunder(rsi_f_x, 50)//---------------- Bill Williams Fractals (filter and entry signal) -----------------up_fr = ta.pivothigh(fr_period, fr_period)dn_fr = ta.pivotlow(fr_period, fr_period)fractal_up_v = ta.valuewhen(up_fr, high[fr_period], 0)fractal_dn_v = ta.valuewhen(dn_fr, low[fr_period], 0)//entry signalfr_upx = one_side_pyr ? ta.crossover(high, fractal_up_v) : high > fractal_up_v fr_dnx = one_side_pyr ? ta.crossunder(low, fractal_dn_v) : low < fractal_dn_v//filtersfr_upx_f = high > fractal_up_vfr_dnx_f = low < fractal_dn_v//exitup_fr_x = ta.pivothigh(fr_period_x, fr_period_x)dn_fr_x = ta.pivotlow(fr_period_x, fr_period_x)fractal_up_v_x = ta.valuewhen(up_fr_x, high[fr_period_x], fr_past_x)fractal_dn_v_x = ta.valuewhen(dn_fr_x, low[fr_period_x], fr_past_x)fr_upx_x = ta.crossover(high, fractal_up_v_x)fr_dnx_x = ta.crossunder(low, fractal_dn_v_x)//-------------------- SuperTrend filter and entry signal ---------------------//entry[SuperTrend, Dir] = ta.supertrend(mult, len)sup_buy = one_side_pyr ? ta.crossover(high, SuperTrend) : high > SuperTrendsup_sell = one_side_pyr ? ta.crossunder(low, SuperTrend) : low < SuperTrend//filterssup_buy_f = high > SuperTrendsup_sell_f = low < SuperTrend//exit[SuperTrend_x, Dir_x] = ta.supertrend(mult_x, len_x)sup_buy_x = ta.crossover(high, SuperTrend_x)sup_sell_x = ta.crossunder(low, SuperTrend_x)//----------------- Parabolic SAR Signal (pb/ps) and filter -------------------psar_buy = one_side_pyr ? ta.crossover(high, ta.sar(start, inc, max)[0]) : high > ta.sar(start, inc, max)[0]psar_sell = one_side_pyr ? ta.crossunder(low, ta.sar(start, inc, max)[0]) : low < ta.sar(start, inc, max)[0]//filterspsar_buy_f = high > ta.sar(start, inc, max)[0]psar_sell_f = low < ta.sar(start, inc, max)[0]psar_buy_x = ta.crossover(high, ta.sar(start, inc, max)[0])psar_sell_x = ta.crossunder(low, ta.sar(start, inc, max)[0])//-------------------------- DMI ADX entry sig and filter ---------------------------//exit[diplus_f_x, diminus_f_X, adx_f_x] = ta.dmi(di_length_x, adx_smooth_x)adx_thres_f_x = ta.crossunder(adx_f_x, adx_thres_x)//dmi and adx signal 1/2/3 and filters[diplus_s, diminus_s, adx_s] = ta.dmi(di_length_s, adx_smooth_s)adx_above_thres = adx_s > adx_thres_sadx_slope_up = ta.rising(adx_s, 1)//entry filterlong_e = diplus_s > diminus_sshort_e = diplus_s < diminus_s//entrylong_1 = one_side_pyr ? ta.crossover(diplus_s, diminus_s) and adx_s < diplus_s and adx_s > diminus_s : diplus_s > diminus_s and adx_s < diplus_s and adx_s > diminus_sshort_1 = one_side_pyr ? ta.crossunder(diplus_s, diminus_s) and adx_s > diplus_s and adx_s < diminus_s : diplus_s < diminus_s and adx_s > diplus_s and adx_s < diminus_slong_2 = one_side_pyr ? ta.crossover(diplus_s, diminus_s) and adx_s > adx_thres_s : diplus_s > diminus_s and adx_above_thresshort_2 = one_side_pyr ? ta.crossunder(diplus_s, diminus_s) and adx_s > adx_thres_s : diplus_s < diminus_s and adx_above_thres//dmi adx-slope signaladx_up_c = adx_slope_up and diplus_s > diminus_s and not (adx_slope_up and diplus_s > diminus_s)[1] adx_dn_c = adx_slope_up and diplus_s < diminus_s and not (adx_slope_up and diplus_s < diminus_s)[1]//-------------------------- SMA50 filter and entry---------------------------//entrysma_buy = one_side_pyr ? ta.crossover(close[1], f_sma(ma_period)) : close[2] > f_sma(ma_period)sma_sell = one_side_pyr ? ta.crossunder(close[1], f_sma(ma_period)) : close[2] < f_sma(ma_period)//filterssma_buy_f = close[2] > f_sma(ma_period)sma_sell_f = close[2] < f_sma(ma_period)//exitsma_buy_x = ta.crossover(close[1], f_sma(ma_period_x))sma_sell_x = ta.crossunder(close[1], f_sma(ma_period_x))//---------------- williams fractals trend lines -----------------up_w_fr = ta.pivothigh(2, 2)dn_w_fr = ta.pivotlow(2, 2)y1_frup_1 = ta.valuewhen(up_w_fr, high[2], 1)y0_frup_0 = ta.valuewhen(up_w_fr, high[2], 0)y1_frdn_1 = ta.valuewhen(dn_w_fr, low[2], 1)y0_frdn_0 = ta.valuewhen(dn_w_fr, low[2], 0)// bar-id loops to get x1 and x2 for line.new()xup0 = 2for i = 1 to 35 by 1 if high[i + 2] >= high[i + 3] and high[i + 2] > high[i + 4] and high[i + 2] > high[i + 1] and high[i + 2] >= high[i + 0] break xup0 := xup0 + 1 xup0xup1 = xup0for i = xup1 to 50 by 1 if high[i + 2] >= high[i + 3] and high[i + 2] > high[i + 4] and high[i + 2] > high[i + 1] and high[i + 2] >= high[i + 0] break xup1 := xup1 + 1 xup1xdn0 = 2for i = 1 to 35 by 1 if low[i + 2] <= low[i + 3] and low[i + 2] < low[i + 4] and low[i + 2] < low[i + 1] and low[i + 2] <= low[i + 0] break xdn0 := xdn0 + 1 xdn0xdn1 = xdn0for i = xdn1 to 50 by 1 if low[i + 2] <= low[i + 3] and low[i + 2] < low[i + 4] and low[i + 2] < low[i + 1] and low[i + 2] <= low[i + 0] break xdn1 := xdn1 + 1 xdn1// y-linebreak values for upper_line and lower_liney_up_lvl = (y0_frup_0 - y1_frup_1) / (xup1 + 2 - xup0) * xup0 + y0_frup_0 // y = slope * x0 + y0y_dn_lvl = (y0_frdn_0 - y1_frdn_1) / (xdn1 + 2 - xdn0) * xdn0 + y0_frdn_0// entry//frup_buy = ta.crossover(high, y0_frup_0)//frdn_sell = ta.crossunder(low, y0_frdn_0)buy_up_line = one_side_pyr ? ta.crossover(high, y_up_lvl) : high > y_up_lvl// or frup_buysell_dn_line = one_side_pyr ? ta.crossunder(low, y_dn_lvl) : low < y_dn_lvl// or frdn_sell//--------------------------- Segments signal ----------------------------count1_l = 0count2_l = 0segment_1_stat_l = falsesegment_2_stat_l = falsesegment_3_stat_l = falsehigher_low = low > low[1]var line segment_low_1_l = navar line segment_low_2_l = navar line segment_low_3_l = na// long segmentsfor i = 0 to sb by 1 count1_l := count1_l + 1 if low[1] > low[i + 2] and higher_low segment_1_stat_l := true breakfor i = count1_l to sb + count1_l by 1 count2_l := count2_l + 1 if low[1 + count1_l] > low[i + 2] and segment_1_stat_l segment_2_stat_l := true breakfor i = count2_l to sb + count2_l by 1 if low[1 + count1_l + count2_l] > low[i + 2 + count1_l] and segment_2_stat_l segment_3_stat_l := true break// short segmentscount1_s = 0count2_s = 0segment_1_stat_s = falsesegment_2_stat_s = falsesegment_3_stat_s = falselower_high = high < high[1]var line segment_high_1 = navar line segment_high_2 = navar line segment_high_3 = nafor i = 0 to sb by 1 count1_s := count1_s + 1 if high[1] < high[i + 2] and lower_high segment_1_stat_s := true breakfor i = count1_s to sb + count1_s by 1 count2_s := count2_s + 1 if high[1 + count1_s] < high[i + 2] and segment_1_stat_s segment_2_stat_s := true breakfor i = count2_s to sb + count2_s by 1 if high[1 + count1_s + count2_s] < high[i + 2 + count1_s] and segment_2_stat_s segment_3_stat_s := true break// segments signalsseg_stat_l = segment_1_stat_l and segment_2_stat_l and segment_3_stat_lseg_stat_s = segment_1_stat_s and segment_2_stat_s and segment_3_stat_s//entrysegments_buy = high > high[1] and seg_stat_l[1]segments_sell = low < low[1] and seg_stat_s[1]//filterssegments_buy_f = high > high[1] and seg_stat_l[1]segments_sell_f = low < low[1] and seg_stat_s[1]//----------------------- i-o-s-p 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]//pinbarcandle_body = math.abs(open - close)pivot_up = ta.pivothigh(high, p_bar_sens_2, 0)pivot_dn = ta.pivotlow(low, p_bar_sens_2, 0)up_wick = close > open ? high - close : high - opendn_wick = close > open ? open - low : close - lowpin_up_def = high - open > p_bar_sens_1 * candle_body and close < open or high - close > p_bar_sens_1 * candle_body and close > openpin_dn_def = open - low > p_bar_sens_1 * candle_body and close > open or close - low > p_bar_sens_1 * candle_body and close < openp_bar_sell = pin_up_def and pivot_up and up_wick > dn_wickp_bar_buy = pin_dn_def and pivot_dn and up_wick < dn_wick//----------------- Ichimoku Signal B1/S1 -----------------buy_strong_B1 = TK >= KJ and high > kumo_high and CS > high[26 - 1] and CS > kumo_high[26 - 1] and SA > SBsell_strong_S1 = TK <= KJ and low < kumo_low and CS < low[26 - 1] and CS < kumo_low[26 - 1] and SA < SB//----------------- Ichimoku Signal B2/S2 -----------------buy_strong_B2 = TK >= KJ and high > kumo_high and CS > high[26 - 1]sell_strong_S2 = TK <= KJ and low < kumo_low and CS < low[26 - 1]//---------------------------- Confluence Signal CB/CS ----------------------------long_short_trig = 10 //input(9, type= input.float, title= "Confluence signal trigger Level", step= 0.2)//Indicators// masma1 = f_sma(50)sma2 = f_sma(200)ema1 = f_ema(50)ema2 = f_ema(200)ema_c = f_ema(21)sma_c = f_sma(20)[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)rsi = f_rsi(14)[diplus, diminus, adx] = ta.dmi(7, 7)[superTrend, dir] = ta.supertrend(2, 5)//Klinger Oszillatorsv = ta.change(hlc3) >= 0 ? volume : -volumekvo = ta.ema(sv, 34) - ta.ema(sv, 55)sig = ta.ema(kvo, 13)//Vortex IndicatorVMP = math.sum(math.abs(high - low[1]), 14)VMM = math.sum(math.abs(low - high[1]), 14)STR = math.sum(ta.atr(1), 14)VIP = VMP / STRVIM = VMM / STR//HMA slopehma_slo_up = ta.rising(f_hma(15),1)//ALMA slopealma_slo_up = ta.rising(ta.alma(close, 9, 0.85, 6),1)//MACD slopemacd_slo_up = ta.rising(macdLine, 1)//Signalsvar float sem_sig_w = navar float sma_sig_w = navar float ema_sig_w = navar float p_kj_sig_w = navar float tk_kj_sig_w = navar float B1_S1_sig_w = navar float B2_S2_sig_w = navar float psar_sig_w = navar float frac_sig_w = navar float macd_sig_w = navar float rsi_sig_w = navar float p_tk_sig_w = navar float dmi_sig_w = navar float klin_sig_w = navar float vort_sig_w = navar float sup_sig_w = navar float hma_sig_w = navar float alma_sig_w = navar float macd_s_sig_w = naif ema_c > sma_c sem_sig_w := 1else if ema_c < sma_c sem_sig_w := 0if sma1 > sma2 sma_sig_w := 1else if sma1 < sma2 sma_sig_w := 0if ema1 > ema2 ema_sig_w := 1else if ema1 < ema2 ema_sig_w := 0if high > KJ p_kj_sig_w := 1else if low < KJ p_kj_sig_w := 0if TK > KJ tk_kj_sig_w := 1else if TK < KJ tk_kj_sig_w := 0if buy_strong_B1 B1_S1_sig_w := 1else if sell_strong_S1 B1_S1_sig_w := 0if buy_strong_B2 B2_S2_sig_w := 1else if sell_strong_S2 B2_S2_sig_w := 0if high >= ta.sar(start, inc, max)[0] psar_sig_w := 1else if low <= ta.sar(start, inc, max)[0] psar_sig_w := 0if high > fractal_up_v frac_sig_w := 1else if low < fractal_dn_v frac_sig_w := 0if macdLine > signalLine macd_sig_w := 1else if macdLine < signalLine macd_sig_w := 0if rsi > 50 rsi_sig_w := 1else if rsi < 50 rsi_sig_w := 0if high > TK p_tk_sig_w := 1else if low < TK p_tk_sig_w := 0if diplus > diminus dmi_sig_w := 1else if diplus < diminus dmi_sig_w := 0if sig > 0 klin_sig_w := 1else if sig < 0 klin_sig_w := 0if VIP > VIM vort_sig_w := 1else if VIP < VIM vort_sig_w := 0if high > superTrend sup_sig_w := 1else if low < superTrend sup_sig_w := 0if hma_slo_up hma_sig_w := 2else if not hma_slo_up hma_sig_w := -1if alma_slo_up alma_sig_w := 2else if not alma_slo_up alma_sig_w := -1if macd_slo_up macd_s_sig_w := 1else if not macd_slo_up macd_s_sig_w := 0bs_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 + sem_sig_w + hma_sig_w + alma_sig_w + macd_s_sig_wlong_c = one_side_pyr ? ta.crossover(bs_conf_sig, (long_short_trig + trig_gap_cbcs)) : bs_conf_sig > (long_short_trig + trig_gap_cbcs) //with +- signal is more stableshort_c = one_side_pyr ? ta.crossunder(bs_conf_sig, (long_short_trig - trig_gap_cbcs)) : bs_conf_sig < (long_short_trig - trig_gap_cbcs)//---------------------------- Pure Ichimoku Confluence Signal IB/IS ----------------------------pic_l_s_trig = 5 //input(4, type= input.float, title= "Ichimoku confluence signal trigger Level", step= 0.1)//Signalsvar float tkkh_sig_w = navar float csh_sig_w = navar float cskh_sig_w = navar float pkj_sig_w = navar float ptk_sig_w = navar float tkkj_sig_w = navar float sasb_sig_w = navar float ckh_sig_w = navar float cskj_sig_w = navar float cstk_sig_w = navar float kjcl_sig_w = naif TK > kumo_high tkkh_sig_w := 1else if TK < kumo_low tkkh_sig_w := 0if CS > high[26 - 1] csh_sig_w := 1else if CS < low[26 - 1] csh_sig_w := 0if CS > kumo_high[26 - 1] cskh_sig_w := 1else if CS < kumo_low[26 - 1] cskh_sig_w := 0if high > TK ptk_sig_w := 1else if low < TK ptk_sig_w := 0if high > KJ pkj_sig_w := 1else if low < KJ pkj_sig_w := 0if TK > KJ tkkj_sig_w := 1else if TK < KJ tkkj_sig_w := 0if SA > SB sasb_sig_w := 1else if SA < SB sasb_sig_w := 0if high > kumo_high ckh_sig_w := 1else if low < kumo_low ckh_sig_w := 0if CS > KJ[26 - 1] cskj_sig_w := 1else if CS < KJ[26 - 1] cskj_sig_w := 0if CS > TK[26 - 1] cstk_sig_w := 1else if CS < TK[26 - 1] cstk_sig_w := 0if KJ > kumo_high kjcl_sig_w := 1else if KJ < kumo_high kjcl_sig_w := 0bs_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 + cskj_sig_w + cstk_sig_w + kjcl_sig_wlong_pic = one_side_pyr ? ta.crossover(bs_pic_sig, pic_l_s_trig + trig_gap_ibis) : bs_pic_sig > pic_l_s_trig + trig_gap_ibisshort_pic = one_side_pyr ? ta.crossunder(bs_pic_sig, pic_l_s_trig - trig_gap_ibis) : bs_pic_sig < pic_l_s_trig - trig_gap_ibislong_pic_x = long_pic and not long_pic[1]short_pic_x = short_pic and not short_pic[1]//-------------------------------------------------------------------- entry filters -------------------------------------------------------------------f_secureSecurity(_symbol, _res, _src) => request.security(_symbol, _res, _src[repaint == 'Allowed' ? 0 : 1]) // no repainting - taken from PineCoders entry_filter_sig_buy_1 = entry_f_1 == '---' ? true : entry_f_1 == 'TRIX slope filter' ? trix_slo_up_f : entry_f_1 == 'RSI Stochastic filter' ? kd_mom_up_f : entry_f_1 == 'EMA1 x EMA2 filter' ? ema_1x2_buy_f : entry_f_1 == 'HMA slope filter' ? hma_up_f : entry_f_1 == 'MACD(fast) slope filter' ? macd_slope_up_f : 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 Threshold filter' ? adx_above_thres : entry_f_1 == 'DMI filter' ? long_e : entry_f_1 == 'Bar breakout 1 filter' ? bar_sig_1_buy_f : entry_f_1 == 'Bar breakout 2 filter' ? bar_sig_2_buy_f : entry_f_1 == 'Reverse fractal filter' ? rev_dn_fr_buy : entry_f_1 == 'ALMA slope filter' ? alma_slo_up_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 == '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 : entry_f_1 == 'B1/S1 sig' ? buy_strong_B1 : entry_f_1 == 'B2/S2 sig' ? buy_strong_B2 : trueentry_filter_sig_sell_1 = entry_f_1 == '---' ? true : entry_f_1 == 'TRIX slope filter' ? not trix_slo_up_f : entry_f_1 == 'RSI Stochastic filter' ? kd_mom_dn_f : entry_f_1 == 'EMA1 x EMA2 filter' ? not ema_1x2_buy_f : entry_f_1 == 'HMA slope filter' ? not hma_up_f : entry_f_1 == 'MACD(fast) slope filter' ? not macd_slope_up_f : 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 Threshold filter' ? adx_above_thres : entry_f_1 == 'DMI filter' ? short_e : entry_f_1 == 'Bar breakout 1 filter' ? bar_sig_1_sell_f : entry_f_1 == 'Bar breakout 2 filter' ? bar_sig_2_sell_f : entry_f_1 == 'Reverse fractal filter' ? rev_up_fr_sell : entry_f_1 == 'ALMA slope filter' ? not alma_slo_up_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 == '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 : entry_f_1 == 'B1/S1 sig' ? sell_strong_S1 : entry_f_1 == 'B2/S2 sig' ? sell_strong_S2 : trueentry_filter_sig_buy_2 = entry_f_2 == '---' ? true : entry_f_2 == 'TRIX slope filter' ? trix_slo_up_f : entry_f_2 == 'RSI Stochastic filter' ? kd_mom_up_f : entry_f_2 == 'EMA1 x EMA2 filter' ? ema_1x2_buy_f : entry_f_2 == 'HMA slope filter' ? hma_up_f : entry_f_2 == 'MACD(fast) slope filter' ? macd_slope_up_f : 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 Threshold filter' ? adx_above_thres : entry_f_2 == 'DMI filter' ? long_e : entry_f_2 == 'Bar breakout 1 filter' ? bar_sig_1_buy_f : entry_f_2 == 'Bar breakout 2 filter' ? bar_sig_2_buy_f : entry_f_2 == 'Reverse fractal filter' ? rev_dn_fr_buy : entry_f_2 == 'ALMA slope filter' ? alma_slo_up_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 == '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 : entry_f_2 == 'B1/S1 sig' ? buy_strong_B1 : entry_f_2 == 'B2/S2 sig' ? buy_strong_B2 : trueentry_filter_sig_sell_2 = entry_f_2 == '---' ? true : entry_f_2 == 'TRIX slope filter' ? not trix_slo_up_f : entry_f_2 == 'RSI Stochastic filter' ? kd_mom_dn_f : entry_f_2 == 'EMA1 x EMA2 filter' ? not ema_1x2_buy_f : entry_f_2 == 'HMA slope filter' ? not hma_up_f : entry_f_2 == 'MACD(fast) slope filter' ? not macd_slope_up_f : 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 Threshold filter' ? adx_above_thres : entry_f_2 == 'DMI filter' ? long_e : entry_f_2 == 'Bar breakout 1 filter' ? bar_sig_1_sell_f : entry_f_2 == 'Bar breakout 2 filter' ? bar_sig_2_sell_f : entry_f_2 == 'Reverse fractal filter' ? rev_up_fr_sell : entry_f_2 == 'ALMA slope filter' ? not alma_slo_up_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 == '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 : entry_f_2 == 'B1/S1 sig' ? sell_strong_S1 : entry_f_2 == 'B2/S2 sig' ? sell_strong_S2 : true//entry buy filter 1 optionsentry_filter_buy_1 = htf_filt_opt_1 == 'Current' ? entry_filter_sig_buy_1[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_filt_opt_1 == '5m' ? '5' : htf_filt_opt_1 == '10m' ? '10' : htf_filt_opt_1 == '15m' ? '15' : htf_filt_opt_1 == '30m' ? '30' : htf_filt_opt_1 == '1H' ? '60' : htf_filt_opt_1 == '2H' ? '120' : htf_filt_opt_1 == '3H' ? '180' : htf_filt_opt_1 == '4H' ? '240' : htf_filt_opt_1 == '6H' ? '360' : htf_filt_opt_1 == '12H' ? '720' : htf_filt_opt_1 == 'D' ? 'D' : htf_filt_opt_1 == '3D' ? '3D' : htf_filt_opt_1 == 'W' ? 'W' : htf_filt_opt_1 == 'M' ? 'M' : na, entry_filter_sig_buy_1)entry_filter_buy_11 = entry_f_1 == 'Segments filter (no tf filter)' ? segments_buy : entry_f_1 == 'IB/IS sig (no tf filter)' ? long_pic[repaint == 'Allowed' ? 0 : 1] : entry_f_1 == 'Fractals trend lines filter (no tf filter)' ? buy_up_line : true//entry sell filter 1 optionsentry_filter_sell_1 = htf_filt_opt_1 == 'Current' ? entry_filter_sig_sell_1[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_filt_opt_1 == '5m' ? '5' : htf_filt_opt_1 == '10m' ? '10' : htf_filt_opt_1 == '15m' ? '15' : htf_filt_opt_1 == '30m' ? '30' : htf_filt_opt_1 == '1H' ? '60' : htf_filt_opt_1 == '2H' ? '120' : htf_filt_opt_1 == '3H' ? '180' : htf_filt_opt_1 == '4H' ? '240' : htf_filt_opt_1 == '6H' ? '360' : htf_filt_opt_1 == '12H' ? '720' : htf_filt_opt_1 == 'D' ? 'D' : htf_filt_opt_1 == '3D' ? '3D' : htf_filt_opt_1 == 'W' ? 'W' : htf_filt_opt_1 == 'M' ? 'M' : na, entry_filter_sig_sell_1)entry_filter_sell_11 = entry_f_1 == 'Segments filter (no tf filter)' ? segments_sell : entry_f_1 == 'IB/IS sig (no tf filter)' ? short_pic[repaint == 'Allowed' ? 0 : 1] : entry_f_1 == 'Fractals trend lines filter (no tf filter)' ? sell_dn_line : true//entry buy filter 2 optionsentry_filter_buy_2 = htf_filt_opt_2 == 'Current' ? entry_filter_sig_buy_2[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_filt_opt_2 == '5m' ? '5' : htf_filt_opt_2 == '10m' ? '10' : htf_filt_opt_2 == '15m' ? '15' : htf_filt_opt_2 == '30m' ? '30' : htf_filt_opt_2 == '1H' ? '60' : htf_filt_opt_2 == '2H' ? '120' : htf_filt_opt_2 == '3H' ? '180' : htf_filt_opt_2 == '4H' ? '240' : htf_filt_opt_2 == '6H' ? '360' : htf_filt_opt_2 == '12H' ? '720' : htf_filt_opt_2 == 'D' ? 'D' : htf_filt_opt_2 == '3D' ? '3D' : htf_filt_opt_2 == 'W' ? 'W' : htf_filt_opt_2 == 'M' ? 'M' : na, entry_filter_sig_buy_2)entry_filter_buy_22 = entry_f_2 == 'Fractals trend lines filter (no tf filter)' ? buy_up_line : entry_f_2 == 'Segments filter (no tf filter)' ? segments_buy : entry_f_2 == 'IB/IS sig (no tf filter)' ? long_pic[repaint == 'Allowed' ? 0 : 1] : true//entry sell filter 2 optionsentry_filter_sell_2 = htf_filt_opt_2 == 'Current' ? entry_filter_sig_sell_2[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_filt_opt_2 == '5m' ? '5' : htf_filt_opt_2 == '10m' ? '10' : htf_filt_opt_2 == '15m' ? '15' : htf_filt_opt_2 == '30m' ? '30' : htf_filt_opt_2 == '1H' ? '60' : htf_filt_opt_2 == '2H' ? '120' : htf_filt_opt_2 == '3H' ? '180' : htf_filt_opt_2 == '4H' ? '240' : htf_filt_opt_2 == '6H' ? '360' : htf_filt_opt_2 == '12H' ? '720' : htf_filt_opt_2 == 'D' ? 'D' : htf_filt_opt_2 == '3D' ? '3D' : htf_filt_opt_2 == 'W' ? 'W' : htf_filt_opt_2 == 'M' ? 'M' : na, entry_filter_sig_sell_2)entry_filter_sell_22 = entry_f_2 == 'Fractals trend lines filter (no tf filter)' ? sell_dn_line : entry_f_2 == 'Segments filter (no tf filter)' ? segments_sell : entry_f_2 == 'IB/IS sig (no tf filter)' ? short_pic[repaint == 'Allowed' ? 0 : 1] : true//-------------------------------------------------------------------- exit filters -----------------------------------------------------------------------exit_filter_sig_buy_1 = exit_f_1 == '---' ? false : exit_f_1 == 'TRIX slope exit' ? trix_slo_up_x : exit_f_1 == 'RSI Stochastic exit' ? kd_mom_up_x : exit_f_1 == 'EMA1 x EMA2 exit' ? ema_1x2_buy_x : exit_f_1 == 'HMA slope exit' ? hma_up_x : exit_f_1 == 'Reverse bar exit' ? rev_bar_sig_buy : exit_f_1 == 'Reverse fractal exit' ? rev_dn_fr_buy : exit_f_1 == 'Bar breakout 2 exit' ? bar_sig_2_buy : exit_f_1 == 'MACD(fast) slope exit' ? macd_slope_up_x : 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_x : exit_f_1 == 'SMA exit' ? sma_buy_x : exit_f_1 == 'ADX Threshold exit' ? adx_thres_f_x : exit_f_1 == 'Cloud exit' ? kumo_buy_x : exit_f_1 == 'Kijun exit' ? kijun_buy_x : falseexit_filter_sig_sell_1 = exit_f_1 == '---' ? false : exit_f_1 == 'TRIX slope exit' ? trix_slo_dn_x : exit_f_1 == 'RSI Stochastic exit' ? kd_mom_dn_x : exit_f_1 == 'EMA1 x EMA2 exit' ? ema_1x2_sell_x : exit_f_1 == 'HMA slope exit' ? hma_dn_x : exit_f_1 == 'Reverse bar exit' ? rev_bar_sig_sell : exit_f_1 == 'Reverse fractal exit' ? rev_up_fr_sell : exit_f_1 == 'Bar breakout 2 exit' ? bar_sig_2_sell : exit_f_1 == 'MACD(fast) slope exit' ? macd_slope_dn_x : 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_x : exit_f_1 == 'SMA exit' ? sma_sell_x : exit_f_1 == 'ADX Threshold exit' ? adx_thres_f_x : exit_f_1 == 'Cloud exit' ? kumo_sell_x : exit_f_1 == 'Kijun exit' ? kijun_sell_x : falseexit_filter_sig_buy_2 = exit_f_2 == '---' ? false : exit_f_2 == 'TRIX slope exit' ? trix_slo_up_x : exit_f_2 == 'RSI Stochastic exit' ? kd_mom_up_x : exit_f_2 == 'EMA1 x EMA2 exit' ? ema_1x2_buy_x : exit_f_2 == 'HMA slope exit' ? hma_up_x : exit_f_2 == 'Reverse bar exit' ? rev_bar_sig_buy : exit_f_2 == 'Reverse fractal exit' ? rev_dn_fr_buy : exit_f_2 == 'Bar breakout 2 exit' ? bar_sig_2_buy : exit_f_2 == 'MACD(fast) slope exit' ? macd_slope_up_x : 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_x : exit_f_2 == 'SMA exit' ? sma_buy_x : exit_f_2 == 'ADX Threshold exit' ? adx_thres_f_x : exit_f_2 == 'Cloud exit' ? kumo_buy_x : exit_f_2 == 'Kijun exit' ? kijun_buy_x : falseexit_filter_sig_sell_2 = exit_f_2 == '---' ? false : exit_f_2 == 'TRIX slope exit' ? trix_slo_dn_x : exit_f_2 == 'RSI Stochastic exit' ? kd_mom_dn_x : exit_f_2 == 'EMA1 x EMA2 exit' ? ema_1x2_sell_x : exit_f_2 == 'HMA slope exit' ? hma_dn_x : exit_f_2 == 'Reverse bar exit' ? rev_bar_sig_sell : exit_f_2 == 'Reverse fractal exit' ? rev_up_fr_sell : exit_f_2 == 'Bar breakout 2 exit' ? bar_sig_2_sell : exit_f_2 == 'MACD(fast) slope exit' ? macd_slope_dn_x : 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_x : exit_f_2 == 'SMA exit' ? sma_sell_x : exit_f_2 == 'ADX Threshold exit' ? adx_thres_f_x : exit_f_2 == 'Cloud exit' ? kumo_sell_x : exit_f_2 == 'Kijun exit' ? kijun_sell_x : false//short exit buy filter 1 optionsexit_filter_buy_1 = htf_exit_opt_1 == 'Current' ? exit_filter_sig_buy_1[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_exit_opt_1 == '5m' ? '5' : htf_exit_opt_1 == '10m' ? '10' : htf_exit_opt_1 == '15m' ? '15' : htf_exit_opt_1 == '30m' ? '30' : htf_exit_opt_1 == '1H' ? '60' : htf_exit_opt_1 == '2H' ? '120' : htf_exit_opt_1 == '3H' ? '180' : htf_exit_opt_1 == '4H' ? '240' : htf_exit_opt_1 == '6H' ? '360' : htf_exit_opt_1 == '12H' ? '720' : htf_exit_opt_1 == 'D' ? 'D' : htf_exit_opt_1 == '3D' ? '3D' : htf_exit_opt_1 == 'W' ? 'W' : htf_exit_opt_1 == 'M' ? 'M' : na, exit_filter_sig_buy_1)exit_filter_sig_buy_11 = exit_f_1 == 'IB/IS exit (no tf filter)' ? long_pic_x[repaint == 'Allowed' ? 0 : 1] : false//long exit sell filter 1 optionsexit_filter_sell_1 = htf_exit_opt_1 == 'Current' ? exit_filter_sig_sell_1[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_exit_opt_1 == '5m' ? '5' : htf_exit_opt_1 == '10m' ? '10' : htf_exit_opt_1 == '15m' ? '15' : htf_exit_opt_1 == '30m' ? '30' : htf_exit_opt_1 == '1H' ? '60' : htf_exit_opt_1 == '2H' ? '120' : htf_exit_opt_1 == '3H' ? '180' : htf_exit_opt_1 == '4H' ? '240' : htf_exit_opt_1 == '6H' ? '360' : htf_exit_opt_1 == '12H' ? '720' : htf_exit_opt_1 == 'D' ? 'D' : htf_exit_opt_1 == '3D' ? '3D' : htf_exit_opt_1 == 'W' ? 'W' : htf_exit_opt_1 == 'M' ? 'M' : na, exit_filter_sig_sell_1)exit_filter_sig_sell_11 = exit_f_1 == 'IB/IS exit (no tf filter)' ? short_pic_x[repaint == 'Allowed' ? 0 : 1] : false//short exit buy filter 2 optionsexit_filter_buy_2 = htf_exit_opt_2 == 'Current' ? exit_filter_sig_buy_2[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_exit_opt_2 == '5m' ? '5' : htf_exit_opt_2 == '10m' ? '10' : htf_exit_opt_2 == '15m' ? '15' : htf_exit_opt_2 == '30m' ? '30' : htf_exit_opt_2 == '1H' ? '60' : htf_exit_opt_2 == '2H' ? '120' : htf_exit_opt_2 == '3H' ? '180' : htf_exit_opt_2 == '4H' ? '240' : htf_exit_opt_2 == '6H' ? '360' : htf_exit_opt_2 == '12H' ? '720' : htf_exit_opt_2 == 'D' ? 'D' : htf_exit_opt_2 == '3D' ? '3D' : htf_exit_opt_2 == 'W' ? 'W' : htf_exit_opt_2 == 'M' ? 'M' : na, exit_filter_sig_buy_2)exit_filter_sig_buy_22 = exit_f_2 == 'IB/IS exit (no tf filter)' ? long_pic_x[repaint == 'Allowed' ? 0 : 1] : false//long exit sell filter 2 optionsexit_filter_sell_2 = htf_exit_opt_2 == 'Current' ? exit_filter_sig_sell_2[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_exit_opt_2 == '5m' ? '5' : htf_exit_opt_2 == '10m' ? '10' : htf_exit_opt_2 == '15m' ? '15' : htf_exit_opt_2 == '30m' ? '30' : htf_exit_opt_2 == '1H' ? '60' : htf_exit_opt_2 == '2H' ? '120' : htf_exit_opt_2 == '3H' ? '180' : htf_exit_opt_2 == '4H' ? '240' : htf_exit_opt_2 == '6H' ? '360' : htf_exit_opt_2 == '12H' ? '720' : htf_exit_opt_2 == 'D' ? 'D' : htf_exit_opt_2 == '3D' ? '3D' : htf_exit_opt_2 == 'W' ? 'W' : htf_exit_opt_2 == 'M' ? 'M' : na, exit_filter_sig_sell_2)exit_filter_sig_sell_22 = exit_f_2 == 'IB/IS exit (no tf filter)' ? short_pic_x[repaint == 'Allowed' ? 0 : 1] : false//---------------------------------------------------------------------- entry signals -------------------------------------------------------------------entry_opt_sig_buy_1 = X_opt == '---' ? na : X_opt == 'TRIX slope sig' ? trix_buy_s : X_opt == 'EMA1 x EMA2 sig' ? ema_1x2_buy_s : X_opt == 'HMA slope sig' ? hma_up_e : X_opt == 'DMI ADX-slope sig' ? adx_up_c : X_opt == 'DMI ADX mod sig' ? long_1 : X_opt == 'DMI ADX classic sig' ? long_2 : X_opt == 'Pin bar sig' ? p_bar_buy : 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 breakout 1 sig' ? bar_sig_1_buy : X_opt == 'Bar breakout 2 sig' ? bar_sig_2_buy : X_opt == 'Higher-low/lower-high bar sig' ? hllh_buy : X_opt == 'Entry on every bar-open sig' ? open_buy : X_opt == 'SMA sig' ? sma_buy : X_opt == 'Fractals sig' ? fr_upx : X_opt == 'Reverse fractal sig' ? rev_dn_fr_buy : X_opt == 'MACD(fast) slope sig' ? macd_slope_up_e : X_opt == 'RSI50 sig' ? rsi_f_buy : X_opt == 'Parabolic SAR sig' ? psar_buy : X_opt == 'ALMA slope sig' ? alma_slo_up_e : X_opt == 'SuperTrend sig' ? sup_buy : X_opt == 'Price X Kijun sig' ? kijun_buy : X_opt == 'Price X Kumo sig' ? kumo_buy : X_opt == 'Kumo flip sig' ? kumo_flip_buy : X_opt == 'Chikou X price sig' ? chikou_X_price_buy : X_opt == 'Chikou X Kumo sig' ? chikou_X_kumo_buy : X_opt == 'Price X Tenkan sig' ? price_X_tenkan_buy : X_opt == 'Tenkan X Kumo sig' ? tenkan_X_kumo_buy : X_opt == 'Tenkan X Kijun sig' ? tenkan_X_kijun_buy : X_opt == 'B1/S1 sig' ? buy_strong_B1 : X_opt == 'B2/S2 sig' ? buy_strong_B2 : naentry_opt_sig_sell_1 = X_opt == '---' ? na : X_opt == 'TRIX slope sig' ? trix_sell_s : X_opt == 'EMA1 x EMA2 sig' ? ema_1x2_sell_s : X_opt == 'HMA slope sig' ? hma_dn_e : X_opt == 'DMI ADX-slope sig' ? adx_dn_c : X_opt == 'DMI ADX mod sig' ? short_1 : X_opt == 'DMI ADX classic sig' ? short_2 : X_opt == 'Pin bar sig' ? p_bar_sell : 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 breakout 1 sig' ? bar_sig_1_sell : X_opt == 'Bar breakout 2 sig' ? bar_sig_2_sell : X_opt == 'Higher-low/lower-high bar sig' ? hllh_sell : X_opt == 'Entry on every bar-open sig' ? open_sell : X_opt == 'SMA sig' ? sma_sell : X_opt == 'Fractals sig' ? fr_dnx : X_opt == 'Reverse fractal sig' ? rev_up_fr_sell : X_opt == 'MACD(fast) slope sig' ? macd_slope_dn_e : X_opt == 'RSI50 sig' ? rsi_f_sell : X_opt == 'Parabolic SAR sig' ? psar_sell : X_opt == 'ALMA slope sig' ? alma_slo_dn_e : X_opt == 'SuperTrend sig' ? sup_sell : X_opt == 'Price X Kijun sig' ? kijun_sell : X_opt == 'Price X Kumo sig' ? kumo_sell : X_opt == 'Kumo flip sig' ? kumo_flip_sell : X_opt == 'Chikou X price sig' ? chikou_X_price_sell : X_opt == 'Chikou X Kumo sig' ? chikou_X_kumo_sell : X_opt == 'Price X Tenkan sig' ? price_X_tenkan_sell : X_opt == 'Tenkan X Kumo sig' ? tenkan_X_kumo_sell : X_opt == 'Tenkan X Kijun sig' ? tenkan_X_kijun_sell : X_opt == 'B1/S1 sig' ? sell_strong_S1 : X_opt == 'B2/S2 sig' ? sell_strong_S2 : naentry_opt_sig_buy_2 = X_opt_2 == '---' ? na : X_opt_2 == 'TRIX slope sig' ? trix_buy_s : X_opt_2 == 'EMA1 x EMA2 sig' ? ema_1x2_buy_s : X_opt_2 == 'HMA slope sig' ? hma_up_e : X_opt_2 == 'DMI ADX-slope sig' ? adx_up_c : X_opt_2 == 'DMI ADX mod sig' ? long_1 : X_opt_2 == 'DMI ADX classic sig' ? long_2 : X_opt_2 == 'Pin bar sig' ? p_bar_buy : X_opt_2 == 'Inside bar sig' ? i_bar_buy : X_opt_2 == 'Outside bar sig' ? o_bar_buy : X_opt_2 == 'Sandwich bar sig' ? s_bar_buy : X_opt_2 == 'Bar breakout 1 sig' ? bar_sig_1_buy : X_opt_2 == 'Bar breakout 2 sig' ? bar_sig_2_buy : X_opt_2 == 'Higher-low/lower-high bar sig' ? hllh_buy : X_opt_2 == 'Entry on every bar-open sig' ? open_buy : X_opt_2 == 'SMA sig' ? sma_buy : X_opt_2 == 'Fractals sig' ? fr_upx : X_opt_2 == 'Reverse fractal sig' ? rev_dn_fr_buy : X_opt_2 == 'MACD(fast) slope sig' ? macd_slope_up_e : X_opt_2 == 'RSI50 sig' ? rsi_f_buy : X_opt_2 == 'Parabolic SAR sig' ? psar_buy : X_opt_2 == 'ALMA slope sig' ? alma_slo_up_e : X_opt_2 == 'SuperTrend sig' ? sup_buy : X_opt_2 == 'Price X Kijun sig' ? kijun_buy : X_opt_2 == 'Price X Kumo sig' ? kumo_buy : X_opt_2 == 'Kumo flip sig' ? kumo_flip_buy : X_opt_2 == 'Chikou X price sig' ? chikou_X_price_buy : X_opt_2 == 'Chikou X Kumo sig' ? chikou_X_kumo_buy : X_opt_2 == 'Price X Tenkan sig' ? price_X_tenkan_buy : X_opt_2 == 'Tenkan X Kumo sig' ? tenkan_X_kumo_buy : X_opt_2 == 'Tenkan X Kijun sig' ? tenkan_X_kijun_buy : X_opt_2 == 'B1/S1 sig' ? buy_strong_B1 : X_opt_2 == 'B2/S2 sig' ? buy_strong_B2 : naentry_opt_sig_sell_2 = X_opt_2 == '---' ? na : X_opt_2 == 'TRIX slope sig' ? trix_sell_s : X_opt_2 == 'EMA1 x EMA2 sig' ? ema_1x2_sell_s : X_opt_2 == 'HMA slope sig' ? hma_dn_e : X_opt_2 == 'DMI ADX-slope sig' ? adx_dn_c : X_opt_2 == 'DMI ADX mod sig' ? short_1 : X_opt_2 == 'DMI ADX classic sig' ? short_2 : X_opt_2 == 'Pin bar sig' ? p_bar_sell : X_opt_2 == 'Inside bar sig' ? i_bar_sell : X_opt_2 == 'Outside bar sig' ? o_bar_sell : X_opt_2 == 'Sandwich bar sig' ? s_bar_sell : X_opt_2 == 'Bar breakout 1 sig' ? bar_sig_1_sell : X_opt_2 == 'Bar breakout 2 sig' ? bar_sig_2_sell : X_opt_2 == 'Higher-low/lower-high bar sig' ? hllh_sell : X_opt_2 == 'Entry on every bar-open sig' ? open_sell : X_opt_2 == 'SMA sig' ? sma_sell : X_opt_2 == 'Fractals sig' ? fr_dnx : X_opt_2 == 'Reverse fractal sig' ? rev_up_fr_sell : X_opt_2 == 'MACD(fast) slope sig' ? macd_slope_dn_e : X_opt_2 == 'RSI50 sig' ? rsi_f_sell : X_opt_2 == 'Parabolic SAR sig' ? psar_sell : X_opt_2 == 'ALMA slope sig' ? alma_slo_dn_e : X_opt_2 == 'SuperTrend sig' ? sup_sell : X_opt_2 == 'Price X Kijun sig' ? kijun_sell : X_opt_2 == 'Price X Kumo sig' ? kumo_sell : X_opt_2 == 'Kumo flip sig' ? kumo_flip_sell : X_opt_2 == 'Chikou X price sig' ? chikou_X_price_sell : X_opt_2 == 'Chikou X Kumo sig' ? chikou_X_kumo_sell : X_opt_2 == 'Price X Tenkan sig' ? price_X_tenkan_sell : X_opt_2 == 'Tenkan X Kumo sig' ? tenkan_X_kumo_sell : X_opt_2 == 'Tenkan X Kijun sig' ? tenkan_X_kijun_sell : X_opt_2 == 'B1/S1 sig' ? sell_strong_S1 : X_opt_2 == 'B2/S2 sig' ? sell_strong_S2 : na// buy signal options 1opt_sig_buy_1 = htf_entr_opt_1 == 'Current' ? entry_opt_sig_buy_1[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_entr_opt_1 == '5m' ? '5' : htf_entr_opt_1 == '10m' ? '10' : htf_entr_opt_1 == '15m' ? '15' : htf_entr_opt_1 == '30m' ? '30' : htf_entr_opt_1 == '1H' ? '60' : htf_entr_opt_1 == '2H' ? '120' : htf_entr_opt_1 == '3H' ? '180' : htf_entr_opt_1 == '4H' ? '240' : htf_entr_opt_1 == '6H' ? '360' : htf_entr_opt_1 == '12H' ? '720' : htf_entr_opt_1 == 'D' ? 'D' : htf_entr_opt_1 == '3D' ? '3D' : htf_entr_opt_1 == 'W' ? 'W' : htf_entr_opt_1 == 'M' ? 'M' : na, entry_opt_sig_buy_1)opt_sig_buy_11 = X_opt == 'Grid - counter trend sig (no tf filter)' ? grid_ct_buy : X_opt == 'Grid - reentry sig (no tf filter)' ? grid_re_buy : X_opt == 'Fractals trend lines sig (no tf filter)' ? buy_up_line : X_opt == 'Segments sig (no tf filter)' ? segments_buy : X_opt == 'CB/CS sig (no tf filter)' ? long_c[repaint == 'Allowed' ? 0 : 1] : X_opt == 'IB/IS sig (no tf filter)' ? long_pic[repaint == 'Allowed' ? 0 : 1] : na// sell signal options 1opt_sig_sell_1 = htf_entr_opt_1 == 'Current' ? entry_opt_sig_sell_1[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_entr_opt_1 == '5m' ? '5' : htf_entr_opt_1 == '10m' ? '10' : htf_entr_opt_1 == '15m' ? '15' : htf_entr_opt_1 == '30m' ? '30' : htf_entr_opt_1 == '1H' ? '60' : htf_entr_opt_1 == '2H' ? '120' : htf_entr_opt_1 == '3H' ? '180' : htf_entr_opt_1 == '4H' ? '240' : htf_entr_opt_1 == '6H' ? '360' : htf_entr_opt_1 == '12H' ? '720' : htf_entr_opt_1 == 'D' ? 'D' : htf_entr_opt_1 == '3D' ? '3D' : htf_entr_opt_1 == 'W' ? 'W' : htf_entr_opt_1 == 'M' ? 'M' : na, entry_opt_sig_sell_1)opt_sig_sell_11 = X_opt == 'Grid - counter trend sig (no tf filter)' ? grid_ct_sell : X_opt == 'Grid - reentry sig (no tf filter)' ? grid_re_sell : X_opt == 'Fractals trend lines sig (no tf filter)' ? sell_dn_line : X_opt == 'Segments sig (no tf filter)' ? segments_sell : X_opt == 'CB/CS sig (no tf filter)' ? short_c[repaint == 'Allowed' ? 0 : 1] : X_opt == 'IB/IS sig (no tf filter)' ? short_pic[repaint == 'Allowed' ? 0 : 1] : na// buy signal options 2opt_sig_buy_2 = htf_entr_opt_2 == 'Current' ? entry_opt_sig_buy_2[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_entr_opt_2 == '5m' ? '5' : htf_entr_opt_2 == '10m' ? '10' : htf_entr_opt_2 == '15m' ? '15' : htf_entr_opt_2 == '30m' ? '30' : htf_entr_opt_2 == '1H' ? '60' : htf_entr_opt_2 == '2H' ? '120' : htf_entr_opt_2 == '3H' ? '180' : htf_entr_opt_2 == '4H' ? '240' : htf_entr_opt_2 == '6H' ? '360' : htf_entr_opt_2 == '12H' ? '720' : htf_entr_opt_2 == 'D' ? 'D' : htf_entr_opt_2 == '3D' ? '3D' : htf_entr_opt_2 == 'W' ? 'W' : htf_entr_opt_2 == 'M' ? 'M' : na, entry_opt_sig_buy_2)opt_sig_buy_22 = X_opt_2 == 'Grid - counter trend sig (no tf filter)' ? grid_ct_buy : X_opt_2 == 'Grid - reentry sig (no tf filter)' ? grid_re_buy : X_opt_2 == 'Fractals trend lines sig (no tf filter)' ? buy_up_line : X_opt_2 == 'Segments sig (no tf filter)' ? segments_buy : X_opt_2 == 'CB/CS sig (no pyr, no tf filter)' ? long_c[repaint == 'Allowed' ? 0 : 1] : X_opt_2 == 'IB/IS sig (no pyr, no tf filter)' ? long_pic[repaint == 'Allowed' ? 0 : 1] : na// sell signal options 2opt_sig_sell_2 = htf_entr_opt_2 == 'Current' ? entry_opt_sig_sell_2[repaint == 'Allowed' ? 0 : 1] : f_secureSecurity(syminfo.tickerid, htf_entr_opt_2 == '5m' ? '5' : htf_entr_opt_2 == '10m' ? '10' : htf_entr_opt_2 == '15m' ? '15' : htf_entr_opt_2 == '30m' ? '30' : htf_entr_opt_2 == '1H' ? '60' : htf_entr_opt_2 == '2H' ? '120' : htf_entr_opt_2 == '3H' ? '180' : htf_entr_opt_2 == '4H' ? '240' : htf_entr_opt_2 == '6H' ? '360' : htf_entr_opt_2 == '12H' ? '720' : htf_entr_opt_2 == 'D' ? 'D' : htf_entr_opt_2 == '3D' ? '3D' : htf_entr_opt_2 == 'W' ? 'W' : htf_entr_opt_2 == 'M' ? 'M' : na, entry_opt_sig_sell_2)opt_sig_sell_22 = X_opt_2 == 'Grid - counter trend sig (no tf filter)' ? grid_ct_sell : X_opt_2 == 'Grid - reentry sig (no tf filter)' ? grid_re_sell : X_opt_2 == 'Fractals trend lines sig (no tf filter)' ? sell_dn_line : X_opt_2 == 'Segments sig (no tf filter)' ? segments_sell : X_opt_2 == 'CB/CS sig (no tf filter)' ? short_c[repaint == 'Allowed' ? 0 : 1] : X_opt_2 == 'IB/IS sig (no tf filter)' ? short_pic[repaint == 'Allowed' ? 0 : 1] : na//---------------------------------------------------- Take profit, stop loss and trailing price --------------------------------------------------------//take profit of average position priceatr_sec = request.security(syminfo.tickerid, atr_tf, ta.atr(atr_l))atr_calc = atr_sec * atr_facttp_step = 0.tp_step := nz(high > tp_step[1] + atr_calc or low < tp_step[1] - atr_calc ? close : tp_step[1])tp_step_l = tp_step > tp_step[1]tp_step_s = tp_step < tp_step[1]av_profit_l = close - strategy.position_avg_price > atr_calc and tp_step_lav_profit_s = strategy.position_avg_price - close > atr_calc and tp_step_s//stop loss of average position priceatr_sec_l = request.security(syminfo.tickerid, atr_tf_l, ta.atr(atr_l_l))atr_calc_l = atr_sec_l * atr_fact_lsl_step = 0.sl_step := nz(high > sl_step[1] + atr_calc_l or low < sl_step[1] - atr_calc_l ? close : sl_step[1])sl_step_l = sl_step < sl_step[1]sl_step_s = sl_step > sl_step[1]sl_t_l = strategy.position_avg_price - close > atr_calc_l and sl_step_lsl_t_s = close - strategy.position_avg_price > atr_calc_l and sl_step_s//average position price lineplot(plot_avg_price ? strategy.position_avg_price : na, linewidth=1, color=color.new(color.blue, 30), title='position_avg_price')//---------------------------------------------------------------- strategy entry / exit -----------------------------------------------------------------long = entry_type != 'Short' // long or bothshort = entry_type != 'Long' // short or bothboth = entry_type == 'Both' // both//exit filterexit_long_1 = exit_filter_sell_1 or exit_filter_sell_2 or exit_filter_sig_sell_11 or exit_filter_sig_sell_22exit_short_1 = exit_filter_buy_1 or exit_filter_buy_2 or exit_filter_sig_buy_11 or exit_filter_sig_buy_22//opposite signal as exit signalexit_long_2 = opt_sig_sell_1 or opt_sig_sell_2 or opt_sig_sell_11 or opt_sig_sell_22exit_short_2 = opt_sig_buy_1 or opt_sig_buy_2 or opt_sig_buy_11 or opt_sig_buy_22//long entry conditions for the 1st and the 2nd entry signalentry_long_1 = (opt_sig_buy_11 or opt_sig_buy_1) and entry_filter_buy_1 and entry_filter_buy_2 and entry_filter_buy_11 and entry_filter_buy_22 and not exit_long_1entry_long_2 = (opt_sig_buy_22 or opt_sig_buy_2) and entry_filter_buy_1 and entry_filter_buy_2 and entry_filter_buy_11 and entry_filter_buy_22 and not exit_long_1//short entry conditions for the 1st and the 2nd entry signalentry_short_1 = (opt_sig_sell_11 or opt_sig_sell_1) and entry_filter_sell_1 and entry_filter_sell_2 and entry_filter_sell_11 and entry_filter_sell_22 and not exit_short_1entry_short_2 = (opt_sig_sell_22 or opt_sig_sell_2) and entry_filter_sell_1 and entry_filter_sell_2 and entry_filter_sell_11 and entry_filter_sell_22 and not exit_short_1if backtest_period() if long if entry_long_1 strategy.entry('os_b', strategy.long) // 1st entry signal if one_side_pyr and entry_long_2 strategy.entry('os_b', strategy.long) // 2nd entry signal when in pyramiding mode if not both and not one_side_pyr ? exit_long_2 : exit_long_1 strategy.close('os_b') // opposite signal or exit-filter signal exit if not both and one_side_pyr ? exit_long_1 and not exit_long_1[1] : na strategy.close('os_b') // exit-filter exit if av_tp_en and av_profit_l strategy.close('os_b', qty_percent= av_tp_qty) // average take profit if sl_en and sl_t_l strategy.close('os_b', qty_percent= av_sl_qty) // average stop loss if short if entry_short_1 strategy.entry('os_s', strategy.short) if one_side_pyr and entry_short_2 strategy.entry('os_s', strategy.short) if not both and not one_side_pyr ? exit_short_2 : exit_short_1 strategy.close('os_s') if not both and one_side_pyr ? exit_short_1 and not exit_short_1[1] : na strategy.close('os_s') if av_tp_en and av_profit_s strategy.close('os_s', qty_percent= av_tp_qty) if sl_en and sl_t_s strategy.close('os_s', qty_percent= av_sl_qty) //alert messages - same conditions like strategy....() - live tradingif long and entry_long_1 or long and (one_side_pyr ? entry_long_2 : na) alert(message= 'BybitAPI(BTCUSD) { continue(if=positionShort); market(position= 0); } BybitAPI(BTCUSD) { wait(0.5s); market(side=buy, amount=' + str.tostring(lot_size) + '); } \n #bot', freq= alert.freq_once_per_bar)if short and entry_short_1 or short and (one_side_pyr ? entry_short_2 : na) alert(message= 'BybitAPI(BTCUSD) { continue(if=positionLong); market(position= 0); } BybitAPI(BTCUSD) { wait(0.5s); market(side=sell, amount=' + str.tostring(lot_size) + '); } \n #bot', freq= alert.freq_once_per_bar)if long and (not both and not one_side_pyr ? exit_long_2 : exit_long_1) or long and (not both and one_side_pyr ? exit_long_1 and not exit_long_1[1] : na) or short and (not both and not one_side_pyr ? exit_short_2 : exit_short_1) or short and (not both and one_side_pyr ? exit_short_1 and not exit_short_1[1] : na) alert(message= 'BybitAPI(BTCUSD) { market(position= 0 %p); } \n #bot', freq= alert.freq_once_per_bar)var float av_tp_qty_var = 100 - av_tp_qty // calc because of alertatron syntax stringvar float av_sl_qty_var = 100 - av_sl_qtyif long and (av_tp_en ? av_profit_l : na) or short and (av_tp_en ? av_profit_s : na) alert(message= 'BybitAPI(BTCUSD) { market(position=' + str.tostring(av_tp_qty_var) + '%p); } \n #bot', freq= alert.freq_once_per_bar)if long and (sl_en ? sl_t_l : na) or short and (sl_en ? sl_t_s : na) alert(message= 'BybitAPI(BTCUSD) { market(position=' + str.tostring(av_sl_qty_var) + '%p); } \n #bot', freq= alert.freq_once_per_bar)