Repository: freqtrade/freqtrade

Issue:
Freqtrade closes trade below candlestick low price
<!-- 
Have you searched for similar issues before posting it?

If you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). 
If it hasn't been reported, please create a new issue.

Please do not use bug reports to request new features.
-->

## Describe your environment

  * Operating system: Ubuntu 16.04
  * Python Version: 3.7.5
  * CCXT version: 1.57.3
  * Freqtrade Version: 2021.9
  
Note: All issues other than enhancement requests will be closed without further comment if the above template is deleted or not filled out.

## Describe the problem:

*Explain the problem you have encountered*

I created a simple strategy that works on the 5 min timeframe. With this strategy the bot buys when the RSI <= 25 and sells when the price closes at least 2% below the trailing stoploss. 

When I backtest the strategy I notice that the bot closes most of the trades after 0 minutes at a price that is below the candlestick low. Plotting the dataframe helped to visualize the issue. 

### Steps to reproduce:

  1. Run the backtest using Binance historical data: freqtrade backtesting --strategy RsiTestStrategy --timerange=20210121-20210122 -p CTK/USDT -c config_backtrader.json
  2. Check the first trade in the backtest log
  3. Plotting helps to visualize the issue: freqtrade plot-dataframe --strategy RsiTestStrategy -p CTK/USDT --timerange=20210121-20210122 --indicators2 rsi  --config config_backtrader.json
  
### Observed Results:

  * What happened?
       The bot opens a trade on the CTK/USDT pair the 21/Jan/2021 at 14:10 purchasing CTK at the price of 1.1754 USDT, setting a training stoploss at 1.151892. 

       Candle details:
        Open: 1.1754
        Close: 1.1586
        High: 1.2049
        Low: 1.1586

       After 0 minutes the bot triggers the stoploss and closes the position selling the trade at 1.151892 (Value below the candlestick low).   
 
       The same problem repeats for most of the trades 

  * What did you expect to happen?
     The bot shouldn't have closed the trade yet
      I'm not sure this is a bug, I probably messed up with the configuration. 
      
       Thanks for your help.

### Relevant code exceptions or logs

Note: Please copy/paste text of the messages, no screenshots of logs please.

  ```
  **The trade log:** 
{"pair":"CTK/USDT","stake_amount":    100.0,"amount":85.07742045,"open_date":"2021-01-21 14:10:00+00:00",
"close_date":"2021-01-21 14:10:00+00:00","open_rate":1.1754,"close_rate":1.151892,"fee_open":0.001,
"fee_close":0.001,"trade_duration":0,"profit_ratio":-0.02195804,"profit_abs":-2.198,
"sell_reason":"trailing_stop_loss","initial_stop_loss_abs":1.151892,"initial_stop_loss_ratio":-0.02,
"stop_loss_abs":1.1808020000000001,"stop_loss_ratio":-0.02,"min_rate":1.1586,"max_rate":1.2049,
"is_open":false,"buy_tag":null,"open_timestamp":1611238200000.0,"close_timestamp":1611238200000.0}
```

``` python
class RsiTestStrategy(IStrategy):
   
    INTERFACE_VERSION = 2

    minimal_roi = {
        "0": 100
    }

    stoploss = -0.02

    trailing_stop = True

    timeframe = '5m'

    process_only_new_candles = False

    use_sell_signal = True
    sell_profit_only = False
    ignore_roi_if_buy_signal = False

    startup_candle_count: int = 14

    order_types = {
        'buy': 'limit',
        'sell': 'limit',
        'stoploss': 'market',
        'stoploss_on_exchange': False
    }

    order_time_in_force = {
        'buy': 'gtc',
        'sell': 'gtc'
    }
    
    plot_config = {
        # Main plot indicators (Moving averages, ...)
        'main_plot': {
            'tema': {},
            'sar': {'color': 'white'},
        },
        'subplots': {
            # Subplots - each dict defines one additional plot
            # "MACD": {
            #     'macd': {'color': 'blue'},
            #     'macdsignal': {'color': 'orange'},
            # },
            "RSI": {
                'rsi': {'color': 'red'},
            }
        }
    }
    def informative_pairs(self):
        return []

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        # RSI
        dataframe['rsi'] = ta.RSI(dataframe)

        return dataframe

    def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
       
        dataframe.loc[
            (
                (dataframe['rsi'] <= 25) &  # Guard: tema below BB middle
                (dataframe['volume'] > 0)  # Make sure Volume is not 0
            ),
            'buy'] = 1

        return dataframe

    def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
       
        return dataframe
```

