NexusFi: Find Your Edge


Home Menu

 





Tip for backtesting on Renko charts


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one cpi65 with 10 posts (0 thanks)
    2. looks_two Zoethecus with 7 posts (1 thanks)
    3. looks_3 gregid with 6 posts (11 thanks)
    4. looks_4 aslan with 6 posts (9 thanks)
      Best Posters
    1. looks_one traderlange with 7 thanks per post
    2. looks_two Seberbach with 2.3 thanks per post
    3. looks_3 gregid with 1.8 thanks per post
    4. looks_4 aslan with 1.5 thanks per post
    1. trending_up 34,728 views
    2. thumb_up 43 thanks given
    3. group 18 followers
    1. forum 44 posts
    2. attach_file 2 attachments




 
Search this Thread

Tip for backtesting on Renko charts

  #1 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

All renko incarnations (NT Renko, MedianRenko, SBSRenko, WickedRenko) are unreliable for backtesting due to few issues. One of these issues is redrawing the "open" of the bar after the bar has formed.

In order to avoid the complications of the redraw:

Tip

Refrain from using Market Orders for backtesting purposes and replace all MARKET orders with LIMIT orders with LimitPrice = Close[0]
(this will simulate standard behaviour of market orders for CalculateOnBarClose = true)



Sample code:

 
Code
                            
//instead of using:
EnterLong("entry1");
//use:
EnterLongLimit(Close[0],"entry1");
 
 
//instead of using:
EnterShort("entry1");
//use:
EnterShortLimit(Close[0],"entry1"); 
Good luck backtesting!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Deepmoney LLM
Elite Quantitative GenAI/LLM
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
27 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
ntmt
ca
 
Posts: 2 since Jul 2010
Thanks Given: 3
Thanks Received: 0


Thank you for the tip!

Does it mean the following simple strategy will work as it supposed to on Wicked Renko charts?

HTML Code:
 protected override void Initialize()
        {
            SetProfitTarget("", CalculationMode.Ticks, 10);
            SetStopLoss("", CalculationMode.Ticks, 40, false);
            CalculateOnBarClose = true;
            EntriesPerDirection = 50; 
            EntryHandling = EntryHandling.UniqueEntries; 
        }

 protected override void OnBarUpdate()
        {
            if (Close[0] > Open[0])
            {
                EnterLongLimit(DefaultQuantity, Close[0], "L");
            }

            if (Close[0] < Open[0])
            {
                EnterShortLimit(DefaultQuantity, Close[0], "S");
            }
        }

Reply With Quote
  #4 (permalink)
 Zoethecus 
United States of America
 
Experience: Advanced
Platform: NT
Posts: 1,145 since Aug 2009


ntmt View Post
Thank you for the tip!

Does it mean the following simple strategy will work as it supposed to on Wicked Renko charts?

HTML Code:
 protected override void Initialize()
        {
            SetProfitTarget("", CalculationMode.Ticks, 10);
            SetStopLoss("", CalculationMode.Ticks, 40, false);
            CalculateOnBarClose = true;
            EntriesPerDirection = 50; 
            EntryHandling = EntryHandling.UniqueEntries; 
        }
 
 protected override void OnBarUpdate()
        {
            if (Close[0] > Open[0])
            {
                EnterLongLimit(DefaultQuantity, Close[0], "L");
            }
 
            if (Close[0] < Open[0])
            {
                EnterShortLimit(DefaultQuantity, Close[0], "S");
            }
        }

Highly unlikely.

Reply With Quote
  #5 (permalink)
ntmt
ca
 
Posts: 2 since Jul 2010
Thanks Given: 3
Thanks Received: 0


Zoethecus View Post
Highly unlikely.

Thank you for the reply.

I have read other threads about why backtesting on renko is not a good idea, but I thought the code above should function as close to reality as possible, since it make decisions only when the bar closes.

Could you give me a little more detailed explanation about why it won't?

Thanks again.

Reply With Quote
  #6 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

I can't vouch for it but I believe it makes a difference. Please see the attached image and guess which chart uses Market orders and which uses Limit orders (everything else is the same in the simple strategy).

I highlighted just one fragment where you could see it straight away

Attached Thumbnails
Click image for larger version

Name:	NowGuess.png
Views:	1231
Size:	313.0 KB
ID:	17379  
Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


gregid View Post
I can't vouch for it but I believe it makes a difference. Please see the attached image and guess which chart uses Market orders and which uses Limit orders (everything else is the same in the simple strategy).

I highlighted just one fragment where you could see it straight away

There is differences in the charts you show, that's sure, and does it make sense ?

Limit orders are limit orders, so:
- you can't be sure they will be filled, so some additional logic is needed in the strategy itself:
-> the limit order is sent, but is it filled ?
-> if it's filled, at which price, so what are the consequences for the target/stop ?
-> if it's not filled x minutes/ticks/bar, what do to ? Cancel the order, change the limit price, ... ?
So the backtests results may look more accurate, but that doesn't mean you can have accurate results (or results similar to the backtests) when the strategy runs live.

The good test, imvho, is to run such strategy with a live feed, and see how it looks after few days, and then compared the live resulsts with the backtests results. And before this, add the MM parts described below, needed by limit orders.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

Sam, I agree with 100% of what you wrote, but I think you are arguing against something I never claimed… but maybe I didn’t make it clear initially.

My original point was (and still is) “for backtesting purposes”. I never said I recommend using limit orders in live strategies as like with every type of order there are some pros and cons of every one of them and the decision which one to use should be made taking into consideration all possible ramifications (and you pointed out very well what would have to be considered for using Limit Orders while trading live)

So to rephrase and specify my initial point:

The way that market orders work for historical trades (and backtesting) is the order is placed at the Open of new bar. But because the Open of a new bar for renko bars is redrawn – the final Open is drawn only after the Close of the new bar is known, my proposed solution is to use Close[0] instead of Open[NewBar] for entry (when historical or backtesting).
In order to achieve it I suggest simulating MarketOrders with LimitOrders as in the post #1.

Few notes:
* The original NT6.5 SbSRenko (with long bars on reversal) doesn’t need this solution as the Open[NewBar]=Close[0] (I haven’t checked this yet – just an assumption)

* The suggested solution doesn’t take into consideration the slippage. If you decide to include slippage in your strategy, you would probably need to amend the limitprice to something like:
 
Code
                            
EnterLongLimit(Close[0]-(Slippage*TickSize),"entry1");
EnterShortLimit(Close[0]+(Slippage*TickSize),"entry1"); 


And to recap:
You don’t need to do simulate MarketOrders in live strategy – it is helpful only for historical trades and bactesting!!!
And: No backtest is comparable to live feed test!!!

Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

You can't do the slippage like that, in my opinion. Instead, use the NT menu itself and input at least 1 tick of slippage for the limit order.

The problem is, NT doesn't handle limit orders very well (in my experience). Just be sure you do a lot of 'live' trading (on sim) with the strategy. Trade it 'live' for a day or two, then go back and run a backtest for identical period. Do the results match, or are there "unexplainable" differences. That will be your sign

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623



Big Mike View Post
You can't do the slippage like that, in my opinion. Instead, use the NT menu itself and input at least 1 tick of slippage for the limit order.

Mike

It wasn't my intention to add slippage this way, but to show how one would have to amend LimitOrder to simulate MarketOrder once the slippage is added (from NT menu or in the code in Initialize section).

I will write it again:

It is only about simulating MarketOrder for backtesting purposes


[sigh].... I feel like I will spend the rest of the day explaining what I wrote

Started this thread Reply With Quote




Last Updated on March 8, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts