Strategy · Pine Script v4 · Own pane

NFI v7.2

by koradiyakaushal· code credited to kaushal

NFI v7.2 is a Pine Script adaptation of the popular NostalgiaForInfinity algorithmic trading strategy originally built for Freqtrade.

View on GitHub

Repaints

GitHub stars12on the repository
Pine versionv4older, still runs
Lines of code1,149
Settings7inputs
LicenceMIT
Last update5 years ago30 Jul 2021

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

1,149 lines of Pine Script v4 from NostalgiaForInfinity/[STRAT]nfinext(v7.2).pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

[STRAT]nfinext(v7.2).pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kaushal

// ###########################################################################################################
// ##                NostalgiaForInfinityV7+ by iterativ                                                     ##
// ##                                                                                                       ##
// ##    Strategy for Freqtrade https://github.com/freqtrade/freqtrade                                      ##
// ##                                                                                                       ##
// ###########################################################################################################
// ##               DONATIONS                                                                               ##
// ##                                                                                                       ##
// ##   Absolutely not required. However, will be accepted as a token of appreciation.                      ##
// ##                                                                                                       ##
// ##   BTC: bc1qvflsvddkmxh7eqhc4jyu5z5k6xcw3ay8jl49sk                                                     ##
// ##   ETH (ERC20): 0x83D3cFb8001BDC5d2211cBeBB8cB3461E5f7Ec91                                             ##
// ##   BEP20/BSC (ETH, BNB, ...): 0x86A0B21a20b39d16424B7c8003E4A7e12d78ABEe                               ##
// ##                                                                                                       ##
// ###########################################################################################################


//@version=4

SystemName = "NFI v7.2"
is_overlay = true
InitCapital = 100
InitPosition = 100
InitCommission = 0
CalcOnorderFills = false

strategy(title=SystemName, shorttitle=SystemName, 
 initial_capital=InitCapital, default_qty_type=strategy.percent_of_equity, 
 default_qty_value=InitPosition,commission_type=strategy.commission.percent, commission_value=InitCommission, calc_on_order_fills=CalcOnorderFills, 
 precision=6, max_lines_count=500, max_labels_count=500, overlay=is_overlay, max_bars_back=20)

// study(SystemName, overlay=true)
// ————— Date range filtering

informative_tf = input(title="Informative Timeframe", type=input.resolution, defval="60")

_master_pair = input(title="Master Pair", type=input.symbol, defval="BINANCE:BTCUSDT", tooltip="Select the ticker you want to use as master pair.")

has_BTC_base_tf = input(true, "Has BTC BASE TF?")
has_BTC_info_tf = input(true, "Has BTC Informative TF?")

DateFilter = input(false, "═════════════ Date Range Filtering", group="Date")

// ————— Syntax coming from https://www.tradingview.com/blog/en/new-parameter-for-date-input-added-to-pine-21812/
i_startTime = input(defval = timestamp("01 Jun 2021 00:00 +0000"), title = "Start Time", type = input.time, group="Date")
i_endTime = input(defval = timestamp("30 Dec 2021 23:30 +0000"), title = "End Time", type = input.time, group="Date")

TradeDateIsAllowed() => DateFilter ? time >= i_startTime and time <= i_endTime : true


// Functions
f_security(_symbol, _res, _src, _repaint) => security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])

ema_difference(window_short, window_long) =>
    sma1 = ema(close, window_short)
    sma2 = ema(close, window_long)
    diff = (sma1 - sma2)/close*100
    diff

sma_dec_1h(close, length) => 
    sma_dec = false
    if (sma(close, length) - sma(close, length)[20])
        sma_dec := true
    sma_dec

chopiness(length) =>
    ci = 100 * log10(sum(atr(1), length) / (highest(length) - lowest(length))) / log10(length)
    ci

chaikin_money_flow(open, high, low, close, volume, length) => 
    ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume
    mf = sum(ad, length) / sum(volume, length)
    mf

zema(close, period) =>
    ema1 = ema(close, period)
    ema2 = ema(ema1, period)
    z = (ema1 - ema2) + ema1
    z

wiliyam_r(high, low, close, period) => 
    highest_high = highest(high, period)
    lowest_low = lowest(low, period)
    r = (close - highest_high)/(highest_high-lowest_low) * 100
    r

stoch_rsi(close, timeperiod, fastk_period, fastd_period) => 
    rsi1 = rsi(close, 14)
    _srsi_k = sma(stoch(rsi1, rsi1, rsi1, timeperiod), fastk_period)
    _srsi_d = sma(_srsi_k, fastd_period)
    [_srsi_k, _srsi_d]

zlema(close, period) =>
    lag = floor((period - 1) / 2)
    ema_data = close + (close - close[lag])
    zl= ema(ema_data, period)
    zl

zlhull(close, period) =>
    lag = floor((period - 1) / 2)
    wma_data = close + (close - close[lag])
    wma1 = 2 * wma(wma_data, floor(period/2))
    wma2 = wma(wma_data, period)
    zl = wma((wma1 - wma2), round(sqrt(period)))
    zl

hull(close, period) =>
    wma1 = 2 * wma(close, floor(period/2))
    wma2 = wma(close, period)
    hl = wma((wma1-wma2), round(sqrt(period)))
    hl
f_vwma(close, volume, length) =>
    pv = close * volume
    vwma = sma(pv, length)/sma(volume, length)
    vwma

moderi(close, volume, lenslowMA) =>
    slowMA = ema(f_vwma(close, volume, lenslowMA), lenslowMA)
    diff = (slowMA >= slowMA[1]) ? true : false
    diff

range_percent_change(open, high, low, close, method, length) =>
    c = 0.0
    if method == "HL"
        c := highest(high, length) - lowest(low, length) / lowest(low, length) 
    else
        c := highest(open, length) - lowest(close, length) / lowest(close, length) 
    c

top_percent_change(open, close, length) =>
    tp_change = 0.0
    if length == 0
        tp_change := ((open - close)/close)
    else
        tp_change := ((highest(open, length) - close)/close)
    tp_change


range_maxgap_adjusted(open, close, length, pull_thresh) =>
    mg = highest(open, length) - lowest(close, length) / pull_thresh
    mg

range_height(close, length) =>
    h = close - lowest(close, length)
    h

safe_pump(open, close, length, oc_pct_change, thresh, pull_thresh) =>
    is_safe = ((oc_pct_change < thresh) or (range_maxgap_adjusted(open, close, length, pull_thresh) > (range_height(close, length))))
    is_safe

safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, thresh_0, thresh_2, thresh_12, thresh_144) =>
    is_safe_dip = ((tpct_change_0 < thresh_0) and (tpct_change_2 < thresh_2) and (tpct_change_12 < thresh_12) and (tpct_change_144 < thresh_144))
    is_safe_dip

// #############################################################
// Buy variables