```
**The configuration I use:** 
{
    "max_open_trades": 10,
    "stake_currency": "USDT",
    "stake_amount": "unlimited",
    "available_capital":1000,
    "tradable_balance_ratio": 0.99,
    "fiat_display_currency": "USD",
    "timeframe": "5m",
    "dry_run": true,
    "cancel_open_orders_on_exit": false,
    "unfilledtimeout": {
        "buy": 10,
        "sell": 30,
        "unit": "minutes"
    },
    "bid_strategy": {
        "price_side": "bid",
        "ask_last_balance": 0.0,
        "use_order_book": true,
        "order_book_top": 1,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "ask_strategy": {
        "price_side": "ask",
        "use_order_book": true,
        "order_book_top": 1
    },
    "exchange": {
        "name": "binance",
        "key": "",
        "secret": "",
        "skip_pair_validation": true,
        "ccxt_config": {"enableRateLimit": true},
        "ccxt_async_config": {
            "enableRateLimit": true,
            "rateLimit": 200
        },
        "pair_whitelist": [
            ".*/USDT" 
        ],
        "pair_blacklist": [
            "BNB/.*",
            "BUSD/.*",
            "USDC/.*",
            "EUR/.*",
            ".*UP/.*",
            ".*BULL/.*",
            ".*DOWN/.*",
            ".*BEAR/.*",
            "TUSD/.*",
            "USDT/.*",
            "USDP/.*",
            "LAZIO/.*",
            "JUV/.*",
            "FIO/.*",
            "BAR/.*",
            "ACM/.*",
            "PSG/.*",
            "ATM/.*"
        ]
    },
    "pairlists": [
        {
            "method": "StaticPairList",
            "allow_inactive": true
        }
    ],
    "edge": {
        "enabled": false,
        "process_throttle_secs": 3600,
        "calculate_since_number_of_days": 7,
        "allowed_risk": 0.01,
        "stoploss_range_min": -0.01,
        "stoploss_range_max": -0.1,
        "stoploss_range_step": -0.01,
        "minimum_winrate": 0.60,
        "minimum_expectancy": 0.20,
        "min_trade_number": 10,
        "max_trade_duration_minute": 1440,
        "remove_pumps": false
    },
    "telegram": {
        "enabled": false,
        "token": "",
        "chat_id": ""
    },
    "bot_name": "freqtrade",
    "initial_state": "running",
    "forcebuy_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}

```

![error2](https://user-images.githubusercontent.com/65393791/139533104-0c0d203f-4287-408a-ac03-525b9a38bb2b.png)
2
Freqtrade closes trade below candlestick low price
<!-- 
Have you searched for similar issues before posting it?

If you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). 
If it hasn't been reported, please create a new issue.

Please do not use bug reports to request new features.
-->

## Describe your environment

  * Operating system: Ubuntu 16.04
  * Python Version: 3.7.5
  * CCXT version: 1.57.3
  * Freqtrade Version: 2021.9
  
Note: All issues other than enhancement requests will be closed without further comment if the above template is deleted or not filled out.

## Describe the problem:

*Explain the problem you have encountered*

I created a simple strategy that works on the 5 min timeframe. With this strategy the bot buys when the RSI <= 25 and sells when the price closes at least 2% below the trailing stoploss. 

When I backtest the strategy I notice that the bot closes most of the trades after 0 minutes at a price that is below the candlestick low. Plotting the dataframe helped to visualize the issue. 

### Steps to reproduce:

  1. Run the backtest using Binance historical data: freqtrade backtesting --strategy RsiTestStrategy --timerange=20210121-20210122 -p CTK/USDT -c config_backtrader.json
  2. Check the first trade in the backtest log
  3. Plotting helps to visualize the issue: freqtrade plot-dataframe --strategy RsiTestStrategy -p CTK/USDT --timerange=20210121-20210122 --indicators2 rsi  --config config_backtrader.json
  
### Observed Results:

  * What happened?
       The bot opens a trade on the CTK/USDT pair the 21/Jan/2021 at 14:10 purchasing CTK at the price of 1.1754 USDT, setting a training stoploss at 1.151892. 

       Candle details:
        Open: 1.1754
        Close: 1.1586
        High: 1.2049
        Low: 1.1586

       After 0 minutes the bot triggers the stoploss and closes the position selling the trade at 1.151892 (Value below the candlestick low).   
 
       The same problem repeats for most of the trades 

  * What did you expect to happen?
     The bot shouldn't have closed the trade yet
      I'm not sure this is a bug, I probably messed up with the configuration. 
      
       Thanks for your help.

