NexusFi: Find Your Edge


Home Menu

 





Backtesting With Only OHLC Data


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one goodoboy with 8 posts (2 thanks)
    2. looks_two rleplae with 5 posts (8 thanks)
    3. looks_3 grausch with 5 posts (5 thanks)
    4. looks_4 DarthJewel with 1 posts (1 thanks)
      Best Posters
    1. looks_one rleplae with 1.6 thanks per post
    2. looks_two grausch with 1 thanks per post
    3. looks_3 DarthJewel with 1 thanks per post
    4. looks_4 goodoboy with 0.3 thanks per post
    1. trending_up 5,499 views
    2. thumb_up 16 thanks given
    3. group 4 followers
    1. forum 19 posts
    2. attach_file 0 attachments




 
Search this Thread

Backtesting With Only OHLC Data

  #1 (permalink)
goodoboy
Houston
 
Posts: 380 since Dec 2016
Thanks Given: 344
Thanks Received: 246

Hello,

I am new to programming and back testing futures trading strategies.

I was reading this https://ninjatrader.com/support/helpGuides/nt7/?discrepancies_real_time_vs_bac.htm

I am confused about this statement "Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest."

I trade on the CL and ES 5 min candle chart

Questions:

1. How can I back test my strategy if my stops and targets prices are calculated/predefined? For instance, if bar close above resistance level 53.50, enter limit order 53.52. What happens if the OHLC of the next bar is 53.59, 53.61,53.48, and 53.56, respectively ?

Does this mean I will not be filled at 53.52?

Any recommendations or options I can consider for getting all the tick data for a back test?

Thank you in advance.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #2 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


goodoboy View Post
Hello,

I am new to programming and back testing futures trading strategies.

I was reading this https://ninjatrader.com/support/helpGuides/nt7/?discrepancies_real_time_vs_bac.htm

I am confused about this statement "Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest."

I trade on the CL and ES 5 min candle chart

Questions:

1. How can I back test my strategy if my stops and targets prices are calculated/predefined? For instance, if bar close above resistance level 53.50, enter limit order 53.52. What happens if the OHLC of the next bar is 53.59, 53.61,53.48, and 53.56, respectively ?

Does this mean I will not be filled at 53.52?

Any recommendations or options I can consider for getting all the tick data for a back test?

Thank you in advance.


Question : you create your order on bar-close ?

Answer : in general, then if the price goes higher, than your price, in our back testing, you can assume you would get a fill in real-life, unless what you are trying to buy, is a number of contracts that would have acted as an iceberg, also important is the type of order. If you put limit orders, and volume is reasonable, then you are ok, if you put market order, back test could be (significantly) different from real-life (because volume, the bigger it is) impacts the price

Recommendation : once you have something that works, let it run in forward
and once it works in forward, let it run on a real account with real money with one contract
scale from there..

good luck !

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
goodoboy
Houston
 
Posts: 380 since Dec 2016
Thanks Given: 344
Thanks Received: 246



rleplae View Post

Recommendation : once you have something that works, let it run in forward
and once it works in forward, let it run on a real account with real money with one contract
scale from there..

good luck !

Thank you rleplae,

I am not sure I follow you to full understanding. I assume the Strategy Analyzer in Ninja Trader give me some probability (with some precision of accuracy) of something that works. But if my price entries will not be filled during back testing, then how I know if something works.

What does everyone here do about back testing only providing the 4 data points of OHLC? Forgive me if question is somewhat easy to most.

Thanks,

Reply With Quote
  #4 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


goodoboy View Post
Thank you rleplae,

I am not sure I follow you to full understanding. I assume the Strategy Analyzer in Ninja Trader give me some probability (with some precision of accuracy) of something that works. But if my price entries will not be filled during back testing, then how I know if something works.

What does everyone here do about back testing only providing the 4 data points of OHLC? Forgive me if question is somewhat easy to most.

Thanks,

