@eric said in Help with plotting issue:
lines = ('datetime', 'open', 'high', 'low', 'close', 'volume',)
You are adding this lines to the existing lines in PandasData possible overriding them with the wrong order (I couldn't tell, it never occurred to me to repeat the same lines declaration overriding the existing lines)
You only need to define the parameters to given them fixed known (to you) values and only new lines.
One is telling you the leverage that will be applied to an asset when acquiring it.
The other is telling you the actual leverage of your account, which is obviously 1 if nothing has been bought.
It's in the topic you link to:
@backtrader said in get_leverage() calls:
@ThatBlokeDave said in get_leverage() calls:
However, self.broker.get_leverage() appears to be doing a different calculation
It's not a different calculation. It's different altogether. Invoking that method, which is intended for user consumption unlike the one above, reports the actual leverage level in the market.
@backtrader said in Convincing strategy to buy at close of current bar in backtest:
The observer in charge of plotting only sees the notification in the next cycle.
Check the order.executed.dt field and you will see the order was properly executed on the right bar (even if the observer doesn't know it)
@ab_trader said in Convincing strategy to buy at close of current bar in backtest:
The order is executed as required, it is just the plotting and it confuses a bit. I know the plotting is not the main goal of the backtrader, but sometimes visual check of the signals/executions is really helpful.
Hi. I faced the same issue. Does anybody know how to force the plotting to draw sell/buy signals in right place (with cheat-on-close mode enabled) ?
There is no "next simplest" thing.
Docs - Plotting - Section Plotted Elements
You either plot a data feed, an indicator or an observer and they all happen to be classes.
backtrader is a framework which is completely OO-based/oriented.
@backtrader said in bt for low-frequency / trend following trading:
You don't have any other approach if you want to operate before the close. You need to have the price updated before you operate.
Ok, and how can I get it? Alpaca live account isn't allowed for me. What API with paper-trading abilities should I use ?
I think you are confused in general. backtrader doesn't work with that notation. It uses the pivot point 0 as the current moment of time and negative indices point to the last (hence "past") values.
If you want to get a complete array of past values, you will get a standard Python array. - Docs - Platform Concepts