### Relevant code exceptions or logs

Note: Please copy/paste text of the messages, no screenshots of logs please.

  ```
  **The trade log:** 
{"pair":"CTK/USDT","stake_amount":    100.0,"amount":85.07742045,"open_date":"2021-01-21 14:10:00+00:00",
"close_date":"2021-01-21 14:10:00+00:00","open_rate":1.1754,"close_rate":1.151892,"fee_open":0.001,
"fee_close":0.001,"trade_duration":0,"profit_ratio":-0.02195804,"profit_abs":-2.198,
"sell_reason":"trailing_stop_loss","initial_stop_loss_abs":1.151892,"initial_stop_loss_ratio":-0.02,
"stop_loss_abs":1.1808020000000001,"stop_loss_ratio":-0.02,"min_rate":1.1586,"max_rate":1.2049,
"is_open":false,"buy_tag":null,"open_timestamp":1611238200000.0,"close_timestamp":1611238200000.0}
```

``` python
class RsiTestStrategy(IStrategy):
   
    INTERFACE_VERSION = 2

    minimal_roi = {
        "0": 100
    }

    stoploss = -0.02

    trailing_stop = True

    timeframe = '5m'

    process_only_new_candles = False

    use_sell_signal = True
    sell_profit_only = False
    ignore_roi_if_buy_signal = False

    startup_candle_count: int = 14

    order_types = {
        'buy': 'limit',
        'sell': 'limit',
        'stoploss': 'market',
        'stoploss_on_exchange': False
    }

    order_time_in_force = {
        'buy': 'gtc',
        'sell': 'gtc'
    }
    
    plot_config = {
        # Main plot indicators (Moving averages, ...)
        'main_plot': {
            'tema': {},
            'sar': {'color': 'white'},
        },
        'subplots': {
            # Subplots - each dict defines one additional plot
            # "MACD": {
            #     'macd': {'color': 'blue'},
            #     'macdsignal': {'color': 'orange'},
            # },
            "RSI": {
                'rsi': {'color': 'red'},
            }
        }
    }
    def informative_pairs(self):
        return []

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        # RSI
        dataframe['rsi'] = ta.RSI(dataframe)

        return dataframe

    def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
       
        dataframe.loc[
            (
                (dataframe['rsi'] <= 25) &  # Guard: tema below BB middle
                (dataframe['volume'] > 0)  # Make sure Volume is not 0
            ),
            'buy'] = 1

        return dataframe

    def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
       
        return dataframe
```

```
**The configuration I use:** 
{
    "max_open_trades": 10,
    "stake_currency": "USDT",
    "stake_amount": "unlimited",
    "available_capital":1000,
    "tradable_balance_ratio": 0.99,
    "fiat_display_currency": "USD",
    "timeframe": "5m",
    "dry_run": true,
    "cancel_open_orders_on_exit": false,
    "unfilledtimeout": {
        "buy": 10,
        "sell": 30,
        "unit": "minutes"
    },
    "bid_strategy": {
        "price_side": "bid",
        "ask_last_balance": 0.0,
        "use_order_book": true,
        "order_book_top": 1,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "ask_strategy": {
        "price_side": "ask",
        "use_order_book": true,
        "order_book_top": 1
    },
    "exchange": {
        "name": "binance",
        "key": "",
        "secret": "",
        "skip_pair_validation": true,
        "ccxt_config": {"enableRateLimit": true},
        "ccxt_async_config": {
            "enableRateLimit": true,
            "rateLimit": 200
        },
        "pair_whitelist": [
            ".*/USDT" 
        ],
        "pair_blacklist": [
            "BNB/.*",
            "BUSD/.*",
            "USDC/.*",
            "EUR/.*",
            ".*UP/.*",
            ".*BULL/.*",
            ".*DOWN/.*",
            ".*BEAR/.*",
            "TUSD/.*",
            "USDT/.*",
            "USDP/.*",
            "LAZIO/.*",
            "JUV/.*",
            "FIO/.*",
            "BAR/.*",
            "ACM/.*",
            "PSG/.*",
            "ATM/.*"
        ]
    },
    "pairlists": [
        {
            "method": "StaticPairList",
            "allow_inactive": true
        }
    ],
    "edge": {
        "enabled": false,
        "process_throttle_secs": 3600,
        "calculate_since_number_of_days": 7,
        "allowed_risk": 0.01,
        "stoploss_range_min": -0.01,
        "stoploss_range_max": -0.1,
        "stoploss_range_step": -0.01,
        "minimum_winrate": 0.60,
        "minimum_expectancy": 0.20,
        "min_trade_number": 10,
        "max_trade_duration_minute": 1440,
        "remove_pumps": false
    },
    "telegram": {
        "enabled": false,
        "token": "",
        "chat_id": ""
    },
    "bot_name": "freqtrade",
    "initial_state": "running",
    "forcebuy_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}

```

