NexusFi: Find Your Edge


Home Menu

 





Backtesting problems with Ninja


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one luitom with 2 posts (0 thanks)
    2. looks_two Gabriel123 with 2 posts (0 thanks)
    3. looks_3 baruchs with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,829 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 4 attachments




 
Search this Thread

Backtesting problems with Ninja

  #1 (permalink)
luitom
Firenze, Italy
 
Posts: 4 since Mar 2011
Thanks Given: 0
Thanks Received: 0

I am trying to backtest a breakout strategy (which enters long or short on the high and low of a certain bar) with ninjatrader; I have minute and tick historical data. unfortunately, they both do not work. The minute historical executes trades on the following bar (not on the actual bar where the entry condition becomes true) therefore the entire strategy becomes useless. On the other hand tick historical does not seem to executes trades the right way and sometimes gaps appear which create unrealistic stop exits. Has anybody encountered my problems and found a way to solve them?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
 
  #3 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800


Have you looked at this?

Strategy: [AUTOLINK]Backtesting[/AUTOLINK] NinjaScript Strategies with an intrabar granularity - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Reply With Quote
  #4 (permalink)
 
NinjaTrader's Avatar
 NinjaTrader  NinjaTrader is an official Site Sponsor
Site Sponsor

Web: NinjaTrader
AMA: Ask Me Anything
Webinars: NinjaTrader Webinars
Elite offer: Click here
 
Posts: 1,714 since May 2010
Thanks Given: 203
Thanks Received: 2,686


luitom View Post
The minute historical executes trades on the following bar (not on the actual bar where the entry condition becomes true) therefore the entire strategy becomes useless.

This is expected and standard basic backtest concept. A bar is evaluated (which is its closing values), if a signal is then generated, an order is submitted which is then filled on the following bar.

Follow me on Twitter Reply With Quote
  #5 (permalink)
luitom
Firenze, Italy
 
Posts: 4 since Mar 2011
Thanks Given: 0
Thanks Received: 0

Many other backtesting platforms have the option of executing in the same bar. The fact that it executes on the following bar makes testing impossible for intraday strategies because all the entries and exits are modified!!! Is there any way to create 1 minute bar objects and then use one to check for the breakout condition and the other to execute the order on the same bar instead of the following one?

Reply With Quote
  #6 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
Posts: 323 since Jun 2009


Quoting 
Is there any way to create 1 minute bar objects and then use one to check for the breakout condition and the other to execute the order on the same bar instead of the following one?

I think you are making a conceptual error. NT executes the trades too early and not too late.
There is no such thing as bar close! If you trade on 1 min bars and you are on a 10:01 bar, when will it close?
When your PC clock strikes 10:01 or the exchange clock or the atomic clock strike 10:01? No, you will get the close only after you get the first tick (trade) for a new bar, and even if your clock shows 10:15!
So first you receive a tick for a new bar and then NT says OH! the previous tick was the last tick of 10:01 bar.
So NT opens a new bar and then and only then it can close the previous bar.
Only then the execution of the strategy is triggered, so your order goes to the broker after first tick of a new bar and if it is really really quick it will land at the exchange before other traders issued their orders.
OK I know that usually one tick (trade) shouldn't move the market, but obviously in real trading you can't issue your trade on the bar close!
I used eSignal before NT and there you were able to peek into the future (see the next bar) in backtesting, unfortunately I was not able to get the same feature in live trading.

Reply With Quote
  #7 (permalink)
Wtuinvest
Munich
 
Posts: 7 since Mar 2011
Thanks Given: 0
Thanks Received: 3

In my experience is isn´t really possible to adequatly emulate real world live order execution as there are simply to many things to consider.
If you´re doing you´re backtesting just look at how execution dependant your strategy is by substracting a decent amount of slippage from each trade or try a slightly delayed execution algo.

Reply With Quote
  #8 (permalink)
 Gabriel123 
Stockholm
 
Experience: Intermediate
Platform: ProRealTime
Trading: DAX
Posts: 40 since Jul 2015
Thanks Given: 6
Thanks Received: 5

I'm backtesting in Ninjatrader. And there is something seriously wrong on all strategies that involves stop och target. Every trade gets stopped out immadietely only one point above the entry price (FDAX). Even though both the stop och the target are 15-30 points away from the entry price.

This problem does not only occur using my own strategies, but also to the pre-built strategies in the software (e.g. "SampleMultiInstrument"). The same thing happens when I test the strategies on other futures/forex.

What is wrong and how to fix it?

Thanks in advance!

Reply With Quote
  #9 (permalink)
 Gabriel123 
Stockholm
 
Experience: Intermediate
Platform: ProRealTime
Trading: DAX
Posts: 40 since Jul 2015
Thanks Given: 6
Thanks Received: 5

The same problem has happened to me several times now.

Suddenly every trade in my strategy gets stopped out immadietely only one point from the entry price. I am backtesting on FDAX and using 30 points stop loss (and 15 points profittarget).

This problem occured a couple of days ago, then suddenly it worked correct (meaning all the transactions ended 30 points at the stop or 15 points away at the limit) and then today this problem happened again. I have not changed anything relevant in the settings in the strategy during this period of time.

Please take a look at the attached images.

What is wrong?

Thanks in advance!

Attached Thumbnails
Click image for larger version

Name:	Sreenshot 01.jpg
Views:	135
Size:	432.0 KB
ID:	191528   Click image for larger version

Name:	Sreenshot 02.jpg
Views:	145
Size:	371.8 KB
ID:	191529   Click image for larger version

Name:	Sreenshot 03.jpg
Views:	138
Size:	503.9 KB
ID:	191530   Click image for larger version

Name:	Sreenshot 04.jpg
Views:	145
Size:	267.6 KB
ID:	191531  
Reply With Quote
  #10 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,426



Gabriel123 View Post
The same problem has happened to me several times now.

Suddenly every trade in my strategy gets stopped out immadietely only one point from the entry price. I am backtesting on FDAX and using 30 points stop loss (and 15 points profittarget).

This problem occured a couple of days ago, then suddenly it worked correct (meaning all the transactions ended 30 points at the stop or 15 points away at the limit) and then today this problem happened again. I have not changed anything relevant in the settings in the strategy during this period of time.

Please take a look at the attached images.

What is wrong?

Thanks in advance!

You've got bad data in there. You need to reload all your historical data, look at the exit prices you are being given and the lines on the chart.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on August 29, 2015


© 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