buy_condition_1_enable = true, buy_1_btc_1h_not_downtrend = false, buy_01_protection__ema_fast = false, buy_01_protection__ema_fast_len = 26, buy_01_protection__ema_slow = true, buy_01_protection__ema_slow_len = 100, buy_01_protection__close_above_ema_fast  = false, buy_01_protection__close_above_ema_fast_len = 200, buy_01_protection__close_above_ema_slow = false, buy_01_protection__close_above_ema_slow_len = 200, buy_01_protection__sma200_rising = true, buy_01_protection__sma200_rising_val = 28, buy_01_protection__sma200_1h_rising = false, buy_01_protection__sma200_1h_rising_val = 50, buy_01_protection__safe_dips = true, buy_01_protection__safe_dips_type = 80, buy_01_protection__safe_pump = true, buy_01_protection__safe_pump_type = 70, buy_01_protection__safe_pump_period = 24
buy_condition_2_enable = true, buy_2_btc_1h_not_downtrend = false, buy_02_protection__ema_fast = false, buy_02_protection__ema_fast_len = 50, buy_02_protection__ema_slow = true, buy_02_protection__ema_slow_len = 20, buy_02_protection__close_above_ema_fast  = false, buy_02_protection__close_above_ema_fast_len = 200, buy_02_protection__close_above_ema_slow = false, buy_02_protection__close_above_ema_slow_len = 200, buy_02_protection__sma200_rising = false, buy_02_protection__sma200_rising_val = 50, buy_02_protection__sma200_1h_rising = false, buy_02_protection__sma200_1h_rising_val = 50, buy_02_protection__safe_dips = true, buy_02_protection__safe_dips_type = 50, buy_02_protection__safe_pump = true, buy_02_protection__safe_pump_type = 50, buy_02_protection__safe_pump_period = 24
buy_condition_3_enable = true, buy_3_btc_1h_not_downtrend = false, buy_03_protection__ema_fast = true, buy_03_protection__ema_fast_len = 100, buy_03_protection__ema_slow = true, buy_03_protection__ema_slow_len = 100, buy_03_protection__close_above_ema_fast  = false, buy_03_protection__close_above_ema_fast_len = 200, buy_03_protection__close_above_ema_slow = false, buy_03_protection__close_above_ema_slow_len = 200, buy_03_protection__sma200_rising = false, buy_03_protection__sma200_rising_val = 50, buy_03_protection__sma200_1h_rising = false, buy_03_protection__sma200_1h_rising_val = 50, buy_03_protection__safe_dips = false, buy_03_protection__safe_dips_type = 10, buy_03_protection__safe_pump = true, buy_03_protection__safe_pump_type = 100, buy_03_protection__safe_pump_period = 36
buy_condition_4_enable = true, buy_4_btc_1h_not_downtrend = false, buy_04_protection__ema_fast = false, buy_04_protection__ema_fast_len = 50, buy_04_protection__ema_slow = true, buy_04_protection__ema_slow_len = 50, buy_04_protection__close_above_ema_fast  = false, buy_04_protection__close_above_ema_fast_len = 200, buy_04_protection__close_above_ema_slow = false, buy_04_protection__close_above_ema_slow_len = 200, buy_04_protection__sma200_rising = true, buy_04_protection__sma200_rising_val = 50, buy_04_protection__sma200_1h_rising = false, buy_04_protection__sma200_1h_rising_val = 20, buy_04_protection__safe_dips = true, buy_04_protection__safe_dips_type = 10, buy_04_protection__safe_pump = true, buy_04_protection__safe_pump_type = 110, buy_04_protection__safe_pump_period = 48
buy_condition_5_enable = true, buy_5_btc_1h_not_downtrend = false, buy_05_protection__ema_fast = true, buy_05_protection__ema_fast_len = 100, buy_05_protection__ema_slow = false, buy_05_protection__ema_slow_len = 50, buy_05_protection__close_above_ema_fast  = false, buy_05_protection__close_above_ema_fast_len = 100, buy_05_protection__close_above_ema_slow = false, buy_05_protection__close_above_ema_slow_len = 36, buy_05_protection__sma200_rising = false, buy_05_protection__sma200_rising_val = 50, buy_05_protection__sma200_1h_rising = false, buy_05_protection__sma200_1h_rising_val = 50, buy_05_protection__safe_dips = true, buy_05_protection__safe_dips_type = 100, buy_05_protection__safe_pump = true, buy_05_protection__safe_pump_type = 20, buy_05_protection__safe_pump_period = 36
buy_condition_6_enable = true, buy_6_btc_1h_not_downtrend = false, buy_06_protection__ema_fast = false, buy_06_protection__ema_fast_len = 50, buy_06_protection__ema_slow = true, buy_06_protection__ema_slow_len = 100, buy_06_protection__close_above_ema_fast  = false, buy_06_protection__close_above_ema_fast_len = 200, buy_06_protection__close_above_ema_slow = false, buy_06_protection__close_above_ema_slow_len = 200, buy_06_protection__sma200_rising = false, buy_06_protection__sma200_rising_val = 50, buy_06_protection__sma200_1h_rising = false, buy_06_protection__sma200_1h_rising_val = 50, buy_06_protection__safe_dips = true, buy_06_protection__safe_dips_type = 50, buy_06_protection__safe_pump = true, buy_06_protection__safe_pump_type = 20, buy_06_protection__safe_pump_period = 36
buy_condition_7_enable = true, buy_7_btc_1h_not_downtrend = false, buy_07_protection__ema_fast = true, buy_07_protection__ema_fast_len = 100, buy_07_protection__ema_slow = true, buy_07_protection__ema_slow_len = 12, buy_07_protection__close_above_ema_fast  = false, buy_07_protection__close_above_ema_fast_len = 200, buy_07_protection__close_above_ema_slow = false, buy_07_protection__close_above_ema_slow_len = 200, buy_07_protection__sma200_rising = false, buy_07_protection__sma200_rising_val = 50, buy_07_protection__sma200_1h_rising = false, buy_07_protection__sma200_1h_rising_val = 50, buy_07_protection__safe_dips = false, buy_07_protection__safe_dips_type = 50, buy_07_protection__safe_pump = false, buy_07_protection__safe_pump_type = 50, buy_07_protection__safe_pump_period = 24
buy_condition_8_enable = true, buy_8_btc_1h_not_downtrend = false, buy_08_protection__ema_fast = false, buy_08_protection__ema_fast_len = 50, buy_08_protection__ema_slow = true, buy_08_protection__ema_slow_len = 12, buy_08_protection__close_above_ema_fast  = true, buy_08_protection__close_above_ema_fast_len = 200, buy_08_protection__close_above_ema_slow = false, buy_08_protection__close_above_ema_slow_len = 200, buy_08_protection__sma200_rising = false, buy_08_protection__sma200_rising_val = 50, buy_08_protection__sma200_1h_rising = false, buy_08_protection__sma200_1h_rising_val = 50, buy_08_protection__safe_dips = false, buy_08_protection__safe_dips_type = 100, buy_08_protection__safe_pump = true, buy_08_protection__safe_pump_type = 120, buy_08_protection__safe_pump_period = 24
buy_condition_9_enable = true, buy_9_btc_1h_not_downtrend = false, buy_09_protection__ema_fast = true, buy_09_protection__ema_fast_len = 100, buy_09_protection__ema_slow = false, buy_09_protection__ema_slow_len = 50, buy_09_protection__close_above_ema_fast  = false, buy_09_protection__close_above_ema_fast_len = 200, buy_09_protection__close_above_ema_slow = false, buy_09_protection__close_above_ema_slow_len = 200, buy_09_protection__sma200_rising = false, buy_09_protection__sma200_rising_val = 50, buy_09_protection__sma200_1h_rising = false, buy_09_protection__sma200_1h_rising_val = 50, buy_09_protection__safe_dips = false, buy_09_protection__safe_dips_type = 10, buy_09_protection__safe_pump = false, buy_09_protection__safe_pump_type = 50, buy_09_protection__safe_pump_period = 24
buy_condition_10_enable = true, buy_10_btc_1h_not_downtrend = false, buy_10_protection__ema_fast = false, buy_10_protection__ema_fast_len = 50, buy_10_protection__ema_slow = true, buy_10_protection__ema_slow_len = 50, buy_10_protection__close_above_ema_fast  = false, buy_10_protection__close_above_ema_fast_len = 200, buy_10_protection__close_above_ema_slow = false, buy_10_protection__close_above_ema_slow_len = 200, buy_10_protection__sma200_rising = false, buy_10_protection__sma200_rising_val = 50, buy_10_protection__sma200_1h_rising = false, buy_10_protection__sma200_1h_rising_val = 24, buy_10_protection__safe_dips = true, buy_10_protection__safe_dips_type = 100, buy_10_protection__safe_pump = false, buy_10_protection__safe_pump_type = 50, buy_10_protection__safe_pump_period = 24
buy_condition_11_enable = true, buy_11_btc_1h_not_downtrend = false, buy_11_protection__ema_fast = false, buy_11_protection__ema_fast_len = 50, buy_11_protection__ema_slow = false, buy_11_protection__ema_slow_len = 50, buy_11_protection__close_above_ema_fast  = false, buy_11_protection__close_above_ema_fast_len = 200, buy_11_protection__close_above_ema_slow = false, buy_11_protection__close_above_ema_slow_len = 200, buy_11_protection__sma200_rising = false, buy_11_protection__sma200_rising_val = 50, buy_11_protection__sma200_1h_rising = false, buy_11_protection__sma200_1h_rising_val = 50, buy_11_protection__safe_dips = false, buy_11_protection__safe_dips_type = 100, buy_11_protection__safe_pump = true, buy_11_protection__safe_pump_type = 50, buy_11_protection__safe_pump_period = 24
buy_condition_12_enable = true, buy_12_btc_1h_not_downtrend = false, buy_12_protection__ema_fast = false, buy_12_protection__ema_fast_len = 50, buy_12_protection__ema_slow = false, buy_12_protection__ema_slow_len = 50, buy_12_protection__close_above_ema_fast  = false, buy_12_protection__close_above_ema_fast_len = 200, buy_12_protection__close_above_ema_slow = false, buy_12_protection__close_above_ema_slow_len = 200, buy_12_protection__sma200_rising = false, buy_12_protection__sma200_rising_val = 50, buy_12_protection__sma200_1h_rising = true, buy_12_protection__sma200_1h_rising_val = 24, buy_12_protection__safe_dips = false, buy_12_protection__safe_dips_type = 100, buy_12_protection__safe_pump = false, buy_12_protection__safe_pump_type = 50, buy_12_protection__safe_pump_period = 24
buy_condition_13_enable = true, buy_13_btc_1h_not_downtrend = false, buy_13_protection__ema_fast = false, buy_13_protection__ema_fast_len = 50, buy_13_protection__ema_slow = false, buy_13_protection__ema_slow_len = 50, buy_13_protection__close_above_ema_fast  = false, buy_13_protection__close_above_ema_fast_len = 200, buy_13_protection__close_above_ema_slow = false, buy_13_protection__close_above_ema_slow_len = 200, buy_13_protection__sma200_rising = false, buy_13_protection__sma200_rising_val = 50, buy_13_protection__sma200_1h_rising = true, buy_13_protection__sma200_1h_rising_val = 24, buy_13_protection__safe_dips = true, buy_13_protection__safe_dips_type = 10, buy_13_protection__safe_pump = false, buy_13_protection__safe_pump_type = 50, buy_13_protection__safe_pump_period = 24
buy_condition_14_enable = true, buy_14_btc_1h_not_downtrend = false, buy_14_protection__ema_fast = false, buy_14_protection__ema_fast_len = 50, buy_14_protection__ema_slow = false, buy_14_protection__ema_slow_len = 50, buy_14_protection__close_above_ema_fast  = false, buy_14_protection__close_above_ema_fast_len = 200, buy_14_protection__close_above_ema_slow = false, buy_14_protection__close_above_ema_slow_len = 200, buy_14_protection__sma200_rising = true, buy_14_protection__sma200_rising_val = 30, buy_14_protection__sma200_1h_rising = true, buy_14_protection__sma200_1h_rising_val = 50, buy_14_protection__safe_dips = true, buy_14_protection__safe_dips_type = 10, buy_14_protection__safe_pump = true, buy_14_protection__safe_pump_type = 70, buy_14_protection__safe_pump_period = 24
buy_condition_15_enable = true, buy_15_btc_1h_not_downtrend = false, buy_15_protection__ema_fast = false, buy_15_protection__ema_fast_len = 50, buy_15_protection__ema_slow = true, buy_15_protection__ema_slow_len = 50, buy_15_protection__close_above_ema_fast  = false, buy_15_protection__close_above_ema_fast_len = 200, buy_15_protection__close_above_ema_slow = false, buy_15_protection__close_above_ema_slow_len = 200, buy_15_protection__sma200_rising = false, buy_15_protection__sma200_rising_val = 50, buy_15_protection__sma200_1h_rising = false, buy_15_protection__sma200_1h_rising_val = 50, buy_15_protection__safe_dips = true, buy_15_protection__safe_dips_type = 50, buy_15_protection__safe_pump = true, buy_15_protection__safe_pump_type = 10, buy_15_protection__safe_pump_period = 36
buy_condition_16_enable = true, buy_16_btc_1h_not_downtrend = false, buy_16_protection__ema_fast = false, buy_16_protection__ema_fast_len = 50, buy_16_protection__ema_slow = true, buy_16_protection__ema_slow_len = 50, buy_16_protection__close_above_ema_fast  = false, buy_16_protection__close_above_ema_fast_len = 200, buy_16_protection__close_above_ema_slow = false, buy_16_protection__close_above_ema_slow_len = 50, buy_16_protection__sma200_rising = false, buy_16_protection__sma200_rising_val = 50, buy_16_protection__sma200_1h_rising = false, buy_16_protection__sma200_1h_rising_val = 50, buy_16_protection__safe_dips = true, buy_16_protection__safe_dips_type = 10, buy_16_protection__safe_pump = true, buy_16_protection__safe_pump_type = 10, buy_16_protection__safe_pump_period = 24
buy_condition_17_enable = true, buy_17_btc_1h_not_downtrend = false, buy_17_protection__ema_fast = false, buy_17_protection__ema_fast_len = 50, buy_17_protection__ema_slow = false, buy_17_protection__ema_slow_len = 50, buy_17_protection__close_above_ema_fast  = false, buy_17_protection__close_above_ema_fast_len = 200, buy_17_protection__close_above_ema_slow = false, buy_17_protection__close_above_ema_slow_len = 200, buy_17_protection__sma200_rising = false, buy_17_protection__sma200_rising_val = 50, buy_17_protection__sma200_1h_rising = false, buy_17_protection__sma200_1h_rising_val = 50, buy_17_protection__safe_dips = true, buy_17_protection__safe_dips_type = 10, buy_17_protection__safe_pump = true, buy_17_protection__safe_pump_type = 120, buy_17_protection__safe_pump_period = 24
buy_condition_18_enable = true, buy_18_btc_1h_not_downtrend = false, buy_18_protection__ema_fast = true, buy_18_protection__ema_fast_len = 100, buy_18_protection__ema_slow = true, buy_18_protection__ema_slow_len = 50, buy_18_protection__close_above_ema_fast  = false, buy_18_protection__close_above_ema_fast_len = 200, buy_18_protection__close_above_ema_slow = true, buy_18_protection__close_above_ema_slow_len = 200, buy_18_protection__sma200_rising = true, buy_18_protection__sma200_rising_val = 44, buy_18_protection__sma200_1h_rising = true, buy_18_protection__sma200_1h_rising_val = 72, buy_18_protection__safe_dips = true, buy_18_protection__safe_dips_type = 50, buy_18_protection__safe_pump = true, buy_18_protection__safe_pump_type = 60, buy_18_protection__safe_pump_period = 24
buy_condition_19_enable = true, buy_19_btc_1h_not_downtrend = false, buy_19_protection__ema_fast = false, buy_19_protection__ema_fast_len = 50, buy_19_protection__ema_slow = true, buy_19_protection__ema_slow_len = 100, buy_19_protection__close_above_ema_fast  = false, buy_19_protection__close_above_ema_fast_len = 200, buy_19_protection__close_above_ema_slow = false, buy_19_protection__close_above_ema_slow_len = 200, buy_19_protection__sma200_rising = true, buy_19_protection__sma200_rising_val = 36, buy_19_protection__sma200_1h_rising = false, buy_19_protection__sma200_1h_rising_val = 50, buy_19_protection__safe_dips = true, buy_19_protection__safe_dips_type = 50, buy_19_protection__safe_pump = true, buy_19_protection__safe_pump_type = 50, buy_19_protection__safe_pump_period = 24
buy_condition_20_enable = true, buy_20_btc_1h_not_downtrend = false, buy_20_protection__ema_fast = false, buy_20_protection__ema_fast_len = 50, buy_20_protection__ema_slow = true, buy_20_protection__ema_slow_len = 50, buy_20_protection__close_above_ema_fast  = false, buy_20_protection__close_above_ema_fast_len = 200, buy_20_protection__close_above_ema_slow = false, buy_20_protection__close_above_ema_slow_len = 200, buy_20_protection__sma200_rising = false, buy_20_protection__sma200_rising_val = 50, buy_20_protection__sma200_1h_rising = false, buy_20_protection__sma200_1h_rising_val = 50, buy_20_protection__safe_dips = false, buy_20_protection__safe_dips_type = 10, buy_20_protection__safe_pump = false, buy_20_protection__safe_pump_type = 50, buy_20_protection__safe_pump_period = 24
buy_condition_21_enable = true, buy_21_btc_1h_not_downtrend = false, buy_21_protection__ema_fast = false, buy_21_protection__ema_fast_len = 50, buy_21_protection__ema_slow = true, buy_21_protection__ema_slow_len = 50, buy_21_protection__close_above_ema_fast  = false, buy_21_protection__close_above_ema_fast_len = 200, buy_21_protection__close_above_ema_slow = false, buy_21_protection__close_above_ema_slow_len = 200, buy_21_protection__sma200_rising = false, buy_21_protection__sma200_rising_val = 50, buy_21_protection__sma200_1h_rising = false, buy_21_protection__sma200_1h_rising_val = 50, buy_21_protection__safe_dips = true, buy_21_protection__safe_dips_type = 90, buy_21_protection__safe_pump = false, buy_21_protection__safe_pump_type = 50, buy_21_protection__safe_pump_period = 24
buy_condition_22_enable = true, buy_22_btc_1h_not_downtrend = false, buy_22_protection__ema_fast = false, buy_22_protection__ema_fast_len = 50, buy_22_protection__ema_slow = false, buy_22_protection__ema_slow_len = 50, buy_22_protection__close_above_ema_fast  = false, buy_22_protection__close_above_ema_fast_len = 200, buy_22_protection__close_above_ema_slow = false, buy_22_protection__close_above_ema_slow_len = 200, buy_22_protection__sma200_rising = false, buy_22_protection__sma200_rising_val = 50, buy_22_protection__sma200_1h_rising = false, buy_22_protection__sma200_1h_rising_val = 50, buy_22_protection__safe_dips = true, buy_22_protection__safe_dips_type = 110, buy_22_protection__safe_pump = false, buy_22_protection__safe_pump_type = 50, buy_22_protection__safe_pump_period = 24
buy_condition_23_enable = true, buy_23_btc_1h_not_downtrend = false, buy_23_protection__ema_fast = false, buy_23_protection__ema_fast_len = 50, buy_23_protection__ema_slow = false, buy_23_protection__ema_slow_len = 50, buy_23_protection__close_above_ema_fast  = true, buy_23_protection__close_above_ema_fast_len = 200, buy_23_protection__close_above_ema_slow = true, buy_23_protection__close_above_ema_slow_len = 200, buy_23_protection__sma200_rising = false, buy_23_protection__sma200_rising_val = 50, buy_23_protection__sma200_1h_rising = false, buy_23_protection__sma200_1h_rising_val = 50, buy_23_protection__safe_dips = true, buy_23_protection__safe_dips_type = 100, buy_23_protection__safe_pump = false, buy_23_protection__safe_pump_type = 50, buy_23_protection__safe_pump_period = 24
buy_condition_24_enable = true, buy_24_btc_1h_not_downtrend = false, buy_24_protection__ema_fast = false, buy_24_protection__ema_fast_len = 50, buy_24_protection__ema_slow = false, buy_24_protection__ema_slow_len = 50, buy_24_protection__close_above_ema_fast  = false, buy_24_protection__close_above_ema_fast_len = 200, buy_24_protection__close_above_ema_slow = false, buy_24_protection__close_above_ema_slow_len = 200, buy_24_protection__sma200_rising = false, buy_24_protection__sma200_rising_val = 30, buy_24_protection__sma200_1h_rising = true, buy_24_protection__sma200_1h_rising_val = 36, buy_24_protection__safe_dips = true, buy_24_protection__safe_dips_type = 20, buy_24_protection__safe_pump = false, buy_24_protection__safe_pump_type = 50, buy_24_protection__safe_pump_period = 24
buy_condition_25_enable = true, buy_25_btc_1h_not_downtrend = false, buy_25_protection__ema_fast = false, buy_25_protection__ema_fast_len = 50, buy_25_protection__ema_slow = false, buy_25_protection__ema_slow_len = 100, buy_25_protection__close_above_ema_fast  = false, buy_25_protection__close_above_ema_fast_len = 50, buy_25_protection__close_above_ema_slow = false, buy_25_protection__close_above_ema_slow_len = 200, buy_25_protection__sma200_rising = true, buy_25_protection__sma200_rising_val = 20, buy_25_protection__sma200_1h_rising = false, buy_25_protection__sma200_1h_rising_val = 50, buy_25_protection__safe_dips = false, buy_25_protection__safe_dips_type = 10, buy_25_protection__safe_pump = true, buy_25_protection__safe_pump_type = 20, buy_25_protection__safe_pump_period = 24
buy_condition_26_enable = true, buy_26_btc_1h_not_downtrend = false, buy_26_protection__ema_fast = false, buy_26_protection__ema_fast_len = 50, buy_26_protection__ema_slow = true, buy_26_protection__ema_slow_len = 100, buy_26_protection__close_above_ema_fast  = true, buy_26_protection__close_above_ema_fast_len = 50, buy_26_protection__close_above_ema_slow = false, buy_26_protection__close_above_ema_slow_len = 200, buy_26_protection__sma200_rising = false, buy_26_protection__sma200_rising_val = 30, buy_26_protection__sma200_1h_rising = false, buy_26_protection__sma200_1h_rising_val = 50, buy_26_protection__safe_dips = true, buy_26_protection__safe_dips_type = 10, buy_26_protection__safe_pump = true, buy_26_protection__safe_pump_type = 100, buy_26_protection__safe_pump_period = 48
buy_condition_27_enable = true, buy_27_btc_1h_not_downtrend = true, buy_27_protection__ema_fast = false, buy_27_protection__ema_fast_len = 50, buy_27_protection__ema_slow = false, buy_27_protection__ema_slow_len = 100, buy_27_protection__close_above_ema_fast  = false, buy_27_protection__close_above_ema_fast_len = 50, buy_27_protection__close_above_ema_slow = false, buy_27_protection__close_above_ema_slow_len = 200, buy_27_protection__sma200_rising = false, buy_27_protection__sma200_rising_val = 30, buy_27_protection__sma200_1h_rising = false, buy_27_protection__sma200_1h_rising_val = 50, buy_27_protection__safe_dips = false, buy_27_protection__safe_dips_type = 10, buy_27_protection__safe_pump = true, buy_27_protection__safe_pump_type = 50, buy_27_protection__safe_pump_period = 36
buy_condition_28_enable = true, buy_28_btc_1h_not_downtrend = true, buy_28_protection__ema_fast = false, buy_28_protection__ema_fast_len = 50, buy_28_protection__ema_slow = false, buy_28_protection__ema_slow_len = 100, buy_28_protection__close_above_ema_fast  = false, buy_28_protection__close_above_ema_fast_len = 50, buy_28_protection__close_above_ema_slow = false, buy_28_protection__close_above_ema_slow_len = 200, buy_28_protection__sma200_rising = false, buy_28_protection__sma200_rising_val = 30, buy_28_protection__sma200_1h_rising = false, buy_28_protection__sma200_1h_rising_val = 50, buy_28_protection__safe_dips = false, buy_28_protection__safe_dips_type = 10, buy_28_protection__safe_pump = true, buy_28_protection__safe_pump_type = 110, buy_28_protection__safe_pump_period = 36