![error2](https://user-images.githubusercontent.com/65393791/139533104-0c0d203f-4287-408a-ac03-525b9a38bb2b.png)
2


Discussion:
![Error_plot](https://user-images.githubusercontent.com/65393791/139533135-f9f05a7e-8a22-4c3e-b337-1830e896956c.png)

![Error_plot](https://user-images.githubusercontent.com/65393791/139533135-f9f05a7e-8a22-4c3e-b337-1830e896956c.png)


Resolving patch:
diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py
--- a/freqtrade/optimize/backtesting.py
+++ b/freqtrade/optimize/backtesting.py
@@ -312,7 +312,9 @@ def _get_close_rate(self, sell_row: Tuple, trade: LocalTrade, sell: SellCheckTup
                     # Worst case: price ticks tiny bit above open and dives down.
                     stop_rate = sell_row[OPEN_IDX] * (1 - abs(trade.stop_loss_pct))
                     assert stop_rate < sell_row[HIGH_IDX]
-                return stop_rate
+                # Limit lower-end to candle low to avoid sells below the low.
+                # This still remains "worst case" - but "worst realistic case".
+                return max(sell_row[LOW_IDX], stop_rate)
 
             # Set close_rate to stoploss
             return trade.stop_loss


Test patch:
diff --git a/tests/optimize/__init__.py b/tests/optimize/__init__.py
--- a/tests/optimize/__init__.py
+++ b/tests/optimize/__init__.py
@@ -54,4 +54,10 @@ def _build_backtest_dataframe(data):
         frame[column] = frame[column].astype('float64')
     if 'buy_tag' not in columns:
         frame['buy_tag'] = None
+
+    # Ensure all candles make kindof sense
+    assert all(frame['low'] <= frame['close'])
+    assert all(frame['low'] <= frame['open'])
+    assert all(frame['high'] >= frame['close'])
+    assert all(frame['high'] >= frame['open'])
     return frame
diff --git a/tests/optimize/test_backtest_detail.py b/tests/optimize/test_backtest_detail.py
--- a/tests/optimize/test_backtest_detail.py
+++ b/tests/optimize/test_backtest_detail.py
@@ -17,10 +17,10 @@
     # D  O     H     L     C     V    B  S
     [0, 5000, 5025, 4975, 4987, 6172, 1, 0],
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
-    [2, 4987, 5012, 4986, 4600, 6172, 0, 0],  # exit with stoploss hit
-    [3, 5010, 5000, 4980, 5010, 6172, 0, 1],
-    [4, 5010, 4987, 4977, 4995, 6172, 0, 0],
-    [5, 4995, 4995, 4995, 4950, 6172, 0, 0]],
+    [2, 4987, 5012, 4986, 4986, 6172, 0, 0],  # exit with stoploss hit
+    [3, 5010, 5010, 4980, 5010, 6172, 0, 1],
+    [4, 5010, 5011, 4977, 4995, 6172, 0, 0],
+    [5, 4995, 4995, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.01, roi={"0": 1}, profit_perc=0.002, use_sell_signal=True,
     trades=[BTrade(sell_reason=SellType.SELL_SIGNAL, open_tick=1, close_tick=4)]
 )
@@ -32,9 +32,9 @@
     [0, 5000, 5025, 4975, 4987, 6172, 1, 0],
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
     [2, 4987, 5012, 4600, 4600, 6172, 0, 0],  # exit with stoploss hit
-    [3, 4975, 5000, 4980, 4977, 6172, 0, 0],
-    [4, 4977, 4987, 4977, 4995, 6172, 0, 0],
-    [5, 4995, 4995, 4995, 4950, 6172, 0, 0]],
+    [3, 4975, 5000, 4975, 4977, 6172, 0, 0],
+    [4, 4977, 4995, 4977, 4995, 6172, 0, 0],
+    [5, 4995, 4995, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.01, roi={"0": 1}, profit_perc=-0.01,
     trades=[BTrade(sell_reason=SellType.STOP_LOSS, open_tick=1, close_tick=2)]
 )
@@ -69,7 +69,7 @@
     [3, 4975, 5000, 4950, 4962, 6172, 1, 0],
     [4, 4975, 5000, 4950, 4962, 6172, 0, 0],  # enter trade 2 (signal on last candle)
     [5, 4962, 4987, 4000, 4000, 6172, 0, 0],  # exit with stoploss hit
-    [6, 4950, 4975, 4975, 4950, 6172, 0, 0]],
+    [6, 4950, 4975, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.02, roi={"0": 1}, profit_perc=-0.04,
     trades=[BTrade(sell_reason=SellType.STOP_LOSS, open_tick=1, close_tick=2),
             BTrade(sell_reason=SellType.STOP_LOSS, open_tick=4, close_tick=5)]
@@ -99,7 +99,7 @@
     [1, 5000, 5025, 4980, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
     [2, 4987, 5025, 4975, 4987, 6172, 0, 0],
     [3, 4975, 6000, 4975, 6000, 6172, 0, 0],  # ROI
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
+    [4, 4962, 4987, 4962, 4972, 6172, 0, 0],
     [5, 4950, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.01, roi={"0": 0.03}, profit_perc=0.03,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
@@ -113,7 +113,7 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
     [2, 4987, 5300, 4850, 5050, 6172, 0, 0],  # Exit with stoploss
     [3, 4975, 5000, 4950, 4962, 6172, 0, 0],
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
     [5, 4950, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.02, roi={"0": 0.05}, profit_perc=-0.02,
     trades=[BTrade(sell_reason=SellType.STOP_LOSS, open_tick=1, close_tick=2)]
@@ -127,7 +127,7 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],
     [2, 4987, 5300, 4950, 5050, 6172, 0, 0],
     [3, 4975, 5000, 4950, 4962, 6172, 0, 0],
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
     [5, 4950, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.02, roi={"0": 0.03}, profit_perc=0.03,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=2)]
@@ -167,7 +167,7 @@
 tc10 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 5100, 5100, 6172, 0, 0],
     [3, 4850, 5050, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -183,7 +183,7 @@
 tc11 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 5100, 5100, 6172, 0, 0],
     [3, 5000, 5150, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -199,7 +199,7 @@
 tc12 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 4650, 5100, 6172, 0, 0],
     [3, 4850, 5050, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -216,8 +216,8 @@
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
     [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 4850, 5100, 6172, 0, 0],
-    [3, 4850, 5050, 4850, 4750, 6172, 0, 0],
-    [4, 4750, 4950, 4850, 4750, 6172, 0, 0]],
+    [3, 4850, 5050, 4750, 4750, 6172, 0, 0],
+    [4, 4750, 4950, 4750, 4750, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.01}, profit_perc=0.01,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=1)]
 )
