NexusFi: Find Your Edge


Home Menu

 





Anyone Build A True Backtest Engine for CalculateOnBarClose = false in NT7?


Discussion in Trading Reviews and Vendors

Updated
      Top Posters
    1. looks_one artemiso with 4 posts (6 thanks)
    2. looks_two albertjay with 3 posts (2 thanks)
    3. looks_3 iantg with 2 posts (8 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,499 views
    2. thumb_up 16 thanks given
    3. group 7 followers
    1. forum 10 posts
    2. attach_file 0 attachments




 
Search this Thread

Anyone Build A True Backtest Engine for CalculateOnBarClose = false in NT7?

  #1 (permalink)
 albertjay 
Los Angeles CA
 
Experience: Advanced
Platform: NT
Trading: ES
Posts: 12 since Aug 2015
Thanks Given: 3
Thanks Received: 5

Just curious if anyone had developed a true backtest engine for NT7 for those of us who live in the CalculateOnBarClose = false world? As we know FirstTickOfBar doesn't solve the backtest problem. There's got to be one vendor who wanted to get rich off this idea...

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
 
  #3 (permalink)
 iantg 
charlotte nc
 
Experience: Advanced
Platform: My Own System
Broker: Optimus
Trading: Emini (ES, YM, NQ, ect.)
Posts: 408 since Jan 2015
Thanks Given: 90
Thanks Received: 1,148


If you are looking for accuracy with NT I can explain how a few things work under the hood.

First off, unless you are using market orders only, and only taking a few trades a day, throw away the strategy analyzer. It will overstate on every single scalping / limit order based strategy by a 100,000x magnitude.

Market replay uses actual tick data to simulate your fills, so you would want to run your tests off of this, however there are differences between 7 and 8. 7 is more optimistic, and 8 is more pessimistic with how the queue placement works. In case you want a look under the hood you can actually see the estimated place in the queue code with NT 8. They only fill from the back of the queue in all cases. This is fairly close to reality for most any retail trader.

But there are two huge issues with market replay you will need to account for and overcome if you want a halfway accurate test for scalping / limit order based strategies.

1. The execution latency is 0! So this assumes you have an FPGA and are sitting at the exchange. So you will have to bake in some latency into your code yourself to get it realistic for your use case. This can be done but it takes extra work.

2. The bigger issue is that if you run your code off of the OnBarUpdate method, this method front runs the OnMarketData event which is what is used to simulate your fills. So you can actually front run your own simulation by accident by using OnBarUpdate. You can also land cancels that occur after price level changes, and get nearly perfect queue placement as a function of this front running. The solution: Only run your code from the OnMarketData feed. Do not ever touch the OnBarUpdate feed for testing.

If you do live SIM, they add a built in latency of 150 MS on top of what you have from your actual latency. This might be overly pessimistic for some. But generlaly speaking the same rules apply, don't ever trade with OnBarUpdate if you want a valid test.

By Contrast if you ever trade live and want fast, the fastest event handler they have is the OnBarUpdate event. Which sucks because it only runs off of transactions and misses cancels and adds. Overall NT is only appropriate for longer term strategies. If you try scalping live with it, you will be too slow.

Ian

In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 artemiso 
New York, NY
 
Experience: Beginner
Platform: Vanguard 401k
Broker: Yahoo Finance
Trading: Mutual funds
Posts: 1,152 since Jul 2012
Thanks Given: 784
Thanks Received: 2,685


albertjay View Post
There's got to be one vendor who wanted to get rich off this idea...

Not much to add since @iantg is a lot more familiar with the specifics of NT7 and wrote a good post above. But that's effectively what Deltix, QuantConnect, Quantopian and SmartQuant are after on the lower end.

On the more institutional end, Flextrade entered this space fairly recently and they're decent in the connectivity world. RTS used to have one then they got acquired by Bloomberg and it's probably in some Bloomberg offering now. Itiviti also has one.

None of these is really decent.

Reply With Quote
Thanked by:
  #5 (permalink)
 albertjay 
Los Angeles CA
 
Experience: Advanced
Platform: NT
Trading: ES
Posts: 12 since Aug 2015
Thanks Given: 3
Thanks Received: 5

Ian, Market replay even at 500X is way too slow to accomplish back-testing for any legit timeframe (like at least a couple of years). I agree with your assessment though, it appears to be the only option. There are literally tens of thousands of NT users that are scalping, so I am surprised NT hasn't developed something themselves. Seems like a huge gap in a need for which many people I am sure would happily pay.

Started this thread Reply With Quote
Thanked by:
  #6 (permalink)
 artemiso 
New York, NY
 
Experience: Beginner
Platform: Vanguard 401k
Broker: Yahoo Finance
Trading: Mutual funds
Posts: 1,152 since Jul 2012
Thanks Given: 784
Thanks Received: 2,685


albertjay View Post
Ian, Market replay even at 500X is way too slow to accomplish back-testing for any legit timeframe (like at least a couple of years). I agree with your assessment though, it appears to be the only option. There are literally tens of thousands of NT users that are scalping, so I am surprised NT hasn't developed something themselves. Seems like a huge gap in a need for which many people I am sure would happily pay.

Yeah, retail platforms are awfully slow. Unfortunately this is one of those areas where if you've developed something good, you're more incentivized to keep it for yourself. I have a friend who runs one of the 3 largest trading firms in U.S. equities by volume, and he once mentioned a huge part of their "secret sauce" is the 50 man years of development time across their researchers (who all have PhDs) that were sunk into their simulation engine.

It's not difficult to write something faster and more accurate than NT market replay though if backtesting is all you're gunning for. I think it's a good learning experience that everyone who uses a backtester should go through.

Reply With Quote
Thanked by:
  #7 (permalink)
 albertjay 
Los Angeles CA
 
Experience: Advanced
Platform: NT
Trading: ES
Posts: 12 since Aug 2015
Thanks Given: 3
Thanks Received: 5

Someone should develop a faster or enterprise level market replay for NT. I see that $99 per month price tag on it.

Started this thread Reply With Quote
  #8 (permalink)
 iantg 
charlotte nc
 
Experience: Advanced
Platform: My Own System
Broker: Optimus
Trading: Emini (ES, YM, NQ, ect.)
Posts: 408 since Jan 2015
Thanks Given: 90
Thanks Received: 1,148

Your absolutely right about NT 7 being crazy slow. I used to setup 4 or 5 laptops and run them 24 hours a day to get a years worth of data over a weekend tested. But then NT 8 came along..... It may be painful to migrate your code, but at max speed on a solid laptop NT 8 can do the job of 10 laptops running market replay on NT 7.

It's well worth the pain to just poke around here over a weekend and migrate all your code:
https://ninjatrader.com/support/helpGuides/nt8/en-us/?code_breaking_changes.htm


albertjay View Post
Ian, Market replay even at 500X is way too slow to accomplish back-testing for any legit timeframe (like at least a couple of years). I agree with your assessment though, it appears to be the only option. There are literally tens of thousands of NT users that are scalping, so I am surprised NT hasn't developed something themselves. Seems like a huge gap in a need for which many people I am sure would happily pay.


In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
 
zacharydw00's Avatar
 zacharydw00 
Idaho
 
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180


iantg View Post
If you are looking for accuracy with NT I can explain how a few things work under the hood.
...

My work with NT 7 & 8 totally agrees and confirms what @iantg has stated above.

NT is not that suitable for scalping. NT 8 is getting better, but I still would stay away from using scalping systems on it.



albertjay View Post
Someone should develop a faster or enterprise level market replay for NT. I see that $99 per month price tag on it.

Sorry to say, that Ninja's customer base is to small to support a niche product like that at $99/mo. It would need to start at $250/mo for a company to stay in business. That type of product would need very well educated support team to properly help customers of that nature. And, those type of employees are not cheap.
Like @iantg said NT 8 Replay Connection is much faster. And, I've heard, Xeon processors give an extra boost in speed. I don't plan on spending the extra $ to find out though.

Milk-a-What?
Reply With Quote
  #10 (permalink)
 artemiso 
New York, NY
 
Experience: Beginner
Platform: Vanguard 401k
Broker: Yahoo Finance
Trading: Mutual funds
Posts: 1,152 since Jul 2012
Thanks Given: 784
Thanks Received: 2,685



Quoting 
Like @iantg said NT 8 Replay Connection is much faster. And, I've heard, Xeon processors give an extra boost in speed. I don't plan on spending the extra $ to find out though.

I have quite a few data points, usually the retail processor is faster for a single host machine because you can overclock it easily. What the Xeon processors are usually better for are ECC support, dual/quad processor support, more memory support, larger cache size, and better binning for base clock, most of which become more meaningful if you have a cluster.

Reply With Quote




Last Updated on March 5, 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