//# Strict dips - level 10
buy_dip_threshold_10_1 = 0.015, buy_dip_threshold_10_2 = 0.1, buy_dip_threshold_10_3 = 0.24, buy_dip_threshold_10_4 = 0.42
//# Strict dips - level 20
buy_dip_threshold_20_1 = 0.016, buy_dip_threshold_20_2 = 0.11, buy_dip_threshold_20_3 = 0.26, buy_dip_threshold_20_4 = 0.44
//# Strict dips - level 30
buy_dip_threshold_30_1 = 0.018, buy_dip_threshold_30_2 = 0.12, buy_dip_threshold_30_3 = 0.28, buy_dip_threshold_30_4 = 0.46
//# Strict dips - level 40
buy_dip_threshold_40_1 = 0.019, buy_dip_threshold_40_2 = 0.13, buy_dip_threshold_40_3 = 0.3, buy_dip_threshold_40_4 = 0.48
//# Normal dips - level 50
buy_dip_threshold_50_1 = 0.02, buy_dip_threshold_50_2 = 0.14, buy_dip_threshold_50_3 = 0.32, buy_dip_threshold_50_4 = 0.5
//# Normal dips - level 60
buy_dip_threshold_60_1 = 0.022, buy_dip_threshold_60_2 = 0.18, buy_dip_threshold_60_3 = 0.34, buy_dip_threshold_60_4 = 0.56
//# Normal dips - level 70
buy_dip_threshold_70_1 = 0.023, buy_dip_threshold_70_2 = 0.2, buy_dip_threshold_70_3 = 0.36, buy_dip_threshold_70_4 = 0.6
//# Normal dips - level 80
buy_dip_threshold_80_1 = 0.024, buy_dip_threshold_80_2 = 0.22, buy_dip_threshold_80_3 = 0.38, buy_dip_threshold_80_4 = 0.66
//# Normal dips - level 70
buy_dip_threshold_90_1 = 0.025, buy_dip_threshold_90_2 = 0.23, buy_dip_threshold_90_3 = 0.4, buy_dip_threshold_90_4 = 0.7
//# Loose dips - level 100
buy_dip_threshold_100_1 = 0.026, buy_dip_threshold_100_2 = 0.24, buy_dip_threshold_100_3 = 0.42, buy_dip_threshold_100_4 = 0.8
//# Loose dips - level 110
buy_dip_threshold_110_1 = 0.027, buy_dip_threshold_110_2 = 0.26, buy_dip_threshold_110_3 = 0.44, buy_dip_threshold_110_4 = 0.84

//# 24 hours - level 10
buy_pump_pull_threshold_10_24 = 2.2, buy_pump_threshold_10_24 = 0.42
//# 36 hours - level 10
buy_pump_pull_threshold_10_36 = 2.0, buy_pump_threshold_10_36 = 0.58
//# 48 hours - level 10
buy_pump_pull_threshold_10_48 = 2.0, buy_pump_threshold_10_48 = 0.8

//# 24 hours - level 20
buy_pump_pull_threshold_20_24 = 2.2, buy_pump_threshold_20_24 = 0.46
//# 36 hours - level 20
buy_pump_pull_threshold_20_36 = 2.0, buy_pump_threshold_20_36 = 0.6
//# 48 hours - level 20
buy_pump_pull_threshold_20_48 = 2.0, buy_pump_threshold_20_48 = 0.81

//# 24 hours - level 30
buy_pump_pull_threshold_30_24 = 2.2, buy_pump_threshold_30_24 = 0.5
//# 36 hours - level 30
buy_pump_pull_threshold_30_36 = 2.0, buy_pump_threshold_30_36 = 0.62
//# 48 hours - level 30
buy_pump_pull_threshold_30_48 = 2.0, buy_pump_threshold_30_48 = 0.82

//# 24 hours - level 40
buy_pump_pull_threshold_40_24 = 2.2, buy_pump_threshold_40_24 = 0.54
//# 36 hours - level 40
buy_pump_pull_threshold_40_36 = 2.0, buy_pump_threshold_40_36 = 0.63
//# 48 hours - level 40
buy_pump_pull_threshold_40_48 = 2.0, buy_pump_threshold_40_48 = 0.84

//# 24 hours - level 50
buy_pump_pull_threshold_50_24 = 1.75, buy_pump_threshold_50_24 = 0.6
//# 36 hours - level 50
buy_pump_pull_threshold_50_36 = 1.75, buy_pump_threshold_50_36 = 0.64
//# 48 hours - level 50
buy_pump_pull_threshold_50_48 = 1.75, buy_pump_threshold_50_48 = 0.85

//# 24 hours - level 60
buy_pump_pull_threshold_60_24 = 1.75, buy_pump_threshold_60_24 = 0.62
//# 36 hours - level 60
buy_pump_pull_threshold_60_36 = 1.75, buy_pump_threshold_60_36 = 0.66
//# 48 hours - level 60
buy_pump_pull_threshold_60_48 = 1.75, buy_pump_threshold_60_48 = 0.9

//# 24 hours - level 70
buy_pump_pull_threshold_70_24 = 1.75, buy_pump_threshold_70_24 = 0.63
//# 36 hours - level 70
buy_pump_pull_threshold_70_36 = 1.75, buy_pump_threshold_70_36 = 0.67
//# 48 hours - level 70
buy_pump_pull_threshold_70_48 = 1.75, buy_pump_threshold_70_48 = 0.95

//# 24 hours - level 80
buy_pump_pull_threshold_80_24 = 1.75, buy_pump_threshold_80_24 = 0.64
//# 36 hours - level 80
buy_pump_pull_threshold_80_36 = 1.75, buy_pump_threshold_80_36 = 0.68
//# 48 hours - level 80
buy_pump_pull_threshold_80_48 = 1.75, buy_pump_threshold_80_48 = 1.0

//# 24 hours - level 90
buy_pump_pull_threshold_90_24 = 1.75, buy_pump_threshold_90_24 = 0.65
//# 36 hours - level 90
buy_pump_pull_threshold_90_36 = 1.75, buy_pump_threshold_90_36 = 0.69
//# 48 hours - level 90
buy_pump_pull_threshold_90_48 = 1.75, buy_pump_threshold_90_48 = 1.1

//# 24 hours - level 100
buy_pump_pull_threshold_100_24 = 1.7, buy_pump_threshold_100_24 = 0.66
//# 36 hours - level 100
buy_pump_pull_threshold_100_36 = 1.7, buy_pump_threshold_100_36 = 0.7
//# 48 hours - level 100
buy_pump_pull_threshold_100_48 = 1.4, buy_pump_threshold_100_48 = 1.6

//# 24 hours - level 110
buy_pump_pull_threshold_110_24 = 1.7, buy_pump_threshold_110_24 = 0.7
//# 36 hours - level 110
buy_pump_pull_threshold_110_36 = 1.7, buy_pump_threshold_110_36 = 0.74
//# 48 hours - level 110
buy_pump_pull_threshold_110_48 = 1.4, buy_pump_threshold_110_48 = 1.8

//# 24 hours - level 120
buy_pump_pull_threshold_120_24 = 1.7, buy_pump_threshold_120_24 = 0.78
//# 36 hours - level 120
buy_pump_pull_threshold_120_36 = 1.7, buy_pump_threshold_120_36 = 0.78
//# 48 hours - level 120
buy_pump_pull_threshold_120_48 = 1.4, buy_pump_threshold_120_48 = 2.0

buy_dump_protection_10_5 = 0.4, buy_dump_protection_20_5 = 0.44, buy_dump_protection_30_5 = 0.5, buy_dump_protection_40_5 = 0.58, buy_dump_protection_50_5 = 0.66, buy_dump_protection_60_5 = 0.74

buy_min_inc_1 = 0.022, buy_rsi_1h_min_1 = 30.0, buy_rsi_1h_max_1 = 84.0, buy_rsi_1 = 36.0, buy_mfi_1 = 44.0
buy_rsi_1h_min_2 = 32.0, buy_rsi_1h_max_2 = 84.0, buy_rsi_1h_diff_2 = 39.0, buy_mfi_2 = 49.0, buy_bb_offset_2 = 0.983
buy_bb40_bbdelta_close_3 = 0.059, buy_bb40_closedelta_close_3 = 0.023, buy_bb40_tail_bbdelta_3 = 0.418, buy_ema_rel_3 = 0.986
buy_bb20_close_bblowerband_4 = 0.98, buy_bb20_volume_4 = 10.0
buy_ema_open_mult_5 = 0.018, buy_bb_offset_5 = 0.996, buy_ema_rel_5 = 0.944
buy_ema_open_mult_6 = 0.021, buy_bb_offset_6 = 0.984
buy_ema_open_mult_7 = 0.03, buy_rsi_7 = 37.0
buy_volume_8 = 2.0, buy_rsi_8 = 29.0, buy_tail_diff_8 = 2.5
buy_ma_offset_9 = 0.922, buy_bb_offset_9 = 0.942, buy_rsi_1h_min_9 = 20.0, buy_rsi_1h_max_9 = 88.0, buy_mfi_9 = 50.0
buy_ma_offset_10 = 0.948, buy_bb_offset_10 = 0.985, buy_rsi_1h_10 = 37.0
buy_ma_offset_11 = 0.934, buy_min_inc_11 = 0.01, buy_rsi_1h_min_11 = 55.0, buy_rsi_1h_max_11 = 84.0, buy_rsi_11 = 48.0, buy_mfi_11 = 36.0
buy_ma_offset_12 = 0.922, buy_rsi_12 = 30.0, buy_ewo_12 = 1.8
buy_ma_offset_13 = 0.99, buy_ewo_13 = -11.4
buy_ema_open_mult_14 = 0.014, buy_bb_offset_14 = 0.988, buy_ma_offset_14 = 0.98
buy_ema_open_mult_15 = 0.018, buy_ma_offset_15 = 0.954, buy_rsi_15 = 28.0, buy_ema_rel_15 = 0.988
buy_ma_offset_16 = 0.952, buy_rsi_16 = 31.0, buy_ewo_16 = 2.8
buy_ma_offset_17 = 0.952, buy_ewo_17 = -12.8
buy_rsi_18 = 26.0, buy_bb_offset_18 = 0.982
buy_rsi_1h_min_19 = 50.0, buy_chop_min_19 = 26.1
buy_rsi_20 = 27.0, buy_rsi_1h_20 = 20.0
buy_rsi_21 = 23.0, buy_rsi_1h_21 = 24.0
buy_volume_22 = 3.0, buy_bb_offset_22 = 0.98, buy_ma_offset_22 = 0.941, buy_ewo_22 = 4.2, buy_rsi_22 = 37.0
buy_bb_offset_23 = 0.983, buy_ewo_23 = 7.0, buy_rsi_23 = 30.0, buy_rsi_1h_23 = 70.0
buy_24_rsi_max = 60.0, buy_24_rsi_1h_min = 66.9
buy_25_ma_offset = 0.922, buy_25_rsi_14 = 38.0
buy_26_zema_low_offset = 0.93
buy_27_wr_max = 95.4, buy_27_wr_1h_max = 97.6, buy_27_rsi_max = 50

// Sell Variables

sell_condition_1_enable = true
sell_condition_2_enable = true
sell_condition_3_enable = true
sell_condition_4_enable = true
sell_condition_5_enable = true
sell_condition_6_enable = true
sell_condition_7_enable = true
sell_condition_8_enable = true

// # 48h for pump sell checks
sell_pump_threshold_48_1 = 0.9, sell_pump_threshold_48_2 = 0.7, sell_pump_threshold_48_3 = 0.5
// # 36h for pump sell checks
sell_pump_threshold_36_1 = 0.7, sell_pump_threshold_36_2 = 4.0, sell_pump_threshold_36_3 = 1.0
// # 24h for pump sell checks
sell_pump_threshold_24_1 = 0.6, sell_pump_threshold_24_2 = 0.6, sell_pump_threshold_24_3 = 0.8

sell_rsi_bb_1 = 79.5
sell_rsi_bb_2 = 81
sell_rsi_main_3 = 82
sell_dual_rsi_rsi_4 = 73.4, sell_dual_rsi_rsi_1h_4 = 79.6
sell_ema_relative_5 = 0.024, sell_rsi_diff_5 = 4.4
sell_rsi_under_6 = 79.0
sell_rsi_1h_7 = 81.7
sell_bb_relative_8 = 1.1


