Thanks for your response.
I am expecting that once a trade signal is generated in the def next() method, the next method to be called is def notify_order() followed by def notify_trade().
When an entry signal is generated in def next() this should result in an output of:
from the def notify_order() method followed by:
no log output from the def notify_trade() method.
Once an exit signal is generated in def next() the following outputs are expected:
CLOSING LONG POSITION
CLOSING SHORT POSITION
from def notify_order() followed by:
from the def notify_trade() method
I'm not getting this flow at all in the output.
The csv file is also showing strange results. At the beginning of the file, entries of the 2 symbols are happening on consecutive bars instead simultaneously and eventually only one symbol gets opened and not the second symbol.
I hope this provides you with enough information as to what I am hoping to resolve.
@YELNAr you use two different scripts in this post. One of them uses dataclose[-2] and one don't. Would you be so kind and post the script which causes the problem. But removed from that script all un-necessary parts.
The first thing for anyone to be able to offer any diagnostic is that people know what you are doing and what the error looks like. And the best approach to achieve that is to have a small code snippet, small data sample to reproduce the error.
@MuSaCN said in cerebro.plot() error!!!:
every is ok
That's your assumption. It may simply not be the case.
@Shubham-Puri said in Stock prediction using sentiment analysis error:
if date in date_sentiment:
self.sentiment = date_sentiment[date]
seems that date_sentiment is not defined in the Sentiment class. Also self.sentiment is not defined as well. At least in the code shown.
Top of the page
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
The backtrader code itself does not run in the shell and has no contact with it. It seems awkward to import get_ipython and to run cerebro.plot(ipython=False), because those seems to be related to be running inside a Jupyter Notebook or Spyder environment.
@jimmyliu @ThatBlokeDave @BernardLin @jf @Amien-Johaadien this may have been an addition since this thread was started - but using the a CommInfo object you can set mult to scale your profit/loss. In the FOREX sense, you can update your commission scheme during next with the relevant exchange rate in order to 'scale' your profits/losses back to your account currency.
Strategies DO NOT loop. They are passive and called by the system, i.e.: they are event based.
If something is wrong in your code ... it is in the code you don't show.
In any case ... all these if something is True tests are WRONG
@Joshua-Cheong said in Strategy runs with no end - is it looping?:
if self.view[d] is True:
You don't know if a True value is being stored. You want to test for something to be true and not for something to be True. Hence
here is a prototyped attempt to this - it has been tested live and does the job for my needs, but code clean up required.
it's a WIP and considering this is not "crucial for me", I cannot guarantee I ll work beyond that proto.
@Sasha consider using the replay datafeeds functionality of Backtrader. This allows you to make trading decisions on a lower timeframe while your higher level algorithm still operates on the higher timeframe. For instance, my system looks at indicators to make choices on the 1D candle, but my entries and exits are made on the 1H level. This way I can place a trade 1H before the close of the 1D candle and my trading results will be much more accurate.