For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Noob question on plotting

  • Sorry for the basic question but I cant seem to figure this out.

    When I use cerebro.plot it plots just fine but it does so before my output shows the results of the backtest.

    How do i make it so that the chart populates after the output of the script is complete?

  • administrators

    That's due to the broker EOL buffering of Windows.

    If you are not running under IPython or similar (which hijack several things like multiprocessing and stdout without warning) environments, you can do the following

    import backtrader.utils.flushfile

    and each line of output will be flushed immediately.

  • You are a life saver. Thank you!

Log in to reply