// indicators

[bb40_2_mid, bb40_2_upper, bb40_2_low] = bb(close, 40, 2)
bb40_2_delta = abs(bb40_2_mid - bb40_2_low)
closedelta = abs(close - close[1])
tail = abs(close - bb40_2_low)

[bb20_2_mid, bb20_2_upp, bb20_2_low] = bb(hlc3, 20, 2)

ema_12  = ema(close, 12)
ema_15  = ema(close, 15)
ema_20  = ema(close, 20)
ema_25  = ema(close, 25)
ema_26  = ema(close, 26)
ema_35  = ema(close, 35)
ema_50  = ema(close, 50)
ema_100 = ema(close, 100)
ema_200 = ema(close, 200)

sma_5   = sma(close, 5)
sma_20  = sma(close, 20)
sma_30  = sma(close, 30)
sma_200 = sma(close, 200)
sma_200_dec_20 = (sma_200 - sma_200[20])
sma_200_dec_24 = (sma_200 - sma_200[24])

mfi_5m = mfi(close, 5)
cmf_5m = chaikin_money_flow(open, high, low, close, volume, 20)
rsi_5m = rsi(close,14)
rsi_5m_4 = rsi(close, 4)
rsi_5m_20 = rsi(close, 20)

ewo_5m = ema_difference(50, 200)
chop_5m = chopiness(14)
zema_61 = zema(close, 61)

r_480_5m = wiliyam_r(high, low, close, 480)
[stochrsi_fastk_96, stochrsi_fastd_96] = stoch_rsi(close, 96, 3, 3)

moderi_64 = moderi(close, volume, 64)
// tsi_slow = f_tsi(close, window_slow=20, window_fast=5)
// tsi_ema_slow = ema(tsi_slow, 5)

// tsi_fast = f_tsi(close, window_slow=4, window_fast=2)
// tsi_ema_fast = ema(tsi_fast, 2)

hull_75 = hull(close, 75)

crossed_below_ema_12_26 = crossunder(ema_12, ema_26)

tpct_change_0 = top_percent_change(open, close, 0)
tpct_change_2 = top_percent_change(open, close, 2)
tpct_change_12 = top_percent_change(open, close, 12)
tpct_change_144 = top_percent_change(open, close, 144)

safe_dips_10 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_10_1, buy_dip_threshold_10_2, buy_dip_threshold_10_3, buy_dip_threshold_10_4)
safe_dips_20 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_20_1, buy_dip_threshold_20_2, buy_dip_threshold_20_3, buy_dip_threshold_20_4)
safe_dips_30 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_30_1, buy_dip_threshold_30_2, buy_dip_threshold_30_3, buy_dip_threshold_30_4)
safe_dips_40 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_40_1, buy_dip_threshold_40_2, buy_dip_threshold_40_3, buy_dip_threshold_40_4)
safe_dips_50 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_50_1, buy_dip_threshold_50_2, buy_dip_threshold_50_3, buy_dip_threshold_50_4)
safe_dips_60 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_60_1, buy_dip_threshold_60_2, buy_dip_threshold_60_3, buy_dip_threshold_60_4)
safe_dips_70 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_70_1, buy_dip_threshold_70_2, buy_dip_threshold_70_3, buy_dip_threshold_70_4)
safe_dips_80 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_80_1, buy_dip_threshold_80_2, buy_dip_threshold_80_3, buy_dip_threshold_80_4)
safe_dips_90 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_90_1, buy_dip_threshold_90_2, buy_dip_threshold_90_3, buy_dip_threshold_90_4)
safe_dips_100 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_100_1, buy_dip_threshold_100_2, buy_dip_threshold_100_3, buy_dip_threshold_100_4)
safe_dips_110 = safe_dips(tpct_change_0, tpct_change_2, tpct_change_12, tpct_change_144, buy_dip_threshold_110_1, buy_dip_threshold_110_2, buy_dip_threshold_110_3, buy_dip_threshold_110_4)

volume_mean_4  = median(volume, 4)[1]
volume_mean_30 = median(volume, 30)

// Base/informative BTC indicators

btc_rsi_5m = security(_master_pair, "", rsi(close,14))

btc_rsi_1h = security(_master_pair, "60", rsi(close,14))
btc_not_downtrend_1h = security(_master_pair, "60", ((close > close[2]) or (btc_rsi_1h > 50)))
// Informative indicators

[ema_12_1h, ema_15_1h, ema_20_1h, ema_26_1h, ema_35_1h, ema_50_1h, ema_100_1h, ema_200_1h] = security(syminfo.tickerid, informative_tf, [ema(close, 12), ema(close, 15), ema(close, 20), ema(close, 26), ema(close, 35), ema(close, 50), ema(close, 100), ema(close, 200)])

[sma_200_1h , sma_200_dec_20_1h] = security(syminfo.tickerid, informative_tf, [sma(close, 200), sma_dec_1h(close, 200)])

[rsi_1h, cmf_1h, r_480_1h] = security(syminfo.tickerid, informative_tf, [rsi(close, 14), chaikin_money_flow(open, high, low, close, volume, 20), wiliyam_r(high, low, close, 480)])

[bb20_2_mid_1h, bb20_2_upp_1h, bb20_2_low_1h] = security(syminfo.tickerid, informative_tf, bb(hlc3, 20, 2))

[hl_pct_change_48, hl_pct_change_36, hl_pct_change_24, oc_pct_change_48, oc_pct_change_36, oc_pct_change_24, hl_pct_change_5, low_5] = security(syminfo.tickerid, informative_tf, [range_percent_change(open, high, low, close, 'HL', 48), range_percent_change(open, high, low, close, 'HL', 36), range_percent_change(open, high, low, close, 'HL', 24), range_percent_change(open, high, low, close, 'OC', 48), range_percent_change(open, high, low, close, 'OC', 36), range_percent_change(open, high, low, close, 'OC', 24), range_percent_change(open, high, low, close, 'HL', 5), lowest(low, 5) ] )

[safe_pump_24_10, safe_pump_36_10, safe_pump_48_10] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_10_24, buy_pump_pull_threshold_10_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_10_36, buy_pump_pull_threshold_10_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_10_48, buy_pump_pull_threshold_10_48)] )

[safe_pump_24_20, safe_pump_36_20, safe_pump_48_20] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_20_24, buy_pump_pull_threshold_20_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_20_36, buy_pump_pull_threshold_20_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_20_48, buy_pump_pull_threshold_20_48)] )

[safe_pump_24_30, safe_pump_36_30, safe_pump_48_30] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_30_24, buy_pump_pull_threshold_30_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_30_36, buy_pump_pull_threshold_30_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_30_48, buy_pump_pull_threshold_30_48)] )

[safe_pump_24_40, safe_pump_36_40, safe_pump_48_40] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_40_24, buy_pump_pull_threshold_40_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_40_36, buy_pump_pull_threshold_40_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_40_48, buy_pump_pull_threshold_40_48)] )

[safe_pump_24_50, safe_pump_36_50, safe_pump_48_50] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_50_24, buy_pump_pull_threshold_50_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_50_36, buy_pump_pull_threshold_50_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_50_48, buy_pump_pull_threshold_50_48)] )

[safe_pump_24_60, safe_pump_36_60, safe_pump_48_60] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_60_24, buy_pump_pull_threshold_60_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_60_36, buy_pump_pull_threshold_60_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_60_48, buy_pump_pull_threshold_60_48)] )

[safe_pump_24_70, safe_pump_36_70, safe_pump_48_70] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_70_24, buy_pump_pull_threshold_70_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_70_36, buy_pump_pull_threshold_70_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_70_48, buy_pump_pull_threshold_70_48)] )

[safe_pump_24_80, safe_pump_36_80, safe_pump_48_80] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_80_24, buy_pump_pull_threshold_80_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_80_36, buy_pump_pull_threshold_80_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_80_48, buy_pump_pull_threshold_80_48)] )

[safe_pump_24_90, safe_pump_36_90, safe_pump_48_90] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_90_24, buy_pump_pull_threshold_90_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_90_36, buy_pump_pull_threshold_90_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_90_48, buy_pump_pull_threshold_90_48)] )

[safe_pump_24_100, safe_pump_36_100, safe_pump_48_100] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_100_24, buy_pump_pull_threshold_100_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_100_36, buy_pump_pull_threshold_100_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_100_48, buy_pump_pull_threshold_100_48)] )

[safe_pump_24_110, safe_pump_36_110, safe_pump_48_110] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_110_24, buy_pump_pull_threshold_110_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_110_36, buy_pump_pull_threshold_110_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_110_48, buy_pump_pull_threshold_110_48)] )

[safe_pump_24_120, safe_pump_36_120, safe_pump_48_120] = security(syminfo.tickerid, informative_tf, [safe_pump(open, close, 24, oc_pct_change_24, buy_pump_threshold_120_24, buy_pump_pull_threshold_120_24), safe_pump(open, close, 36, oc_pct_change_36, buy_pump_threshold_120_36, buy_pump_pull_threshold_120_36), safe_pump(open, close, 48, oc_pct_change_48, buy_pump_threshold_120_48, buy_pump_pull_threshold_120_48)] )

// [safe_dump_10, safe_dump_20, safe_dump_30, safe_dump_40, safe_dump_50] = security(syminfo.tickerid, informative_tf, [((hl_pct_change_5 < buy_dump_protection_10_5) or (close < low_5) or (close > open)), ((hl_pct_change_5 < buy_dump_protection_20_5) or (close < low_5) or (close > open)), ((hl_pct_change_5 < buy_dump_protection_30_5) or (close < low_5) or (close > open)), ((hl_pct_change_5 < buy_dump_protection_40_5) or (close < low_5) or (close > open)), ((hl_pct_change_5 < buy_dump_protection_50_5) or (close < low_5) or (close > open))] )

[sell_pump_48_1, sell_pump_48_2, sell_pump_48_3] = security(syminfo.tickerid, informative_tf, [(hl_pct_change_48 > sell_pump_threshold_48_1), (hl_pct_change_48 > sell_pump_threshold_48_2), (hl_pct_change_48 > sell_pump_threshold_48_3)])
[sell_pump_36_1, sell_pump_36_2, sell_pump_36_3] = security(syminfo.tickerid, informative_tf, [(hl_pct_change_48 > sell_pump_threshold_36_1), (hl_pct_change_48 > sell_pump_threshold_36_2), (hl_pct_change_48 > sell_pump_threshold_36_3)])
[sell_pump_24_1, sell_pump_24_2, sell_pump_24_3] = security(syminfo.tickerid, informative_tf, [(hl_pct_change_48 > sell_pump_threshold_24_1), (hl_pct_change_48 > sell_pump_threshold_24_2), (hl_pct_change_48 > sell_pump_threshold_24_3)])

sell_custom_profit_0    = 0.012, sell_custom_rsi_0       = 34.0, sell_custom_profit_1    = 0.02, sell_custom_rsi_1       = 35.0, sell_custom_profit_2    = 0.03, sell_custom_rsi_2       = 37.0, sell_custom_profit_3    = 0.04, sell_custom_rsi_3       = 42.0, sell_custom_profit_4    = 0.05, sell_custom_rsi_4       = 43.0, sell_custom_profit_5    = 0.06, sell_custom_rsi_5       = 45.0, sell_custom_profit_6    = 0.07, sell_custom_rsi_6       = 52.0, sell_custom_profit_7    = 0.08, sell_custom_rsi_7       = 54.0, sell_custom_profit_8    = 0.09, sell_custom_rsi_8       = 55.0, sell_custom_profit_9    = 0.1, sell_custom_rsi_9       = 54.0, sell_custom_profit_10   = 0.12, sell_custom_rsi_10      = 42.0, sell_custom_profit_11   = 0.20, sell_custom_rsi_11      = 34.0

// # Profit under EMA200
sell_custom_under_profit_0 = 0.01, sell_custom_under_rsi_0 =  38.0, sell_custom_under_profit_1 =  0.02, sell_custom_under_rsi_1 =  56.0, sell_custom_under_profit_2 =  0.03, sell_custom_under_rsi_2 =  57.0, sell_custom_under_profit_3 =  0.04, sell_custom_under_rsi_3 =  58.0, sell_custom_under_profit_4 = 0.05, sell_custom_under_rsi_4 =  59.0, sell_custom_under_profit_5 = 0.06, sell_custom_under_rsi_5 =  60.0, sell_custom_under_profit_6 = 0.07, sell_custom_under_rsi_6 =  56.0, sell_custom_under_profit_7 = 0.08, sell_custom_under_rsi_7 =  54.0, sell_custom_under_profit_8 =  0.09, sell_custom_under_rsi_8 =  55.0, sell_custom_under_profit_9 =  0.1, sell_custom_under_rsi_9 =  54.0, sell_custom_under_profit_10 = 0.12, sell_custom_under_rsi_10 =  42.0, sell_custom_under_profit_11 = 0.2, sell_custom_under_rsi_11 =  34.0

// # Profit targets for pumped pairs 48h 1
sell_custom_pump_profit_1_1 = 0.01, sell_custom_pump_rsi_1_1 = 34.0, sell_custom_pump_profit_1_2 = 0.02, sell_custom_pump_rsi_1_2 = 40.0, sell_custom_pump_profit_1_3 = 0.04, sell_custom_pump_rsi_1_3 = 42.0, sell_custom_pump_profit_1_4 = 0.1, sell_custom_pump_rsi_1_4 = 42.0, sell_custom_pump_profit_1_5 = 0.2, sell_custom_pump_rsi_1_5 = 34.0

// # Profit targets for pumped pairs 36h 1,
sell_custom_pump_profit_2_1 = 0.01, sell_custom_pump_rsi_2_1 = 34.0, sell_custom_pump_profit_2_2 = 0.02, sell_custom_pump_rsi_2_2 = 40.0, sell_custom_pump_profit_2_3 = 0.04, sell_custom_pump_rsi_2_3 = 40.0, sell_custom_pump_profit_2_4 = 0.1, sell_custom_pump_rsi_2_4 = 42.0, sell_custom_pump_profit_2_5 = 0.2, sell_custom_pump_rsi_2_5 = 34.0

// # Profit targets for pumped pairs 24h 1
sell_custom_pump_profit_3_1 = 0.01, sell_custom_pump_rsi_3_1 = 34.0, sell_custom_pump_profit_3_2 = 0.02, sell_custom_pump_rsi_3_2 = 40.0, sell_custom_pump_profit_3_3 = 0.04, sell_custom_pump_rsi_3_3 = 40.0, sell_custom_pump_profit_3_4 = 0.1, sell_custom_pump_rsi_3_4 = 42.0, sell_custom_pump_profit_3_5 = 0.2, sell_custom_pump_rsi_3_5 = 34.0