@@ -229,7 +229,7 @@
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
     [1, 5000, 5100, 4600, 5100, 6172, 0, 0],
     [2, 5100, 5251, 4850, 5100, 6172, 0, 0],
-    [3, 4850, 5050, 4850, 4750, 6172, 0, 0],
+    [3, 4850, 5050, 4750, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
     stop_loss=-0.05, roi={"0": 0.10}, profit_perc=-0.05,
     trades=[BTrade(sell_reason=SellType.STOP_LOSS, open_tick=1, close_tick=1)]
@@ -243,7 +243,7 @@
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
     [1, 5000, 5100, 4900, 5100, 6172, 1, 0],
     [2, 5100, 5251, 4650, 5100, 6172, 0, 0],
-    [3, 4850, 5050, 4850, 4750, 6172, 0, 0],
+    [3, 4850, 5050, 4750, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
     stop_loss=-0.05, roi={"0": 0.01}, profit_perc=-0.04,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=1),
@@ -259,7 +259,7 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],
     [2, 4987, 5300, 4950, 5050, 6172, 0, 0],
     [3, 4975, 5000, 4940, 4962, 6172, 0, 0],  # ForceSell on ROI (roi=-1)
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
     [5, 4950, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.10, "65": -1}, profit_perc=-0.012,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
