@backtrader said in Implement stop loss:
No, under buy_price, because your are talking about stop-loss (you are in the market), people will understand the price at which you bought your asset and not the expected (and yet unknown) price at which the next order, the stop-loss one will execute.
Got this. I've declared a new variable which is store buy_price and updates it in notify order method with order.executed.price.
@scottz1 said in My Orders dont get Closed (wrong implementation of SL/TP?):
Looks ok basically. However,
remember to add logic for partial fills so the tp/sl orders will have the correct size.
remember to check existing position so as not to overwrite self.order and end up doubling your position.
No, it cannot work for me, because that doesn't read from Yahoo. It tries
@Mario-Pellegrini said in float division by zero:
It is not a random code since you also say that the ticker works
It is random, because you apparently want to read from Yahoo and apply Quandl. The code has also nothing to do with the code from the homepage (3 snippets) that directly reads data from Yahoo.
Why don't you start from one of the scripts on the home page, change the ticker to FCA.MI and then slowly modify it? The link again for your reference
One of the latest additions lets you do direct time comparisons directly to lines to generate signals. Probably nobody has used it yet. An example:
lines = ('mysignal',)
self.lines.mysignal = self.data.datetime > datetime.time(10, 30)
This generates an indicator which can be used as a signal to only execute orders when the daily time goes over 10:30.
But since you are probably looking for day, you'll need to work it out in the next method comparing the self.data.datetime.date() (maybe even getting the weekday) against something of your choosing
@Harel-Rozental said in Smart optimizations and Backtrader:
I managed to get my optimizations to run as quick as optstrategy by subclassing Cerebro and pulling out some stuff out of run() and addstrategy() into different functions (one to initialize data loading, and another which gets re-executed from outside the class for optimization).
I also manage multiprocessing from the outside.
Do you mind to share some code? Or kind of a layout of what and where was implemented in more details?
@ab_trader - I am doing my best. I have already submitted pull requests for new Fisher Transform indicator and Simulated Order. And I am sharing all my code snippets here along with explanations whenever relevant.
When I say the framework should have this or that, I dont mean that someone should implement them but that we shall implement it for everybody's benefit.
i do like this, as suggested by @backtrader: I preprocess all my securities data including as an extra column their membership status. I do this while creating the survivorship bias free dataset.
In 'next' I look for it as it is another indicator. If True I trigger a EW target buy order otherwise a 0% target sell order.
@Laurent-Michelizza Thank you very much! when I log the position,I also find this question and use almost your way to solve it.
But in the future,I guess,we do a auto-close function when the future expires, it is more easy to use. After this four times reading the source code,I maybe try this function.
@ab_trader If I can use the fractal indicator to reference the true/false for any candle, like fractal[-14] to find out if 14 candles back was a high or low, then it will work, because I have to be able to get the high/low value from the fractal, not just knowing whether or not it is. I'll mess around with it, definitely looks cleaner than my method lol.