// # SMA descending
sell_custom_dec_profit_min_1 = 0.05, sell_custom_dec_profit_max_1 = 0.12

// # Under EMA100
sell_custom_dec_profit_min_2 = 0.07, sell_custom_dec_profit_max_2 = 0.16

// # Trail 1
sell_trail_profit_min_1 = 0.16, sell_trail_profit_max_1 = 0.6, sell_trail_down_1 = 0.03, sell_trail_rsi_min_1 = 20.0, sell_trail_rsi_max_1 = 50.0

// # Trail 2
sell_trail_profit_min_2 = 0.1, sell_trail_profit_max_2 = 0.4, sell_trail_down_2 = 0.03, sell_trail_rsi_min_2 = 20.0, sell_trail_rsi_max_2 = 50.0

// # Trail 3
sell_trail_profit_min_3 = 0.06, sell_trail_profit_max_3 = 0.2, sell_trail_down_3 = 0.05

// # Trail 4
sell_trail_profit_min_4 = 0.03, sell_trail_profit_max_4 = 0.06, sell_trail_down_4 = 0.02

// # Under & near EMA200, accept profit
sell_custom_profit_under_rel_1 = 0.024, sell_custom_profit_under_rsi_diff_1 = 4.4

// # Under & near EMA200, take the loss
sell_custom_stoploss_under_rel_1 = 0.002, sell_custom_stoploss_under_rsi_diff_1 = 10.0

// # Long duration/recover stoploss 1
sell_custom_stoploss_long_profit_min_1 = -0.08, sell_custom_stoploss_long_profit_max_1 = -0.04, sell_custom_stoploss_long_recover_1 = 0.1, sell_custom_stoploss_long_rsi_diff_1 = 4.0

// # Long duration/recover stoploss 2
sell_custom_stoploss_long_recover_2 = 0.06, sell_custom_stoploss_long_rsi_diff_2 = 40.0

// # Pumped, descending SMA
sell_custom_pump_dec_profit_min_1 = 0.005, sell_custom_pump_dec_profit_max_1 = 0.05, sell_custom_pump_dec_profit_min_2 = 0.04, sell_custom_pump_dec_profit_max_2 = 0.06, sell_custom_pump_dec_profit_min_3 = 0.06, sell_custom_pump_dec_profit_max_3 = 0.09, sell_custom_pump_dec_profit_min_4 = 0.02, sell_custom_pump_dec_profit_max_4 = 0.04

// # Pumped 48h 1, under EMA200
sell_custom_pump_under_profit_min_1 = 0.04, sell_custom_pump_under_profit_max_1 = 0.09

// # Pumped trail 1
sell_custom_pump_trail_profit_min_1 = 0.05, sell_custom_pump_trail_profit_max_1 = 0.07, sell_custom_pump_trail_down_1 = 0.05, sell_custom_pump_trail_rsi_min_1 = 20.0, sell_custom_pump_trail_rsi_max_1 = 70.0

// # Stoploss, pumped, 48h 1
sell_custom_stoploss_pump_max_profit_1 = 0.01, sell_custom_stoploss_pump_min_1 = -0.02, sell_custom_stoploss_pump_max_1 = -0.01, sell_custom_stoploss_pump_ma_offset_1 =0.94

// # Stoploss, pumped, 48h 1
sell_custom_stoploss_pump_max_profit_2 = 0.025, sell_custom_stoploss_pump_loss_2 = -0.05, sell_custom_stoploss_pump_ma_offset_2 =0.92

// # Stoploss, pumped, 36h 3
sell_custom_stoploss_pump_max_profit_3 = 0.008, sell_custom_stoploss_pump_loss_3 = -0.12, sell_custom_stoploss_pump_ma_offset_3 = 0.88

// # Recover
sell_custom_recover_profit_1 = 0.06, sell_custom_recover_min_loss_1 = 0.12

sell_custom_recover_profit_min_2 = 0.01, sell_custom_recover_profit_max_2 = 0.05, sell_custom_recover_min_loss_2 = 0.06, sell_custom_recover_rsi_2 = 46.0

// # Profit for long duration trades
sell_custom_long_profit_min_1 = 0.03, sell_custom_long_profit_max_1 = 0.04, sell_custom_long_duration_min_1 = 180


// Protections
standard_buy_protection(close, buy_protection__ema_fast, ema_1, buy_protection__ema_slow, ema_2, buy_protection__close_above_ema_fast,  ema_3, buy_protection__close_above_ema_slow, ema_4, buy_protection__sma200_rising, sma_rising_value,buy_protection__sma200_1h_rising, sma_1h_rising_value, buy_protection__safe_dips, safe_dips, buy_protection__safe_pump, safe_pump, btc_1h_not_downtrend) =>
    i = ((buy_protection__ema_fast ? (ema_1 > ema_200) : true) and (buy_protection__ema_slow ? (ema_2 > ema_200_1h) : true) and (buy_protection__close_above_ema_fast ? (close > ema_3) : true) and (buy_protection__close_above_ema_slow ? (close > ema_4): true) and (buy_protection__sma200_rising ? (sma_200 > sma_200[sma_rising_value]) : true) and (buy_protection__sma200_1h_rising ? (sma_200_1h > sma_200_1h[sma_1h_rising_value]) : true) and (buy_protection__safe_dips ? safe_dips : true) and (buy_protection__safe_pump ? safe_pump : true) and (btc_1h_not_downtrend ? btc_not_downtrend_1h : true))
    i

// #############################################################
// Buy Condition 1

buy_01_protections = standard_buy_protection(close, buy_01_protection__ema_fast, ema_26, buy_01_protection__ema_slow, ema_100_1h, buy_01_protection__close_above_ema_fast, ema_200, buy_01_protection__close_above_ema_slow, ema_200, buy_01_protection__sma200_rising, buy_01_protection__sma200_rising_val, buy_01_protection__sma200_1h_rising, buy_01_protection__sma200_1h_rising_val, buy_01_protection__safe_dips, safe_dips_80, buy_01_protection__safe_pump, safe_pump_24_70, buy_1_btc_1h_not_downtrend)

buy_01_logic = (buy_01_protections and (((close - lowest(open, 36))/lowest(open, 36)) > buy_min_inc_1) and (rsi_1h > buy_rsi_1h_min_1) and (rsi_1h < buy_rsi_1h_max_1) and (rsi_5m < buy_rsi_1) and (mfi_5m < buy_mfi_1))


// Buy Condition 2
buy_02_protections = standard_buy_protection(close, buy_02_protection__ema_fast, ema_50, buy_02_protection__ema_slow, ema_20_1h, buy_02_protection__close_above_ema_fast, ema_200, buy_02_protection__close_above_ema_slow, ema_200, buy_02_protection__sma200_rising, buy_02_protection__sma200_rising_val, buy_02_protection__sma200_1h_rising, buy_02_protection__sma200_1h_rising_val, buy_02_protection__safe_dips, safe_dips_50, buy_02_protection__safe_pump, safe_pump_24_50, buy_2_btc_1h_not_downtrend)

buy_02_logic = (buy_02_protections and ((rsi_5m < (rsi_1h - buy_rsi_1h_diff_2)) and (mfi_5m < buy_mfi_2) and (close < (bb20_2_low * buy_bb_offset_2))))


// Buy Condition 3
buy_03_protections = (standard_buy_protection(close, buy_03_protection__ema_fast, ema_100, buy_03_protection__ema_slow, ema_100_1h, buy_03_protection__close_above_ema_fast, ema_200, buy_03_protection__close_above_ema_slow, ema_200, buy_03_protection__sma200_rising, buy_03_protection__sma200_rising_val, buy_03_protection__sma200_1h_rising, buy_03_protection__sma200_1h_rising_val, buy_03_protection__safe_dips, safe_dips_10, buy_03_protection__safe_pump, safe_pump_36_100, buy_3_btc_1h_not_downtrend) and (close > (ema_200_1h * buy_ema_rel_3)))

buy_03_logic = (buy_03_protections and (bb40_2_low[1] > 0) and (bb40_2_delta > (close * buy_bb40_bbdelta_close_3)) and (closedelta > (close*buy_bb40_closedelta_close_3)) and (tail < (bb40_2_delta * buy_bb40_tail_bbdelta_3)) and (close < bb40_2_low[1]) and (close <= close[1]))


// Buy Condition 4
buy_04_protections = standard_buy_protection(close, buy_04_protection__ema_fast, ema_50, buy_04_protection__ema_slow, ema_50_1h, buy_04_protection__close_above_ema_fast, ema_200, buy_04_protection__close_above_ema_slow, ema_200, buy_04_protection__sma200_rising, buy_04_protection__sma200_rising_val, buy_04_protection__sma200_1h_rising, buy_04_protection__sma200_1h_rising_val, buy_04_protection__safe_dips, safe_dips_10, buy_04_protection__safe_pump, safe_pump_48_110, buy_4_btc_1h_not_downtrend)

buy_04_logic = (buy_04_protections and (close < ema_50) and (close < (buy_bb20_close_bblowerband_4 * bb20_2_low)) and (volume < (volume_mean_30[1]*buy_bb20_volume_4)))


// Buy Condition 5
buy_05_protections = (standard_buy_protection(close, buy_05_protection__ema_fast, ema_100, buy_05_protection__ema_slow, ema_50_1h, buy_05_protection__close_above_ema_fast, ema_100, buy_05_protection__close_above_ema_slow, ema_35, buy_05_protection__sma200_rising, buy_05_protection__sma200_rising_val, buy_05_protection__sma200_1h_rising, buy_05_protection__sma200_1h_rising_val, buy_05_protection__safe_dips, safe_dips_100, buy_05_protection__safe_pump, safe_pump_36_20, buy_5_btc_1h_not_downtrend) and (close > (ema_200_1h * buy_ema_rel_5)))

buy_05_logic = (buy_05_protections and (ema_26 > ema_12) and ((ema_26 - ema_12) > (open * buy_ema_open_mult_5)) and ((ema_26[1] - ema_12[1]) > (open / 100)) and (close < (bb20_2_low * buy_bb_offset_5)))


// Buy Condition 6
buy_06_protections = standard_buy_protection(close, buy_06_protection__ema_fast, ema_50, buy_06_protection__ema_slow, ema_100_1h, buy_06_protection__close_above_ema_fast, ema_200, buy_06_protection__close_above_ema_slow, ema_200, buy_06_protection__sma200_rising, buy_06_protection__sma200_rising_val, buy_06_protection__sma200_1h_rising, buy_06_protection__sma200_1h_rising_val, buy_06_protection__safe_dips, safe_dips_50, buy_06_protection__safe_pump, safe_pump_36_20, buy_6_btc_1h_not_downtrend)

buy_06_logic = (buy_06_protections and (ema_26 > ema_12) and ((ema_26 - ema_12) > (open * buy_ema_open_mult_6)) and ((ema_26[1] - ema_12[1]) > (open/100)) and (close < (bb20_2_low * buy_bb_offset_6)))


// Buy Condition 7
buy_07_protections = standard_buy_protection(close, buy_07_protection__ema_fast, ema_100, buy_07_protection__ema_slow, ema_12_1h, buy_07_protection__close_above_ema_fast, ema_200, buy_07_protection__close_above_ema_slow, ema_200, buy_07_protection__sma200_rising, buy_07_protection__sma200_rising_val, buy_07_protection__sma200_1h_rising, buy_07_protection__sma200_1h_rising_val, buy_07_protection__safe_dips, safe_dips_50, buy_07_protection__safe_pump, safe_pump_24_50, buy_7_btc_1h_not_downtrend)

buy_07_logic = (buy_07_protections and (ema_26 > ema_12) and ((ema_26 - ema_12) > (open * buy_ema_open_mult_7)) and ((ema_26[1] - ema_12[1]) > (open/100)) and (rsi_5m < buy_rsi_7))


// Buy Condition 8
buy_08_protections = standard_buy_protection(close, buy_08_protection__ema_fast, ema_50, buy_08_protection__ema_slow, ema_12_1h, buy_08_protection__close_above_ema_fast, ema_200, buy_08_protection__close_above_ema_slow, ema_200, buy_08_protection__sma200_rising, buy_08_protection__sma200_rising_val, buy_08_protection__sma200_1h_rising, buy_08_protection__sma200_1h_rising_val, buy_08_protection__safe_dips, safe_dips_100, buy_08_protection__safe_pump, safe_pump_24_120, buy_8_btc_1h_not_downtrend)

buy_08_logic = (buy_08_protections and (rsi_5m < buy_rsi_8) and (volume > (volume[1] * buy_volume_8)) and (close > open) and ((close-low) > ((close-open) * buy_tail_diff_8)))


// Buy Condition 9
buy_09_protections = standard_buy_protection(close, buy_09_protection__ema_fast, ema_100, buy_09_protection__ema_slow, ema_50_1h, buy_09_protection__close_above_ema_fast, ema_200, buy_09_protection__close_above_ema_slow, ema_200, buy_09_protection__sma200_rising, buy_09_protection__sma200_rising_val, buy_09_protection__sma200_1h_rising, buy_09_protection__sma200_1h_rising_val, buy_09_protection__safe_dips, safe_dips_10, buy_09_protection__safe_pump, safe_pump_24_50, buy_9_btc_1h_not_downtrend)

buy_09_logic = ((close < (ema_20 * buy_ma_offset_9)) and (close < (bb20_2_low * buy_ma_offset_9)) and (rsi_1h > buy_rsi_1h_min_9) and (rsi_1h < buy_rsi_1h_max_9) and (mfi_5m < buy_mfi_9))


// Buy Condition 10
buy_10_protections = (standard_buy_protection(close, buy_10_protection__ema_fast, ema_50, buy_10_protection__ema_slow, ema_50_1h, buy_10_protection__close_above_ema_fast, ema_200, buy_10_protection__close_above_ema_slow, ema_200, buy_10_protection__sma200_rising, buy_10_protection__sma200_rising_val, buy_10_protection__sma200_1h_rising, buy_10_protection__sma200_1h_rising_val, buy_10_protection__safe_dips, safe_dips_100, buy_10_protection__safe_pump, safe_pump_24_50, buy_10_btc_1h_not_downtrend) and (ema_50_1h > ema_100_1h))

buy_10_logic = (buy_10_protections and (close < (sma_30 * buy_ma_offset_10)) and (close < (bb20_2_low * buy_bb_offset_10)) and (rsi_1h < buy_rsi_1h_10))


