To start with, congratulations for the neat framework you have here came up with. Have been fiddling around since few weeks ago with it, and i am surprised with the simplicity of use, yet powerful abilities available.
Going to the subject under discussion, I would like to give it a go and try some implementation of different bars, initially with Heikin-Ashi and later on with Renko or Range bars.
The first question would be if you have any advice on where to plug the code for those bars? After looking into backtrader docs, i wonder if Filters are the right way to do it, after looking at it's description:
'Filters transform the values provided by a data feed to deliver a different data feed' ?
Or rather one shall just previously compute the bars and just add them as a regular datafeed to cerebro? Obviously this would loose later on the live trading ability and just be useful for backtesting purposes.
As for the issue with datetime stamping observations for price based bars, i don't see an issue there, as from my pov they shall have anyhow a time-stamp associated with the time they were started/per observation, therefore comparable with regular bars, just not with a regular interval. Apart from plotting which shall be non sense, the rest should work. Does this make any sense?
The de-facto Interactive Brokers uses the BID price as the reference for Forex, but you can track anything you want, including the MIDPOINT (which is obviously the middle point in between BID and ASK)
Just a matter of choosing (and leave open what to choose via parameters)
You can resample 1000 times in pandas if you wish, there is nothing against it. It will actually probably save you time (more if you save it to disk/database/something-else) and read it from there each time.
But you are simply not telling the platform to what you actually resampled to and therefore the default settings bt.TimeFrame.Days/1 are applied.
@Taewoo-Kim said in Animated Charting?:
If possible, go step by step (input() style wait) and look at trades and analysis incrementally
next will be called each time and provides therefore a framework for you to stop and look.
If you can write it down to disk, anything will be compatible.
If you are looking for live minute data with backfilling, the only other such source which is implemented is *[VisualChart][https://www.visualchart.com]. This has the drawback that it only runs under Windows and may be out of your area of influence.
Communication over COM has also small issues and data download may have to be restarted (COM is not one of the strongest aspects in Python)
The problem is:
How do you resample the code?
See the usual values:
open it is only taken 1 at the beginning of a resample cycle and never changed again until delivery
high and low are constanly updated if exceeded until delivery (max and min)
close is always updated until delivery
volume starts at 0 and is incremented with the incoming data
The platform cannot know what to do with an unknown value and therefore nothing is done. The given line doesn't exist for the resampler.
Implement a filter which is plugged into the resampled instance, looks into the original data feed and resamples code with your desired policy.
See: Docs - Filters
Hint: the resampled data instance contains a data attribute which points to the original non-resampled data instance.
Sorry just saw that you replied to this.
Actually I was more considering it in the live environment if/when the strategy graduates from back testing . It would be useful to be able to visually see what the strategy is doing for monitoring purposes and peace of mind of those who might use the strategy but have not developed it.
I understand we can already see buying and selling using the brokers own platform. However you can't see any custom indicators, support lines or other things we can plot on the backtested charts that might have caused the strategy to enter or exit a trade.
Glad it worked.
timeframe=1 seems anyhow odd because that is the actual value for bt.TimeFrame.Ticks and the data seems to be made up of 1-minute bars.
The platform will not complain (especially if no resampling is done), but you can see that later in a plot.
The suggestion would be to use: timeframe=bt.TimeFrame.Minutes (symbolic names seem better)