You have two possibilities to fire your order
1) on bar close, based on certain condition (OnBarUpdate event in NT
2) during the bar, based on certain condition (OnMarketUpdate even in NT

What i'm saying is, that your fill depends on where you fire the order ...

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
DarthJewel
London
 
Posts: 7 since Jul 2016
Thanks Given: 1
Thanks Received: 3

[ I am a little late with the answer , anyway ]

I think that means that from your example OHLC you can only be certain that during these 5 min there were transactions made at prices 5.48 and 5.56. You do not know if anyone was offering the price 5.52 besides you.
The quotes could go up slowly 5.48 , 5.50 ,5.52, 5.50 ,5.52, 5.54, 5.56
or just jump from 5.48 to 5.56
You do not know also about the volume of transactions made at these prices.

Reply With Quote
Thanked by:
  #6 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


DarthJewel View Post
[ I am a little late with the answer , anyway ]

I think that means that from your example OHLC you can only be certain that during these 5 min there were transactions made at prices 5.48 and 5.56. You do not know if anyone was offering the price 5.52 besides you.
The quotes could go up slowly 5.48 , 5.50 ,5.52, 5.50 ,5.52, 5.54, 5.56
or just jump from 5.48 to 5.56
You do not know also about the volume of transactions made at these prices.

That is correct, the fill is hypothetical
one can assume (if volume is not huge), that if you limit is before a higher (for sell) and above (fore buy) other
historical execution, the is reasonable basis to assume a fill would have been likely... (not 100% sure) hence
difference between backtest and forward test

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
goodoboy
Houston
 
Posts: 380 since Dec 2016
Thanks Given: 344
Thanks Received: 246


rleplae View Post
That is correct, the fill is hypothetical
one can assume (if volume is not huge), that if you limit is before a higher (for sell) and above (fore buy) other
historical execution, the is reasonable basis to assume a fill would have been likely... (not 100% sure) hence
difference between backtest and forward test

Thanks for reply

Yes, I understand that part and that is good point.

Problem:
NT7 only provides the Open, High, Close, and Low prices for each 5 min bar, if my limit entry price is not one of the 4 prices, that trade may will not execute, which will lead to incorrect back testing.

For my strategy, this is a problem because I use calculated entry, stops and targets that may not be the Open, High, Close, and Low price.

Is there any solution you have for my problem other then forward testing and market replay?

Thank you,

Reply With Quote
  #8 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


goodoboy View Post
Thanks for reply

Yes, I understand that part and that is good point.

Problem:
NT7 only provides the Open, High, Close, and Low prices for each 5 min bar, if my limit entry price is not one of the 4 prices, that trade may will not execute, which will lead to incorrect back testing.

For my strategy, this is a problem because I use calculated entry, stops and targets that may not be the Open, High, Close, and Low price.

Is there any solution you have for my problem other then forward testing and market replay?

Thank you,

That statement is not correct.

You order gets filled (with theoretical chance) if
- for a sell, the price went to that price (not sure) and preferable above
- for a buy, the price went to that price (not sure) and preferable below

In reality the fills may be different based on the liquidity (not enough buyers/sellers)

It is important to see how you trigger your order, as said before :
on bar close -> your order is ready for a fill in the next bar
on market update -> your order can still get a fill in the current bar, if the price fills your order

best close results are with market replay, and just let your strategy run on a tick by tick basis

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
 grausch 
Luxembourg, Luxembourg
 
Experience: Advanced
Platform: TWS
Broker: Interactive Brokers
Trading: Stocks
Posts: 494 since May 2012
Thanks Given: 1,731
Thanks Received: 1,159

I'd also add that it is always a good idea to review a sample of the backtest manually to ensure it works as intended.

What this means is that you select a certain period and manually "walk-forward" through your charts to ensure that a) trades that should execute were executed in your backtest, and b) trades execute at realistic fills.

You can't merely review trades that executed, because you will never know if there are any trades that should have executed that did not.

The realistic fills comment applies to all trading, but once you are aware of how NT approximates its fills, you may need to adjust the slippage. For instance, their fill algorithm will always give unrealistic fills if you are using Uni-Renko bars and entering on breakouts of the Uni-Renko. The manual review will highlight these type of issues. It will also help you to get comfortable with the logic NT uses in determining whether trades should execute.

To tie in with your original question, I have always used OHLC when backtesting. When using 1 minute candles there is not much to be gained by going to tick data unless you wish to trade or hold through news events. Even then, I don't think there would be much benefit due to the random and often violent nature of these moves.

Reply With Quote
Thanked by:
  #10 (permalink)
goodoboy
Houston
 
Posts: 380 since Dec 2016
Thanks Given: 344
Thanks Received: 246



rleplae View Post

best close results are with market replay, and just let your strategy run on a tick by tick basis

Thank you so much for clarifying and correcting me.

Appreciate the help.

Market Replay Comments:
This make good sense as well to just let the automated strategy run on market replay for 120 days and confirm the system is trading per design and the review the trading performance as time goes by. Also, i read the market replay can be done for multiple markets at the same time. I will have to research the difference between NT Historical Data used for market replay vs recording the live data for 120 days.

Then just for experiment sake it would be a decent idea to back test the strategy for these same 120 days using the Strategy Analyzer and compare the results.

Would you recommend this as an opinion?

Thanks,

Reply With Quote




Last Updated on February 27, 2017


© 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