// Buy Condition 11
buy_11_protections = (standard_buy_protection(close, buy_11_protection__ema_fast, ema_50, buy_11_protection__ema_slow, ema_50_1h, buy_11_protection__close_above_ema_fast, ema_200, buy_11_protection__close_above_ema_slow, ema_200, buy_11_protection__sma200_rising, buy_11_protection__sma200_rising_val, buy_11_protection__sma200_1h_rising, buy_11_protection__sma200_1h_rising_val, buy_11_protection__safe_dips, safe_dips_100, buy_11_protection__safe_pump, safe_pump_24_50, buy_11_btc_1h_not_downtrend) and (ema_50_1h > ema_100_1h) and (safe_pump_36_50) and (safe_pump_48_100))

buy_11_logic = (buy_11_protections and ((close-lowest(open, 36))/(lowest(open, 36)) > buy_min_inc_11) and (close < (sma_30 * buy_ma_offset_11)) and (rsi_1h > buy_rsi_1h_min_11) and (rsi_1h < buy_rsi_1h_max_11) and (mfi_5m < buy_mfi_11))


// Buy Condition 12
buy_12_protections = standard_buy_protection(close, buy_12_protection__ema_fast, ema_50, buy_12_protection__ema_slow, ema_50_1h, buy_12_protection__close_above_ema_fast, ema_200, buy_12_protection__close_above_ema_slow, ema_200, buy_12_protection__sma200_rising, buy_12_protection__sma200_rising_val, buy_12_protection__sma200_1h_rising, buy_12_protection__sma200_1h_rising_val, buy_12_protection__safe_dips, safe_dips_100, buy_12_protection__safe_pump, safe_pump_24_50, buy_12_btc_1h_not_downtrend)

buy_12_logic = (buy_12_protections and (close < (sma_30 * buy_ma_offset_12)) and (ewo_5m > buy_ewo_12) and (rsi_5m < buy_rsi_12))


// Buy Condition 13
buy_13_protections = (standard_buy_protection(close, buy_13_protection__ema_fast, ema_50, buy_13_protection__ema_slow, ema_50_1h, buy_13_protection__close_above_ema_fast, ema_200, buy_13_protection__close_above_ema_slow, ema_200, buy_13_protection__sma200_rising, buy_13_protection__sma200_rising_val, buy_13_protection__sma200_1h_rising, buy_13_protection__sma200_1h_rising_val, buy_13_protection__safe_dips, safe_dips_10, buy_13_protection__safe_pump, safe_pump_24_50, buy_13_btc_1h_not_downtrend) and (ema_50_1h > ema_100_1h))

buy_13_logic = (buy_13_protections and (close < (sma_30 * buy_ma_offset_13)) and (ewo_5m < buy_ewo_13) )


// Buy Condition 14
buy_14_protections = standard_buy_protection(close, buy_14_protection__ema_fast, ema_50, buy_14_protection__ema_slow, ema_50_1h, buy_14_protection__close_above_ema_fast, ema_200, buy_14_protection__close_above_ema_slow, ema_200, buy_14_protection__sma200_rising, buy_14_protection__sma200_rising_val, buy_14_protection__sma200_1h_rising, buy_14_protection__sma200_1h_rising_val, buy_14_protection__safe_dips, safe_dips_10, buy_14_protection__safe_pump, safe_pump_24_70, buy_14_btc_1h_not_downtrend)

buy_14_logic = (buy_14_protections and (ema_26 > ema_12) and ((ema_26 - ema_12) > (open * buy_ema_open_mult_14)) and ((ema_26[1] - ema_12[1]) > (open/100)) and (close < (bb20_2_low * buy_bb_offset_14)) and (close < (ema_20 * buy_ma_offset_14)))


// Buy Condition 15
buy_15_protections = (standard_buy_protection(close, buy_15_protection__ema_fast, ema_50, buy_15_protection__ema_slow, ema_50_1h, buy_15_protection__close_above_ema_fast, ema_200, buy_15_protection__close_above_ema_slow, ema_200, buy_15_protection__sma200_rising, buy_15_protection__sma200_rising_val, buy_15_protection__sma200_1h_rising, buy_15_protection__sma200_1h_rising_val, buy_15_protection__safe_dips, safe_dips_50, buy_15_protection__safe_pump, safe_pump_36_10, buy_15_btc_1h_not_downtrend) and (close > (ema_200_1h * buy_ema_rel_15)))

buy_15_logic = (buy_15_protections and (ema_26 > ema_12) and ((ema_26-ema_12) > (open * buy_ema_open_mult_15)) and ((ema_26[1] - ema_12[1]) > (open/100)) and (rsi_5m < buy_rsi_15) and (close < (ema_20 * buy_ma_offset_15)))


// Buy Condition 16
buy_16_protections = standard_buy_protection(close, buy_16_protection__ema_fast, ema_50, buy_16_protection__ema_slow, ema_50_1h, buy_16_protection__close_above_ema_fast, ema_200, buy_16_protection__close_above_ema_slow, ema_50, buy_16_protection__sma200_rising, buy_16_protection__sma200_rising_val, buy_16_protection__sma200_1h_rising, buy_16_protection__sma200_1h_rising_val, buy_16_protection__safe_dips, safe_dips_10, buy_16_protection__safe_pump, safe_pump_24_10, buy_16_btc_1h_not_downtrend)

buy_16_logic = (buy_16_protections and (close < (ema_20 * buy_ma_offset_16)) and (ewo_5m > buy_ewo_16) and (rsi_5m < buy_rsi_16))


// Buy Condition 17
buy_17_protections = standard_buy_protection(close, buy_17_protection__ema_fast, ema_50, buy_17_protection__ema_slow, ema_50_1h, buy_17_protection__close_above_ema_fast, ema_200, buy_17_protection__close_above_ema_slow, ema_200, buy_17_protection__sma200_rising, buy_17_protection__sma200_rising_val, buy_17_protection__sma200_1h_rising, buy_17_protection__sma200_1h_rising_val, buy_17_protection__safe_dips, safe_dips_10, buy_17_protection__safe_pump, safe_pump_24_120, buy_17_btc_1h_not_downtrend)

buy_17_logic = (buy_17_protections and (close < (ema_20 * buy_ma_offset_17)) and (ewo_5m < buy_ewo_17) )


// Buy Condition 18
buy_18_protections = (standard_buy_protection(close, buy_18_protection__ema_fast, ema_100, buy_18_protection__ema_slow, ema_50_1h, buy_18_protection__close_above_ema_fast, ema_200, buy_18_protection__close_above_ema_slow, ema_200, buy_18_protection__sma200_rising, buy_18_protection__sma200_rising_val, buy_18_protection__sma200_1h_rising, buy_18_protection__sma200_1h_rising_val, buy_18_protection__safe_dips, safe_dips_50, buy_18_protection__safe_pump, safe_pump_24_60, buy_18_btc_1h_not_downtrend) and (sma_200) > (sma_200[20]) and (sma_200_1h > sma_200_1h[36]))

buy_18_logic = (buy_18_protections and (rsi_5m < buy_rsi_18) and (close < (bb20_2_low * buy_bb_offset_18)))


// Buy Condition 19
buy_19_protections = (standard_buy_protection(close, buy_19_protection__ema_fast, ema_50, buy_19_protection__ema_slow, ema_100_1h, buy_19_protection__close_above_ema_fast, ema_200, buy_19_protection__close_above_ema_slow, ema_200, buy_19_protection__sma200_rising, buy_19_protection__sma200_rising_val, buy_19_protection__sma200_1h_rising, buy_19_protection__sma200_1h_rising_val, buy_19_protection__safe_dips, safe_dips_50, buy_19_protection__safe_pump, safe_pump_24_50, buy_19_btc_1h_not_downtrend) and (ema_50_1h > ema_200_1h))

buy_19_logic = (buy_19_protections and (close[1] > ema_100_1h) and (low < ema_100_1h) and (close > ema_100_1h) and (rsi_1h > buy_rsi_1h_min_19) and (chop_5m < buy_chop_min_19))


// Buy Condition 20
buy_20_protections = standard_buy_protection(close, buy_20_protection__ema_fast, ema_50, buy_20_protection__ema_slow, ema_50_1h, buy_20_protection__close_above_ema_fast, ema_200, buy_20_protection__close_above_ema_slow, ema_200, buy_20_protection__sma200_rising, buy_20_protection__sma200_rising_val, buy_20_protection__sma200_1h_rising, buy_20_protection__sma200_1h_rising_val, buy_20_protection__safe_dips, safe_dips_10, buy_20_protection__safe_pump, safe_pump_24_50, buy_20_btc_1h_not_downtrend)

buy_20_logic = (buy_20_protections and (rsi_5m < buy_rsi_20) and (rsi_1h < buy_rsi_1h_20))


// Buy Condition 21
buy_21_protections = standard_buy_protection(close, buy_21_protection__ema_fast, ema_50, buy_21_protection__ema_slow, ema_50_1h, buy_21_protection__close_above_ema_fast, ema_200, buy_21_protection__close_above_ema_slow, ema_200, buy_21_protection__sma200_rising, buy_21_protection__sma200_rising_val, buy_21_protection__sma200_1h_rising, buy_21_protection__sma200_1h_rising_val, buy_21_protection__safe_dips, safe_dips_90, buy_21_protection__safe_pump, safe_pump_24_50, buy_21_btc_1h_not_downtrend)

buy_21_logic = (buy_21_protections and (rsi_5m < buy_rsi_21) and (rsi_1h < buy_rsi_1h_21))


// Buy Condition 22
buy_22_protections = (standard_buy_protection(close, buy_22_protection__ema_fast, ema_50, buy_22_protection__ema_slow, ema_50_1h, buy_22_protection__close_above_ema_fast, ema_200, buy_22_protection__close_above_ema_slow, ema_200, buy_22_protection__sma200_rising, buy_22_protection__sma200_rising_val, buy_22_protection__sma200_1h_rising, buy_22_protection__sma200_1h_rising_val, buy_22_protection__safe_dips, safe_dips_110, buy_22_protection__safe_pump, safe_pump_24_50, buy_22_btc_1h_not_downtrend) and (ema_100_1h > ema_100_1h[12]) and (ema_200_1h > ema_200_1h[36]) )

buy_22_logic = (buy_22_protections and ((volume_mean_4 * buy_volume_22) > volume) and (close < (sma_30 * buy_ma_offset_22)) and (close < (bb20_2_low * buy_bb_offset_22)) and (ewo_5m > buy_ewo_22) and (rsi_5m < buy_rsi_22) )


// Buy Condition 23
buy_23_protections = standard_buy_protection(close, buy_23_protection__ema_fast, ema_50, buy_23_protection__ema_slow, ema_50_1h, buy_23_protection__close_above_ema_fast, ema_200, buy_23_protection__close_above_ema_slow, ema_200, buy_23_protection__sma200_rising, buy_23_protection__sma200_rising_val, buy_23_protection__sma200_1h_rising, buy_23_protection__sma200_1h_rising_val, buy_23_protection__safe_dips, safe_dips_100, buy_23_protection__safe_pump, safe_pump_24_50, buy_23_btc_1h_not_downtrend)

buy_23_logic = (buy_23_protections and (close < (bb20_2_low * buy_bb_offset_23)) and (ewo_5m < buy_ewo_23) and (rsi_5m < buy_rsi_23) and (rsi_1h < buy_rsi_1h_23))


// Buy Condition 24
buy_24_protections = standard_buy_protection(close, buy_24_protection__ema_fast, ema_50, buy_24_protection__ema_slow, ema_50_1h, buy_24_protection__close_above_ema_fast, ema_200, buy_24_protection__close_above_ema_slow, ema_200, buy_24_protection__sma200_rising, buy_24_protection__sma200_rising_val, buy_24_protection__sma200_1h_rising, buy_24_protection__sma200_1h_rising_val, buy_24_protection__safe_dips, safe_dips_20, buy_24_protection__safe_pump, safe_pump_24_50, buy_24_btc_1h_not_downtrend)

buy_24_logic = (buy_24_protections and (ema_12_1h[12] < ema_35_1h[12]) and (ema_12_1h > ema_35_1h) and (cmf_1h[12] < 0) and (cmf_1h > 0) and (rsi_5m < buy_24_rsi_max) and (rsi_1h > buy_24_rsi_1h_min))

// Buy Condition 25

buy_25_protections = standard_buy_protection(close, buy_25_protection__ema_fast, ema_50, buy_25_protection__ema_slow, ema_100_1h, buy_25_protection__close_above_ema_fast, ema_50, buy_25_protection__close_above_ema_slow, ema_200, buy_25_protection__sma200_rising, buy_25_protection__sma200_rising_val, buy_25_protection__sma200_1h_rising, buy_25_protection__sma200_1h_rising_val, buy_25_protection__safe_dips, safe_dips_10, buy_25_protection__safe_pump, safe_pump_24_20, buy_25_btc_1h_not_downtrend)

buy_25_logic = (buy_25_protections and (rsi_5m_20 < rsi_5m_20[1]) and (rsi_5m_4 < buy_25_rsi_14) and (ema_20_1h > ema_26_1h) and (close < (sma_20 * buy_25_ma_offset)) and (open > (sma_20 * buy_25_ma_offset)) and ((open < ema_20_1h and low < ema_20_1h) or (open > ema_20_1h and low > ema_20_1h)))

// Buy Condition 26

buy_26_protections = standard_buy_protection(close, buy_26_protection__ema_fast, ema_50, buy_26_protection__ema_slow, ema_100_1h, buy_26_protection__close_above_ema_fast, ema_50, buy_26_protection__close_above_ema_slow, ema_200, buy_26_protection__sma200_rising, buy_26_protection__sma200_rising_val, buy_26_protection__sma200_1h_rising, buy_26_protection__sma200_1h_rising_val, buy_26_protection__safe_dips, safe_dips_10, buy_26_protection__safe_pump, safe_pump_48_100, buy_26_btc_1h_not_downtrend)

buy_26_logic = (buy_26_protections and (close < (zema_61 * buy_26_zema_low_offset)))

// Buy Condition 27

buy_27_protections = standard_buy_protection(close, buy_27_protection__ema_fast, ema_50, buy_27_protection__ema_slow, ema_100_1h, buy_27_protection__close_above_ema_fast, ema_50, buy_27_protection__close_above_ema_slow, ema_200, buy_27_protection__sma200_rising, buy_27_protection__sma200_rising_val, buy_27_protection__sma200_1h_rising, buy_27_protection__sma200_1h_rising_val, buy_27_protection__safe_dips, safe_dips_10, buy_27_protection__safe_pump, safe_pump_36_50, buy_27_btc_1h_not_downtrend)

