• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Quality Renko Backtesting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Quality Renko Backtesting

    I am currently working on an EA that uses Renko bars. Before I wrote the first line of code I read half a dozen different threads about how you can't backtest on Renko charts. I partially understand why it doesn't work, and was able to simulate it myself. If I entered a trade and was immediately stopped out, I would end up profiting because of how it's using the Renko's bars for market orders.

    I believe I fixed the issue by adding the Renko as an extra series. The primary chart is a normal chart using tick data. My strategy involves entering/exiting trades when the Renko bars cross above/below various indicators. Because I don't want to use Renko for market orders, but just as an indicator, I use "BarsInProgress() == 1" to check for my entry condition, and if there is an entry condition, I set a class level boolean and wait for "BarsInProgress() == 0" and then call EnterLong() or EnterShort(). If I set my orders from the Renko BarsInProgress I get a profit factor of 4, if I run the same EA but use the primary BarsInProgress(), I get a profit factor of 0.25. That would tell me I am approaching the issue correctly and perhaps have solved the problem of backtesting Renko charts, but making market orders off of the actual current tick prices.

    Does this sound correct? Also am I missing anything else when using the Renko charts as an indicator? For example if I check if Renko is above/below an EMA, can that be trusted?

    Thanks.

    #2
    Ok, I take all of that back. Just ignore my first post. I think I am more confused now than when I started. This is how I have everything set up right now to test what is wrong: My primary chart is Renko, brick size 100, and 1 tick data as my secondary. The strategy watches if a Renko bar closes above or below a certain EMA, and then either enterlong() or entershort(), and the market order is placed on the secondary 1 tick data series. Doing that should get me in the trade on the granular tick data and avoid any of the Renko shenanigans. Just for testing I set up a trailing stop of 1 pip to force any open orders to immediately close, which should cause the strategy to lose a lot of money. The problem is when I do that the strategy results end up with a profit factor of 4.5. Which really makes no sense.

    If I am reading these other posts correctly, NT is saying to resolve the issue you need to add a second series for granularity and then make orders on that series. That should result in trade signals coming from the Renko primary series, but market orders being taken from the granular secondary series. I believe that is what I am doing but the results are reflecting that I am doing something wrong.

    Please help me understand what I am missing here.

    Comment


      #3
      Just a little more info for anyone interested in helping me out. When I set a trailing stop of 1 pip I end up with the 4.5 pf, when I set a stoploss of 1 pip I get a 0.95(which seems like the value I would expect if it was working). Why does a trailing stop of 1 pip have such a vastly different result of a normal stop of 1 pip.

      Comment


        #4
        Just for giggles I decided to code my own trailing stop using the granular bars, rather than use the NT trailingstop(), since i believe the built in TS wants to use the Renko bars. After writing my own TS, the strategy should be entering and exiting off the granular series, which should give me closest to realistic behavior. Well... after writing my own quick trail stop and using a trailing stop of 1 pip my PF is now coming in at 10..., after taking about 3,500 trades. That is not even close to being right. With a 1 pip stop I would expect major losses overall. I am getting really disheartened by all of the goofy results I am getting. I hope someone out there understands what is happening under the hood here.

        Comment


          #5
          Ok, this will be my last post for tonight, I promise. I was searching around and found that when exiting a position to specific the barsInProgressIndex. I was already doing that with my entry, but I didn't realize there was an overloaded version of ExitShort()/ExitLong() that did the same thing. I was making the assumption that whatever time series you open a trade on, the entire life of the trade would be managed from that timeframe. After specifying the barsInProgressIndex as my granular secondary series, the profit factor dropped to 6. I am glad to see it drop, which let me know that code change actually did something. But a PF of 6 with a trailing stop of 1 pip, and basically no strategy but to just always be in the market, is a totally fake and ridiculous number.

          Comment


            #6
            After testing this some more, it seems more like there could possibly be a NT problem. Because of that I will be moving this over the bugs category. If you would like to help me solve this issue please respond to that thread.

            Comment


              #7
              Hello krugman25,

              Thank you for your posts.

              Can you provide the link to the other thread that you created on this?

              If the Renko bar is the primary series, then the SetStopLoss, SetProfitTarget, and SetTrailStop will work off of the Renko bars in historical calculation.

              Historical executions occur on the close of the bar. I would recommend reviewing the details between live and historical performance at the following link: http://ninjatrader.com/support/helpG...ime_vs_bac.htm
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                http://ninjatrader.com/support/forum...ad.php?t=88146

                Thank you Patrick. In that thread I described in detail exactly how I have my strategy set up and how I execute orders.

                I had read that link you posted. I am using a 1 tick secondary data series for grandular order execution. If I am understanding this right, I should have the same type of tick by tick granularity that I would have in live testing.

                Originally posted by NinjaTrader_PatrickH View Post
                Hello krugman25,

                Thank you for your posts.

                Can you provide the link to the other thread that you created on this?

                If the Renko bar is the primary series, then the SetStopLoss, SetProfitTarget, and SetTrailStop will work off of the Renko bars in historical calculation.

                Historical executions occur on the close of the bar. I would recommend reviewing the details between live and historical performance at the following link: http://ninjatrader.com/support/helpG...ime_vs_bac.htm

                Comment


                  #9
                  Hello krugman25,

                  Thank you for your response.

                  Adding an additional 1 Tick Series will not result in the calculations being performed tick by tick on the Renko bar. Instead you would see a 1 Tick bar calling OnBarUpdate and the Renko bars calling the OnBarUpdate(). The Renko bars would still be calculating on the close. You can submit orders to the 1 Tick Series, but the Set methods (SetStopLoss, etc.) will run off of the primary series (Renko).
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by krugman25 View Post
                    I am currently working on an EA that uses Renko bars. Before I wrote the first line of code I read half a dozen different threads about how you can't backtest on Renko charts. I partially understand why it doesn't work, and was able to simulate it myself. If I entered a trade and was immediately stopped out, I would end up profiting because of how it's using the Renko's bars for market orders.

                    I believe I fixed the issue by adding the Renko as an extra series. The primary chart is a normal chart using tick data. My strategy involves entering/exiting trades when the Renko bars cross above/below various indicators. Because I don't want to use Renko for market orders, but just as an indicator, I use "BarsInProgress() == 1" to check for my entry condition, and if there is an entry condition, I set a class level boolean and wait for "BarsInProgress() == 0" and then call EnterLong() or EnterShort(). If I set my orders from the Renko BarsInProgress I get a profit factor of 4, if I run the same EA but use the primary BarsInProgress(), I get a profit factor of 0.25. That would tell me I am approaching the issue correctly and perhaps have solved the problem of backtesting Renko charts, but making market orders off of the actual current tick prices.

                    Does this sound correct? Also am I missing anything else when using the Renko charts as an indicator? For example if I check if Renko is above/below an EMA, can that be trusted?

                    Thanks.
                    There is a good thread over at Big Mikes regarding Renko and scalping. It can be viewed here

                    Not sure it will help you with this problem but the thread has some interesting methods. The tread is very long and most things related to Renko are in the beginning.

                    Good luck in your quest.

                    Comment


                      #11
                      I use BetterRenko or UniRenko for all my strategy back-testing as well as live trading.

                      Works pretty well.

                      Comment


                        #12
                        Originally posted by bltdavid View Post
                        I use BetterRenko or UniRenko for all my strategy back-testing as well as live trading.

                        Works pretty well.
                        Thank you for this suggestion! I am going to check out UniRenko. I was planning on building my own Renko bar type because I wanted a renko bar where you could adjust the number of bricks required for a reversal, like a 3 box reversal in point-and-figure charting, but it looks like the UniRenko may already have that feature!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Bionian, Today, 10:10 AM
                        2 responses
                        14 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by D Trader, Today, 01:41 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post D Trader  
                        Started by rexmie888, Today, 04:00 AM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by terminatorT1000, Today, 01:23 AM
                        1 response
                        11 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by Tradarr, Today, 12:25 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post Tradarr
                        by Tradarr
                         
                        Working...
                        X