Repository: freqtrade/freqtrade

Issue:
Plotting dataframe when using DataProvider
<!-- 
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 18.04
  * Python Version: 3.6.9
  * CCXT version: 1.30.48
  * Freqtrade Version: develop
  
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:

*I'm trying to use "plot-dataframe" to visualize the result of my strategy which is using data from several time frame (4H, 1D, 1W) using the data provider. Unfortunately when trying to plot the following error occurs : *

### Steps to reproduce:

`freqtrade plot-dataframe -p LINK/BTC -s EMAHL`
  
### Observed Results:

```
in populate_indicators daily = self.super_trend(self.dp.get_pair_dataframe(metadata['pair'], timeframe='1D'))`
AttributeError : 'NoneType' object has no attribute 'get_pair_dataframe'`
```

### Relevant code exceptions or logs

  ```
in populate_indicators daily = self.super_trend(self.dp.get_pair_dataframe(metadata['pair'], timeframe='1D'))`
AttributeError : 'NoneType' object has no attribute 'get_pair_dataframe'`
  ```



Discussion:
All examples we have in the [documentation](https://www.freqtrade.io/en/latest/strategy-customization/#get_pair_dataframepair-timeframe) show that before using DP, you should check it exists (via `if self.dp:` ). 
That will avoid this error.

Now for the problem itself - yes, dataprovider is not supported in plotting mode, we should add this to the documentation as well.


Resolving patch:
diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py
--- a/freqtrade/plot/plotting.py
+++ b/freqtrade/plot/plotting.py
@@ -10,11 +10,13 @@
                                        create_cum_profit,
                                        extract_trades_of_period, load_trades)
 from freqtrade.data.converter import trim_dataframe
+from freqtrade.data.dataprovider import DataProvider
 from freqtrade.data.history import load_data
 from freqtrade.exceptions import OperationalException
 from freqtrade.exchange import timeframe_to_prev_date
 from freqtrade.misc import pair_to_filename
-from freqtrade.resolvers import StrategyResolver
+from freqtrade.resolvers import ExchangeResolver, StrategyResolver
+from freqtrade.strategy import IStrategy
 
 logger = logging.getLogger(__name__)
 
@@ -467,6 +469,8 @@ def load_and_plot_trades(config: Dict[str, Any]):
     """
     strategy = StrategyResolver.load_strategy(config)
 
+    exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config)
+    IStrategy.dp = DataProvider(config, exchange)
     plot_elements = init_plotscript(config)
     trades = plot_elements['trades']
     pair_counter = 0


Test patch:
diff --git a/tests/test_plotting.py b/tests/test_plotting.py
--- a/tests/test_plotting.py
+++ b/tests/test_plotting.py
@@ -21,7 +21,7 @@
                                      load_and_plot_trades, plot_profit,
                                      plot_trades, store_plot_file)
 from freqtrade.resolvers import StrategyResolver
-from tests.conftest import get_args, log_has, log_has_re
+from tests.conftest import get_args, log_has, log_has_re, patch_exchange
 
 
 def fig_generating_mock(fig, *args, **kwargs):
@@ -316,6 +316,8 @@ def test_start_plot_dataframe(mocker):
 
 
 def test_load_and_plot_trades(default_conf, mocker, caplog, testdatadir):
+    patch_exchange(mocker)
+
     default_conf['trade_source'] = 'file'
     default_conf["datadir"] = testdatadir
     default_conf['exportfilename'] = testdatadir / "backtest-result_test.json"