buy_27_logic = (buy_27_protections and (r_480_5m < -buy_27_wr_max) and (r_480_1h < -buy_27_wr_1h_max ) and ((rsi_1h + rsi_5m) < buy_27_rsi_max))

buy_28_protections = standard_buy_protection(close, buy_28_protection__ema_fast, ema_50, buy_28_protection__ema_slow, ema_100_1h, buy_28_protection__close_above_ema_fast, ema_50, buy_28_protection__close_above_ema_slow, ema_200, buy_28_protection__sma200_rising, buy_28_protection__sma200_rising_val, buy_28_protection__sma200_1h_rising, buy_28_protection__sma200_1h_rising_val, buy_28_protection__safe_dips, safe_dips_10, buy_28_protection__safe_pump, safe_pump_36_110, buy_28_btc_1h_not_downtrend)

buy_28_logic = (buy_28_protections and (moderi_64) and (close < (hull_75 * 0.92)) and (ewo_5m > 12.4) and (rsi_5m < 38.0))


// // // #############################################################
// // // Sell Conditions

sell_01_logic = ((rsi_5m > sell_rsi_bb_1) and (close > bb20_2_upp) and (close[1] > bb20_2_upp[1]) and (close[2] > bb20_2_upp[2]) and (close[3] > bb20_2_upp[3]) and (close[4] > bb20_2_upp[4]) and (close[5] > bb20_2_upp[5]))
sell_02_logic = ((rsi_5m > sell_rsi_bb_2) and (close > bb20_2_upp) and (close[1] > bb20_2_upp[1]) and (close[2] > bb20_2_upp[2]))
// sell_03_logic = (rsi_5m > sell_rsi_main_3)
sell_04_logic = ((rsi_5m > sell_dual_rsi_rsi_4) and (rsi_1h > sell_dual_rsi_rsi_1h_4))
sell_06_logic = ((close < ema_200) and (close > ema_50) and (rsi_5m > sell_rsi_under_6))
sell_07_logic = ((rsi_1h > sell_rsi_1h_7) and (crossed_below_ema_12_26))
sell_08_logic = (close > (bb20_2_upp_1h * sell_bb_relative_8))