@@ -275,7 +275,7 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],
     [2, 4987, 5300, 4950, 5050, 6172, 0, 0],
     [3, 4980, 5000, 4940, 4962, 6172, 0, 0],  # ForceSell on ROI (roi=-1)
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
     [5, 4950, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.10, "120": -1}, profit_perc=-0.004,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
@@ -291,7 +291,7 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],
     [2, 4987, 5300, 4950, 5200, 6172, 0, 0],
     [3, 5200, 5220, 4940, 4962, 6172, 0, 0],  # Sell on ROI (sells on open)
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
     [5, 4950, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.10, "120": 0.01}, profit_perc=0.04,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
@@ -306,8 +306,8 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],
     [2, 4987, 5300, 4950, 5200, 6172, 0, 0],
     [3, 5000, 5300, 4940, 4962, 6172, 0, 0],  # Sell on ROI
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
-    [5, 4550, 4975, 4925, 4950, 6172, 0, 0]],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
+    [5, 4550, 4975, 4550, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.10, "120": 0.01}, profit_perc=0.01,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
 )
@@ -321,8 +321,8 @@
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],
     [2, 4987, 5300, 4950, 5200, 6172, 0, 0],
     [3, 5200, 5300, 4940, 4962, 6172, 0, 0],  # Sell on ROI
-    [4, 4962, 4987, 4972, 4950, 6172, 0, 0],
-    [5, 4550, 4975, 4925, 4950, 6172, 0, 0]],
+    [4, 4962, 4987, 4950, 4950, 6172, 0, 0],
+    [5, 4925, 4975, 4925, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.10, "119": 0.01}, profit_perc=0.01,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
 )
@@ -334,7 +334,7 @@
 tc21 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 4650, 5100, 6172, 0, 0],
     [3, 4850, 5050, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -350,7 +350,7 @@
 tc22 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 5100, 5100, 6172, 0, 0],
     [3, 4850, 5050, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -369,7 +369,7 @@
 tc23 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 5100, 5100, 6172, 0, 0],
     [3, 4850, 5251, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -386,10 +386,10 @@
     # D  O     H     L     C     V    B  S
     [0, 5000, 5025, 4975, 4987, 6172, 1, 0],
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
-    [2, 4987, 5012, 4986, 4600, 6172, 0, 0],
-    [3, 5010, 5000, 4855, 5010, 6172, 0, 1],  # Triggers stoploss + sellsignal
-    [4, 5010, 4987, 4977, 4995, 6172, 0, 0],
-    [5, 4995, 4995, 4995, 4950, 6172, 0, 0]],
+    [2, 4987, 5012, 4986, 4986, 6172, 0, 0],
+    [3, 5010, 5010, 4855, 5010, 6172, 0, 1],  # Triggers stoploss + sellsignal
+    [4, 5010, 5010, 4977, 4995, 6172, 0, 0],
+    [5, 4995, 4995, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.01, roi={"0": 1}, profit_perc=-0.01, use_sell_signal=True,
     trades=[BTrade(sell_reason=SellType.STOP_LOSS, open_tick=1, close_tick=3)]
 )
@@ -401,10 +401,10 @@
     # D  O     H     L     C     V    B  S
     [0, 5000, 5025, 4975, 4987, 6172, 1, 0],
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
-    [2, 4987, 5012, 4986, 4600, 6172, 0, 0],
-    [3, 5010, 5000, 4986, 5010, 6172, 0, 1],
-    [4, 5010, 4987, 4855, 4995, 6172, 0, 0],  # Triggers stoploss + sellsignal acted on
-    [5, 4995, 4995, 4995, 4950, 6172, 0, 0]],
+    [2, 4987, 5012, 4986, 4986, 6172, 0, 0],
+    [3, 5010, 5010, 4986, 5010, 6172, 0, 1],
+    [4, 5010, 5010, 4855, 4995, 6172, 0, 0],  # Triggers stoploss + sellsignal acted on
+    [5, 4995, 4995, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.01, roi={"0": 1}, profit_perc=0.002, use_sell_signal=True,
     trades=[BTrade(sell_reason=SellType.SELL_SIGNAL, open_tick=1, close_tick=4)]
 )
@@ -416,10 +416,10 @@
     # D  O     H     L     C     V    B  S
     [0, 5000, 5025, 4975, 4987, 6172, 1, 0],
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
-    [2, 4987, 5012, 4986, 4600, 6172, 0, 0],
+    [2, 4987, 5012, 4986, 4986, 6172, 0, 0],
     [3, 5010, 5251, 4986, 5010, 6172, 0, 1],  # Triggers ROI, sell-signal
-    [4, 5010, 4987, 4855, 4995, 6172, 0, 0],
-    [5, 4995, 4995, 4995, 4950, 6172, 0, 0]],
+    [4, 5010, 5010, 4855, 4995, 6172, 0, 0],
+    [5, 4995, 4995, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.05}, profit_perc=0.05, use_sell_signal=True,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=3)]
 )
@@ -432,10 +432,10 @@
     # D  O     H     L     C     V    B  S
     [0, 5000, 5025, 4975, 4987, 6172, 1, 0],
     [1, 5000, 5025, 4975, 4987, 6172, 0, 0],  # enter trade (signal on last candle)
-    [2, 4987, 5012, 4986, 4600, 6172, 0, 0],
+    [2, 4987, 5012, 4986, 4986, 6172, 0, 0],
     [3, 5010, 5012, 4986, 5010, 6172, 0, 1],  # sell-signal
     [4, 5010, 5251, 4855, 4995, 6172, 0, 0],  # Triggers ROI, sell-signal acted on
-    [5, 4995, 4995, 4995, 4950, 6172, 0, 0]],
+    [5, 4995, 4995, 4950, 4950, 6172, 0, 0]],
     stop_loss=-0.10, roi={"0": 0.05}, profit_perc=0.05, use_sell_signal=True,
     trades=[BTrade(sell_reason=SellType.ROI, open_tick=1, close_tick=4)]
 )
@@ -447,7 +447,7 @@
 tc28 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 4950, 5100, 6172, 0, 0],
+    [1, 5000, 5100, 4950, 5100, 6172, 0, 0],
     [2, 5100, 5251, 5100, 5100, 6172, 0, 0],
     [3, 4850, 5050, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -463,7 +463,7 @@
 tc29 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5050, 5000, 4900, 6172, 0, 0],    # enter trade (signal on last candle)
+    [1, 5000, 5050, 5000, 5000, 6172, 0, 0],    # enter trade (signal on last candle)
     [2, 4900, 5250, 4500, 5100, 6172, 0, 0],    # Triggers trailing-stoploss
     [3, 5100, 5100, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -477,7 +477,7 @@
 tc30 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5500, 5000, 4900, 6172, 0, 0],    # enter trade (signal on last candle) and stop
+    [1, 5000, 5500, 4900, 4900, 6172, 0, 0],    # enter trade (signal on last candle) and stop
     [2, 4900, 5250, 4500, 5100, 6172, 0, 0],
     [3, 5100, 5100, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -491,7 +491,7 @@
 tc31 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5500, 5000, 4900, 6172, 0, 0],    # enter trade (signal on last candle) and stop
+    [1, 5000, 5500, 4900, 4900, 6172, 0, 0],    # enter trade (signal on last candle) and stop
     [2, 4900, 5250, 4500, 5100, 6172, 0, 0],
     [3, 5100, 5100, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -506,7 +506,7 @@
 tc32 = BTContainer(data=[
     # D   O     H     L     C    V    B  S
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0],
-    [1, 5000, 5500, 5000, 4900, 6172, 0, 0],    # enter trade (signal on last candle) and stop
+    [1, 5000, 5500, 4951, 5000, 6172, 0, 0],    # enter trade (signal on last candle) and stop
     [2, 4900, 5250, 4500, 5100, 6172, 0, 0],
     [3, 5100, 5100, 4650, 4750, 6172, 0, 0],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0]],
@@ -521,7 +521,7 @@
 tc33 = BTContainer(data=[
     # D   O     H     L     C    V    B  S   BT
     [0, 5000, 5050, 4950, 5000, 6172, 1, 0, 'buy_signal_01'],
-    [1, 5000, 5500, 5000, 4900, 6172, 0, 0, None],    # enter trade (signal on last candle) and stop
+    [1, 5000, 5500, 4951, 5000, 6172, 0, 0, None],    # enter trade (signal on last candle) and stop
     [2, 4900, 5250, 4500, 5100, 6172, 0, 0, None],
     [3, 5100, 5100, 4650, 4750, 6172, 0, 0, None],
     [4, 4750, 4950, 4350, 4750, 6172, 0, 0, None]],