For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Renko Bricks


  • administrators

    Use the link below to go the original post

    Click here to see the full blog post



  • 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)


  • administrators

    It's not as difficult as it would seem

    • Add a Writer to your Cerebro and 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



  • 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.


  • administrators

    If you look in the docs, you can pass an out=xxx parameter 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 csv=True or False I 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.


  • administrators

    If you want to do it real-time you will then have to read the values from the data feed (high and low are enough) and write them out yourself.

    This is something you can easily do at the beginning of each next cycle 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.


  • administrators

    @rchausse said in Renko Bricks:

    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"

    @rchausse said in Renko Bricks:

    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.csv for data feed

    1. I run the renko code above adding a buy order after 3 upticks and a sell order after 3 downticks
    2. 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
    3. I don't know how to compute that simple moving average on the renko results instead of the .../dj.csv
    4. I'm just a the pseudo code step for now and blocked on how to handle 2 data feeds .../dj.csv and 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.