plotshape(buy_01_logic, title="1", text="1", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_02_logic, title="2", text="2", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_03_logic, title="3", text="3", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_04_logic, title="4", text="4", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_05_logic, title="5", text="5", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_06_logic, title="6", text="6", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_07_logic, title="7", text="7", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_08_logic, title="8", text="8", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_09_logic, title="9", text="9", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_10_logic, title="10", text="10", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_11_logic, title="11", text="11", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_12_logic, title="12", text="12", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_13_logic, title="13", text="13", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_14_logic, title="14", text="14", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_15_logic, title="15", text="15", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_16_logic, title="16", text="16", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_17_logic, title="17", text="17", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_18_logic, title="18", text="18", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_19_logic, title="19", text="19", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_20_logic, title="20", text="20", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_21_logic, title="21", text="21", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_22_logic, title="22", text="22", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_23_logic, title="23", text="23", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_24_logic, title="24", text="24", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_25_logic, title="25", text="25", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_26_logic, title="26", text="26", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_27_logic, title="27", text="27", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
plotshape(buy_28_logic, title="28", text="28", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)


plotshape(sell_01_logic, title="1", text="1", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
plotshape(sell_02_logic, title="2", text="2", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
// plotshape(sell_03_logic, title="3", text="3", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
plotshape(sell_04_logic, title="4", text="4", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
plotshape(sell_06_logic, title="5", text="5", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
plotshape(sell_07_logic, title="6", text="6", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
plotshape(sell_08_logic, title="7", text="7", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)

long_signal = (buy_01_logic or buy_02_logic or buy_03_logic or buy_04_logic or buy_05_logic or buy_06_logic or buy_07_logic or buy_08_logic or buy_09_logic or buy_10_logic or buy_11_logic or buy_12_logic or buy_13_logic or buy_14_logic or buy_15_logic or buy_16_logic or buy_17_logic or buy_18_logic or buy_19_logic or buy_20_logic or buy_21_logic or buy_22_logic or buy_23_logic or buy_24_logic or buy_25_logic or buy_26_logic or buy_27_logic or buy_28_logic)

sell_signal = (sell_01_logic or sell_02_logic or sell_04_logic or sell_06_logic or sell_07_logic or sell_08_logic)

// Entry Price
// entry_price = valuewhen(condition=long_signal, source=close, occurrence=0)

if (long_signal and TradeDateIsAllowed())
    strategy.entry("Long", strategy.long, alert_message="{{ticker}} Long Signal - Entry Price: " + tostring(close) + " Timeframe: {{interval}}")

// custom sell

sell_over_main(current_profit) =>
    is_valid = false, name = ""

    if (close > ema_200)
        if (current_profit > sell_custom_profit_11)
            if (rsi_5m < sell_custom_rsi_11 and ema_25 < ema_50)
                is_valid := true, name := "signal_profit_11"
        else if (current_profit > sell_custom_profit_10)
            if (rsi_5m < sell_custom_rsi_10 and ema_25 < ema_50)
                is_valid := true, name := "signal_profit_10"
        else if (current_profit > sell_custom_profit_9)
            if (rsi_5m < sell_custom_rsi_9 and ema_25 < ema_50)
                is_valid := true, name := "signal_profit_9"
        else if (current_profit > sell_custom_profit_8)
            if (rsi_5m < sell_custom_rsi_8 and ema_25 < ema_50)
                is_valid := true, name := "signal_profit_8"
        else if (current_profit > sell_custom_profit_7)
            if (rsi_5m < sell_custom_rsi_7 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_7"
        else if (current_profit > sell_custom_profit_6)
            if (rsi_5m < sell_custom_rsi_6 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_6"
        else if (current_profit > sell_custom_profit_5)
            if (rsi_5m < sell_custom_rsi_5 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_5"
        else if (current_profit > sell_custom_profit_4)
            if (rsi_5m < sell_custom_rsi_4 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_4"
        else if (current_profit > sell_custom_profit_3)
            if (rsi_5m < sell_custom_rsi_3 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_3"
        else if (current_profit > sell_custom_profit_2)
            if (rsi_5m < sell_custom_rsi_2 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_2"
        else if (current_profit > sell_custom_profit_1)
            if (rsi_5m < sell_custom_rsi_1 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_1"
        else if (current_profit > sell_custom_profit_0)
            if (rsi_5m < sell_custom_rsi_0 and ema_25 < ema_50 and cmf_5m < 0.0)
                is_valid := true, name := "signal_profit_0"
        else
            is_valid := false, name := ""
    else
        is_valid := false, name := ""
    
    [is_valid, name]

sell_under_main(current_profit) =>
    is_valid = false, name = ""

    if (close > ema_200)
        if (current_profit > sell_custom_under_profit_11 and rsi_5m < sell_custom_under_rsi_11 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_11"
        if (current_profit > sell_custom_under_profit_10 and rsi_5m < sell_custom_under_rsi_10 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_10"
        if (current_profit > sell_custom_under_profit_9 and rsi_5m < sell_custom_under_rsi_9 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_9"
        if (current_profit > sell_custom_under_profit_8 and rsi_5m < sell_custom_under_rsi_8 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_8"
        if (current_profit > sell_custom_under_profit_7 and rsi_5m < sell_custom_under_rsi_7 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_7"
        if (current_profit > sell_custom_under_profit_6 and rsi_5m < sell_custom_under_rsi_6 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_6"
        if (current_profit > sell_custom_under_profit_5 and rsi_5m < sell_custom_under_rsi_5 and ema_25 < ema_50)
            is_valid := true, name := "signal_profit_u_5"
        if (current_profit > sell_custom_under_profit_4 and rsi_5m < sell_custom_under_rsi_4)
            is_valid := true, name := "signal_profit_u_4"
        if (current_profit > sell_custom_under_profit_3 and rsi_5m < sell_custom_under_rsi_3)
            is_valid := true, name := "signal_profit_u_3"
        if (current_profit > sell_custom_under_profit_2 and rsi_5m < sell_custom_under_rsi_2)
            is_valid := true, name := "signal_profit_u_2"
        if (current_profit > sell_custom_under_profit_1 and rsi_5m < sell_custom_under_rsi_1)
            is_valid := true, name := "signal_profit_u_1"
        if (current_profit > sell_custom_under_profit_0 and rsi_5m < sell_custom_under_rsi_0 and cmf_5m < 0.0)
            is_valid := true, name := "signal_profit_u_0"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_pump_main(current_profit) =>
    is_valid = false, name = ""
    if (sell_pump_48_1)
        if (current_profit > sell_custom_pump_profit_1_5 and rsi_5m < sell_custom_pump_rsi_1_5)
            is_valid := true, name := "signal_profit_p_1_5"
        else if (sell_custom_pump_profit_1_5 > current_profit and current_profit > sell_custom_pump_profit_1_4 and rsi_5m < sell_custom_pump_rsi_1_4)
            is_valid := true, name := "signal_profit_p_1_4"
        else if (sell_custom_pump_profit_1_4 > current_profit and current_profit > sell_custom_pump_profit_1_3 and rsi_5m < sell_custom_pump_rsi_1_3)
            is_valid := true, name := "signal_profit_p_1_3"
        else if (sell_custom_pump_profit_1_3 > current_profit and current_profit > sell_custom_pump_profit_1_2 and rsi_5m < sell_custom_pump_rsi_1_2)
            is_valid := true, name := "signal_profit_p_1_2"
        else if (sell_custom_pump_profit_1_2 > current_profit and current_profit > sell_custom_pump_profit_1_1 and rsi_5m < sell_custom_pump_rsi_1_1)
            is_valid := true, name := "signal_profit_p_1_1"
        else
            is_valid := false, name := ""
    else if (sell_pump_36_1)
        if (current_profit > sell_custom_pump_profit_2_5 and rsi_5m < sell_custom_pump_rsi_2_5)
            is_valid := true, name := "signal_profit_p_2_5"
        else if (sell_custom_pump_profit_2_5 > current_profit and current_profit > sell_custom_pump_profit_2_4 and rsi_5m < sell_custom_pump_rsi_2_4)
            is_valid := true, name := "signal_profit_p_2_4"
        else if (sell_custom_pump_profit_2_4 > current_profit and current_profit > sell_custom_pump_profit_2_3 and rsi_5m < sell_custom_pump_rsi_2_3)
            is_valid := true, name := "signal_profit_p_2_3"
        else if (sell_custom_pump_profit_2_3 > current_profit and current_profit > sell_custom_pump_profit_2_2 and rsi_5m < sell_custom_pump_rsi_2_2)
            is_valid := true, name := "signal_profit_p_2_2"
        else if (sell_custom_pump_profit_2_2 > current_profit and current_profit > sell_custom_pump_profit_2_1 and rsi_5m < sell_custom_pump_rsi_2_1)
            is_valid := true, name := "signal_profit_p_2_1"
        else
            is_valid := false, name := ""
    else if (sell_pump_24_1)
        if (current_profit > sell_custom_pump_profit_3_5 and rsi_5m < sell_custom_pump_rsi_3_5)
            is_valid := true, name := "signal_profit_p_3_5"
        else if (sell_custom_pump_profit_3_5 > current_profit and current_profit > sell_custom_pump_profit_3_4 and rsi_5m < sell_custom_pump_rsi_3_4)
            is_valid := true, name := "signal_profit_p_3_4"
        else if (sell_custom_pump_profit_3_4 > current_profit and current_profit > sell_custom_pump_profit_3_3 and rsi_5m < sell_custom_pump_rsi_3_3)
            is_valid := true, name := "signal_profit_p_3_3"
        else if (sell_custom_pump_profit_3_3 > current_profit and current_profit > sell_custom_pump_profit_3_2 and rsi_5m < sell_custom_pump_rsi_3_2)
            is_valid := true, name := "signal_profit_p_3_2"
        else if (sell_custom_pump_profit_3_2 > current_profit and current_profit > sell_custom_pump_profit_3_1 and rsi_5m < sell_custom_pump_rsi_3_1)
            is_valid := true, name := "signal_profit_p_3_1"
        else
            is_valid := false, name := ""
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_dec_main(current_profit) =>
    is_valid = false, name = ""
    if (sell_custom_dec_profit_max_1 > current_profit and current_profit > sell_custom_dec_profit_min_1 and sma_200_dec_20)
        is_valid := true, name := "signal_profit_d_1"
    else if (sell_custom_dec_profit_max_2 > current_profit and current_profit > sell_custom_dec_profit_min_2 and close < ema_100)
        is_valid := true, name := "signal_profit_d_2"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_trail_main(current_profit, max_profit) =>
    is_valid = false, name = ""

    if (sell_trail_profit_max_1 > current_profit and current_profit > sell_trail_profit_min_1 and sell_trail_rsi_min_1 < rsi_5m and rsi_5m < sell_trail_rsi_max_1 and max_profit > (current_profit + sell_trail_down_1))
        is_valid := true, name := "signal_profit_t_1"
    else if (sell_trail_profit_max_2 > current_profit and current_profit > sell_trail_profit_min_2 and sell_trail_rsi_min_2 < rsi_5m and rsi_5m < sell_trail_rsi_max_2 and max_profit > (current_profit + sell_trail_down_2) and ema_25 < ema_50)
        is_valid := true, name := "signal_profit_t_2"
    else if (sell_trail_profit_max_3 > current_profit and current_profit > sell_trail_profit_min_3 and max_profit > (current_profit + sell_trail_down_3) and sma_200_dec_20_1h)
        is_valid := true, name := "signal_profit_t_3"
    else if (sell_trail_profit_max_4 > current_profit and current_profit > sell_trail_profit_min_4 and max_profit > (current_profit + sell_trail_down_4) and sma_200_dec_24 and cmf_5m < 0.0)
        is_valid := true, name := "signal_profit_t_4"
    else if (close < ema_200 and current_profit > sell_trail_profit_min_3 and current_profit < sell_trail_profit_max_3 and max_profit > (current_profit + sell_trail_down_3))
        is_valid := true, name := "signal_profit_u_t_1"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_duration_main(current_profit, barsFromLong) =>
    is_valid = false, name = ""
    if (sell_pump_24_1 and (0.2 > current_profit) and (current_profit > 0.07) and barsFromLong <= 6)
        is_valid := true, name := "signal_profit_p_s_1"
    else if ((sell_custom_long_profit_min_1 < current_profit) and (current_profit < sell_custom_long_profit_max_1) and barsFromLong > sell_custom_long_duration_min_1)
        is_valid := true, name := "signal_profit_l_1"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_under_min(current_profit) =>
    is_valid = false, name = ""
    if (current_profit > 0.0 and close < ema_200 and (((ema_200 - close)/close) < sell_custom_profit_under_rel_1) and (rsi_5m > (rsi_1h + sell_custom_profit_under_rsi_diff_1)))
        is_valid := true, name := "signal_profit_u_e_1"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_stoploss(current_profit, max_profit, max_loss, barsFromLong) =>
    is_valid = false, name = ""

    if (current_profit < 0.0 and sma_200_dec_24 and cmf_5m < 0.0 and close < ema_200 and ema_25 < ema_50 and barsFromLong > 144 and (rsi_5m > (rsi_1h + sell_custom_stoploss_under_rsi_diff_1)) and (((ema_200 - close)/close) < sell_custom_stoploss_under_rel_1))
        is_valid := true, name := "signal_stoploss_u_1"
    else if (-0.03 > current_profit and current_profit > -0.07 and (btc_not_downtrend_1h == false) and max_profit < 0.005 and sma_200_dec_24 and cmf_5m < 0.0 and close < ema_200 and ema_25 < ema_50)
        is_valid := true, name := "signal_stoploss_u_b_1"

    else if (sell_custom_stoploss_long_profit_min_1 < current_profit and current_profit < sell_custom_stoploss_long_profit_max_1 and current_profit > (-max_loss + sell_custom_stoploss_long_recover_1) and close < ema_200 and cmf_5m < 0.0 and rsi_5m > (rsi_1h + sell_custom_stoploss_long_rsi_diff_1) and sma_200_dec_24 and barsFromLong > 240)
        is_valid := true, name := "signal_stoploss_l_r_u_1"
    else if (current_profit < 0.0 and current_profit > (-max_loss + sell_custom_stoploss_long_recover_2) and close < ema_200 and cmf_5m < 0.0 and rsi_5m > (rsi_1h + sell_custom_stoploss_long_rsi_diff_2) and sma_200_dec_24 and barsFromLong > 240)
        is_valid := true, name := "signal_stoploss_l_r_u_2"

    else if (max_profit < sell_custom_stoploss_pump_max_profit_2 and current_profit < sell_custom_stoploss_pump_loss_2 and sell_pump_48_1 and close < (ema_200 * sell_custom_stoploss_pump_ma_offset_2) and cmf_5m < 0.0)
        is_valid := true, name := "signal_stoploss_p_2"
    else if (max_profit < sell_custom_stoploss_pump_max_profit_3 and current_profit < sell_custom_stoploss_pump_loss_3 and sell_pump_36_3 and close < (ema_200 * sell_custom_stoploss_pump_ma_offset_3))
        is_valid := true, name := "signal_stoploss_p_3"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_pump_dec(current_profit) =>
    is_valid = false, name = ""

    if (sell_custom_pump_dec_profit_max_1 > current_profit and current_profit > sell_custom_pump_dec_profit_min_1 and sell_pump_48_1 and sma_200_dec_20 and close < ema_200)
        is_valid := true, name := "signal_profit_p_d_1"
    else if (sell_custom_pump_dec_profit_max_2 > current_profit and current_profit > sell_custom_pump_dec_profit_min_2 and sell_pump_48_2 and sma_200_dec_20 and close < ema_200)
        is_valid := true, name := "signal_profit_p_d_2"
    else if (sell_custom_pump_dec_profit_max_3 > current_profit and current_profit > sell_custom_pump_dec_profit_min_3 and sell_pump_48_3 and sma_200_dec_20 and close < ema_200)
        is_valid := true, name := "signal_profit_p_d_3"
    else if (sell_custom_pump_dec_profit_max_4 > current_profit and current_profit > sell_custom_pump_dec_profit_min_4 and sell_pump_24_2 and sma_200_dec_20)
        is_valid := true, name := "signal_profit_p_d_4"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_pump_extra(current_profit, max_profit) =>
    is_valid = false, name = ""

    if (sell_custom_pump_under_profit_max_1 > current_profit and current_profit > sell_custom_pump_under_profit_min_1 and sell_pump_48_1 and close < ema_200)
        is_valid := true, name := "signal_profit_p_u_1"
    
    else if (sell_pump_36_2 and sell_custom_pump_trail_profit_max_1 > current_profit and current_profit > sell_custom_pump_trail_profit_min_1 and sell_custom_pump_trail_rsi_min_1 < rsi_5m and rsi_5m < sell_custom_pump_trail_rsi_max_1 and max_profit > (current_profit + sell_custom_pump_trail_down_1))
        is_valid := true, name := "signal_profit_p_t_1"

    else
        is_valid := false, name := ""

    [is_valid, name]

sell_recover(current_profit, max_loss) =>
    is_valid = false, name = ""

    if (max_loss > sell_custom_recover_min_loss_1 and current_profit > sell_custom_recover_profit_1)
        is_valid := true, name := "signal_profit_r_1"
    else if (max_loss > sell_custom_recover_min_loss_2 and sell_custom_recover_profit_max_2 > current_profit and current_profit > sell_custom_recover_profit_min_2 and rsi_5m < sell_custom_recover_rsi_2 and ema_25 < ema_50)
        is_valid := true, name := "signal_profit_r_2"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_r_1(current_profit) =>
    is_valid = false, name = ""

    if (0.02 > current_profit and current_profit > 0.012 and r_480_5m > -2.0)
        is_valid := true, name := "signal_profit_w_1_1"
    else if (0.03 > current_profit and current_profit > 0.02 and r_480_5m > -2.1)
        is_valid := true, name := "signal_profit_w_1_2"
    else if (0.04 > current_profit and current_profit > 0.03 and r_480_5m > -2.2)
        is_valid := true, name := "signal_profit_w_1_3"
    else if (0.05 > current_profit and current_profit > 0.04 and r_480_5m > -2.3)
        is_valid := true, name := "signal_profit_w_1_4"
    else if (0.06 > current_profit and current_profit > 0.05 and r_480_5m > -2.4)
        is_valid := true, name := "signal_profit_w_1_5"
    else if (0.07 > current_profit and current_profit > 0.06 and r_480_5m > -2.5)
        is_valid := true, name := "signal_profit_w_1_6"
    else if (0.08 > current_profit and current_profit > 0.07 and r_480_5m > -2.6)
        is_valid := true, name := "signal_profit_w_1_7"
    else if (0.09 > current_profit and current_profit > 0.08 and r_480_5m > -5.5)
        is_valid := true, name := "signal_profit_w_1_8"
    else if (0.1 > current_profit and current_profit > 0.09 and r_480_5m > -3.0)
        is_valid := true, name := "signal_profit_w_1_9"
    else if (0.12 > current_profit and current_profit > 0.1 and r_480_5m > -8.0)
        is_valid := true, name := "signal_profit_w_1_10"
    else if (0.2 > current_profit and current_profit > 0.12 and r_480_5m > -2.0 and rsi_5m > 78.0)
        is_valid := true, name := "signal_profit_w_1_11"
    else if (current_profit > 0.2 and r_480_5m > -1.5 and rsi_5m > 80.0)
        is_valid := true, name := "signal_profit_w_1_12"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_r_2(current_profit) =>
    is_valid = false, name = ""

    if (0.02 > current_profit and current_profit > 0.012 and r_480_5m > -4.0 and rsi_5m > 78 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_1"
    else if (0.03 > current_profit and current_profit > 0.02 and r_480_5m > -4.5 and rsi_5m > 78 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_2"
    else if (0.04 > current_profit and current_profit > 0.03 and r_480_5m > -5 and rsi_5m > 78 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_3"
    else if (0.05 > current_profit and current_profit > 0.04 and r_480_5m > -5.5 and rsi_5m > 78 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_4"
    else if (0.06 > current_profit and current_profit > 0.05 and r_480_5m > -6 and rsi_5m > 78 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_5"
    else if (0.07 > current_profit and current_profit > 0.06 and r_480_5m > -30.0 and rsi_5m > 79 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_6"
    else if (0.08 > current_profit and current_profit > 0.07 and r_480_5m > -34.0 and rsi_5m > 80 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_7"
    else if (0.09 > current_profit and current_profit > 0.08 and r_480_5m > -7.0 and rsi_5m > 80.5 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_8"
    else if (0.1 > current_profit and current_profit > 0.09 and r_480_5m > -6.0 and rsi_5m > 80.5 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_9"
    else if (0.12 > current_profit and current_profit > 0.1 and r_480_5m > -5.0 and rsi_5m > 80.5 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_10"
    else if (0.2 > current_profit and current_profit > 0.12 and r_480_5m > -4.0 and rsi_5m > 81 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_11"
    else if (current_profit > 0.2 and  r_480_5m > -3.0 and rsi_5m > 81.5 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_2_12"
    else
        is_valid := false, name := ""

    [is_valid, name]

sell_r_3(current_profit) => 
    is_valid = false, name = ""

    if (0.02 > current_profit and current_profit > 0.012 and r_480_5m > -6 and rsi_5m > 74 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_3_1"
    else if (0.03 > current_profit and current_profit > 0.02 and r_480_5m > -8 and rsi_5m > 74 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_3_2"
    else if (0.04 > current_profit and current_profit > 0.03 and r_480_5m > -29 and rsi_5m > 74 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_3_3"
    else if (0.05 > current_profit and current_profit > 0.04 and r_480_5m > -30 and rsi_5m > 74 and stochrsi_fastk_96 > 99 and stochrsi_fastd_96 > 99)
        is_valid := true, name := "signal_profit_w_3_4"
    else
        is_valid := false, name := ""

    [is_valid, name]

if (strategy.position_size > 0)
    current_profit = ((close - strategy.position_avg_price) / strategy.position_avg_price)

    wasLongEntry = strategy.position_size > 0 and strategy.position_size != strategy.position_size[1]
    barsFromLong = barssince(wasLongEntry)
    priorbars = barsFromLong != na ? (barsFromLong + 1) : 1
    highest_high = highest(priorbars)
    lowest_low = lowest(priorbars)

    max_profit = ((highest_high - strategy.position_avg_price) / strategy.position_avg_price)
    max_loss = ((strategy.position_avg_price - lowest_low) / lowest_low)

    [should_sell_01, signal_name_01] = sell_over_main(current_profit)
    [should_sell_02, signal_name_02] = sell_under_main(current_profit)
    [should_sell_03, signal_name_03] = sell_pump_main(current_profit)
    [should_sell_04, signal_name_04] = sell_dec_main(current_profit)
    [should_sell_05, signal_name_05] = sell_trail_main(current_profit, max_profit)
    [should_sell_06, signal_name_06] = sell_duration_main(current_profit, barsFromLong)
    [should_sell_07, signal_name_07] = sell_under_min(current_profit)
    [should_sell_08, signal_name_08] = sell_stoploss(current_profit, max_profit, max_loss, barsFromLong)
    [should_sell_09, signal_name_09] = sell_pump_dec(current_profit)
    [should_sell_10, signal_name_10] = sell_pump_extra(current_profit, max_profit)
    [should_sell_11, signal_name_11] = sell_recover(current_profit, max_loss)
    [should_sell_12, signal_name_12] = sell_r_1(current_profit)
    [should_sell_13, signal_name_13] = sell_r_2(current_profit)
    [should_sell_14, signal_name_14] = sell_r_3(current_profit)


    strategy.close(id="Long", comment=signal_name_01, when=should_sell_01)
    strategy.close(id="Long", comment=signal_name_02, when=should_sell_02)
    strategy.close(id="Long", comment=signal_name_03, when=should_sell_03)
    strategy.close(id="Long", comment=signal_name_04, when=should_sell_04)
    strategy.close(id="Long", comment=signal_name_05, when=should_sell_05)
    strategy.close(id="Long", comment=signal_name_06, when=should_sell_06)
    strategy.close(id="Long", comment=signal_name_07, when=should_sell_07)
    strategy.close(id="Long", comment=signal_name_08, when=should_sell_08)
    strategy.close(id="Long", comment=signal_name_09, when=should_sell_09)
    strategy.close(id="Long", comment=signal_name_10, when=should_sell_10)
    strategy.close(id="Long", comment=signal_name_11, when=should_sell_11)
    strategy.close(id="Long", comment=signal_name_12, when=should_sell_12)
    strategy.close(id="Long", comment=signal_name_13, when=should_sell_13)
    strategy.close(id="Long", comment=signal_name_14, when=should_sell_14)
    
    
    strategy.close(id="Long", comment="Exit", when=sell_01_logic)
    strategy.close(id="Long", comment="Exit", when=sell_02_logic)
    // strategy.close(id="Long", comment="Exit", when=sell_03_logic)
    strategy.close(id="Long", comment="Exit", when=sell_04_logic)
    strategy.close(id="Long", comment="Exit", when=sell_06_logic)
    strategy.close(id="Long", comment="Exit", when=sell_07_logic)
    strategy.close(id="Long", comment="Exit", when=sell_08_logic)

Overview

NFI v7.2 analyzes price action and exponential moving average metrics across both base and higher informative timeframes, incorporating reference data from a designated master pair like BTCUSDT. Strategy execution can be restricted to specific testing windows using an optional date range filter. The strategy plots directly on the main price chart. Note that default risk management parameters do not include an explicit stop loss.

Details

Published by

koradiyakaushal on GitHub

Code credit

kaushal, as written in the script's header

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Trend, Moving averages

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time
  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Informative Timeframetimeframe60informative_tf
Master PairsymbolBINANCE:BTCUSDT_master_pair
Has BTC BASE TF?booltruehas_BTC_base_tf
Has BTC Informative TF?booltruehas_BTC_info_tf
═════════════ Date Range FilteringboolfalseDateFilter
Start Timetimetimestamp("01 Jun 2021 00:00 +0000")i_startTime
End Timetimetimestamp("30 Dec 2021 23:30 +0000")i_endTime
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

HA UnivLong&Short Futures calculates Heikin Ashi candles and builds a channel using simple moving averages of Heikin Ashi highs and lows. It enters long positions when the upper channel line crosses above the lower channel line and opens short positions on the

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of HA UnivLong&Short Futures

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)

8 Whittle Down

by hasnocool
106 stars

This strategy executes short positions during the end-of-day session (14:29–15:00) when the price is below the 200-day simple moving average. If price moves higher against the initial short trade, it scales into the position by submitting a second short order

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 8 Whittle Down

EMA Ribbon MACD

by iamrichardD
57 stars

This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta

Strategy v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon MACD

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers