Use the link below to go the original post
Click here to see the full blog post
Curtis Miller last edited by
I'm sorry, but I can't not say it: Renko charts look adorable. The little bricks going up and down are just... so freakin' cute. I wouldn't mind hanging these things up on my wall or storing them in little books or making a quilt out of them.
Now that that's out of the way, I'm guessing that the Renko filter could be used as a data feed to build strategies so you can do backtests or compute statistics.
Would that be possible to have the renko block values in table instead of a plot? (I apologize if the answer is obvious as I'm a beginner with python)
It's not as difficult as it would seem
- Add a
Cerebroand the values of the data feed (your Renko bricks) will be printed as csv (i.e.: a table suitable for import in Excel for example)
See: Docs - Writer
- Add a
Thank you it works with this : cerebro.addwriter(bt.WriterFile,csv=True). That produces a csv table along with the cerebro stats at the end in the console. Does the backtrader package as a command to write only the data in a actual csv file or should I use another package like csv? Thanks again for helping a newbie.
If you look in the docs, you can pass an
out=xxxparameter to the call
cerebro.addwriter, which is described as:
out(default: sys.stdout): output stream to write to
If a string is passed a filename with the content of the parameter will be used
Pass the name of a file or an open file.
That works thank you. Although with the
FalseI can't remove the cerebro stats at the end of the file. I'll add some code to delete those lines because my goal is to add data to this csv file in real time and generate trading signals from it. Thanks again.
If you want to do it real-time you will then have to read the values from the data feed (
loware enough) and write them out yourself.
This is something you can easily do at the beginning of each
nextcycle before you do anything else
I'm having problems generating buy and sell signal after a certain amount of up or down renko ticks. I tried to couple those renko signals with 2 moving averages and 1 ADX indicators. The problem I face is I want those indicators to be run on the renko values and not the original data values. I had no luck so far to use 2 data feed, one to generate the renko and the other to run indicators on that first data feed.
The problem I face is I want those indicators to be run on the renko values and not the original data values
Emphasis on: "on the renko values"
I had no luck so far to use 2 data feed, one to generate the renko and the other to run indicators on that first data feed
Here you seem to do the opposite of what you said above (hence the emphasis, to make it clear), because you run the indicators "and the other to run indicators ..."
This may simply be that I misread your intentions.
The best thing would be a simple sample of what you try to achieve. It would really clarify things as to what's not working.
Sorry I wasn't clear at the end of the paragraph. I have a data file
.../dj.csvfor data feed
- I run the renko code above adding a buy order after 3 upticks and a sell order after 3 downticks
- Now I want those buy/sell signals to execute only if the third tick is above (for buy) or below (for sell) a simple moving average
- I don't know how to compute that simple moving average on the renko results instead of the
- I'm just a the pseudo code step for now and blocked on how to handle 2 data feeds
.../dj.csvand renko results for sma
The RSI in the
def __init__(self):just does that. I wrongly assumed the indicator was doing its math on the csv data source. I did the math ant it computes on the Renko output data. Basically, this question was on a wrong assumption.
Hi, I noticed that Renko adds 1 brick for each input candle. However i would like to add multiple bricks if the closing price differs by that much. I looked into making a custom renko filter and was able to change the closing price, but it gives bricks of uneven sizes. How can i generate multiple bricks of same size.
Hi, I noticed that Renko adds 1 brick for each input candle.
No. If they did, they wouldn't be Renko Bricks. The post clearly shows a comparison of the original data feed and the one with the Renko bricks which has less points across time.
However i would like to add multiple bricks if the closing price differs by that much
You probably need to elaborate a bit more, because that's exactly the definition of the Renko briks: add a brick if the closing price differs by that much (where that has to be defined by you and is provided as the
sizeparameter to the filter)
Renko adds a maximum of 1 brick for each input candle.
Lets say the brick size is 50 pips, and the next candle closes at a difference of 230. Currently "next" would generate 1 brick, I want to generate 4 bricks, to cover the difference of 200.
The problem is that the bricks need to be placed at a timestamp. At each timestamp you only have one output value for the lines of the data feed (in general these will be
In summary: you cannot therefore generate multiple bricks. Generating bricks of dissimilar sizes, what you apparently have already achieved, is your only possibility.
Chia-Yu Chien last edited by
I think it's possible to have 1 large bar to form multiple bricks but not with the implementation in backtrader's filter, you have to implement your own renko filter. every extra bricks need to have a small time offset, due to the precision, the smallest value is 10 microseconds which is small enough to use I think.