NexusFi: Find Your Edge


Home Menu

 





COBC false indicators on COBC true strategy


Discussion in NinjaTrader

Updated
    1. trending_up 4,685 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 10 posts
    2. attach_file 2 attachments




 
Search this Thread

COBC false indicators on COBC true strategy

  #1 (permalink)
 daydaxer 
Madrid/Spain
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers/Kinetick
Trading: FDAX
Posts: 16 since Mar 2012
Thanks Given: 3
Thanks Received: 6

Hi everybody!

In this thread I'm going to try to achieve something I find useful, and that currently Ninjatrader does not support: having Indicators calculated on real time (COBC false) on a CalculateOnBarClose strategy. NT support says it's not possible, but maybe we, together can achieve it.

My first thoughts:

1) We could achieve this by having a CalculateOnBarClose false strategy. All indicators would be then calculated on realtime, and we could handle COBC entry points by using FirstTickOfBar. Unfortunately backtesting a CalculateOnBarClose false strategy it's not very reliable.

2) We could achieve this by attaching a 1tick chart to the strategy, and discriminating on BarUpdate from the main chart (i.e. 1 minute) and the tick chart using BarsInProgress. So we basically could code two functions to be called in each case i.e OnBarTickUpdate() and OnBarCloseUpdate(). We could now place our code in either function depending on the granularity needed or wanted (i.e entries and trail stops on OnBarCloseUpdate and exits on OnBarTickUpdate). The only issue left is that if we want the main 1 min indicators to be updated with every OnBarTickUpdate() we need to hack something to make it work.


So, I think the way to go is the 2 option. But we need to be able to emulate the COBC false update of the indicators.

What we need is to calculate our own OHLC values for the current bar using tick data, and update the current bar of 1min indicators with them.

We could try this by:
A) Custom coding every single indicator we use in our estrategy, and replacing their use of High[], Low[], Close with our own code.

B) Adding code to the indicator class to handle this through all indicators.

At the moment I'm trying option B, I've tryed to overload the High, Low, Close Dataseries without success but I'll keep looking for a way to achieve this.

I just wanted to open this thread to hear other thoughts or ideas, and to post my advancement.

Cheers,
David.

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
77 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
38 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
17 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


Why don't you simply add a secondary bar series built from 1-tick bars and have that bar series running set to CalculateOnBarClose = true?

Your indicators running on that secondary bar series will then be updated with every incoming tick, and you can use them within your strategy as required.

The only problem that I can see is that NinjaTrader does not support sub-second granularity on historical data, which can falsify a backtest.

Reply With Quote
  #4 (permalink)
 daydaxer 
Madrid/Spain
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers/Kinetick
Trading: FDAX
Posts: 16 since Mar 2012
Thanks Given: 3
Thanks Received: 6


Fat Tails View Post
Why don't you simply add a secondary bar series built from 1-tick bars and have that bar series running set to CalculateOnBarClose = true?

Your indicators running on that secondary bar series will then be updated with every incoming tick, and you can use them within your strategy as required.

Thanks Fat Tails, but the problem I have is that my exit conditions are based in the indicators running on the 1 minute bars, and I can't find a proper translation between those and the ones running in the 1 tick or even 1 second bars.

i.e. If I want to exit when DM[14].DIMinus>XXX on the 1 minute bars, How can I find the equivalent to that in the 1 tick o 1 second bars?

Follow me on Twitter Started this thread Reply With Quote
  #5 (permalink)
 daydaxer 
Madrid/Spain
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers/Kinetick
Trading: FDAX
Posts: 16 since Mar 2012
Thanks Given: 3
Thanks Received: 6


daydaxer View Post
i.e. If I want to exit when DM[14].DIMinus>XXX on the 1 minute bars, How can I find the equivalent to that in the 1 tick o 1 second bars?

Actually that's what my problem is about. I need to have 1 minute indicators updated on 1 tick data to emulate COBC false for those indicators.

Follow me on Twitter Started this thread Reply With Quote
  #6 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


daydaxer View Post
Thanks Fat Tails, but the problem I have is that my exit conditions are based in the indicators running on the 1 minute bars, and I can't find a proper translation between those and the ones running in the 1 tick or even 1 second bars.

i.e. If I want to exit when DM[14].DIMinus>XXX on the 1 minute bars, How can I find the equivalent to that in the 1 tick o 1 second bars?

You need to code it. You can take the last known value of DM[14].DiMinus which was calculated from 1 min bars. Then you apply the DM indicator formulae to both the prior values of DM stored by the indicator and the last price retrieved by the 1-tick bar series.

The result is the current intrabar value of the indicator. That is all you need to do.

Reply With Quote
  #7 (permalink)
 daydaxer 
Madrid/Spain
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers/Kinetick
Trading: FDAX
Posts: 16 since Mar 2012
Thanks Given: 3
Thanks Received: 6


Fat Tails View Post
You need to code it. You can take the last known value of DM[14].DiMinus which was calculated from 1 min bars. Then you apply the DM indicator formulae to both the prior values of DM stored by the indicator and the last price retrieved by the 1-tick bar series.

The result is the current intrabar value of the indicator. That is all you need to do.

That was my original idea, but then I got greedy and I though we could be able to somehow overload the high, low, close for the current bar and modify the Indicator class to have that functionality in every indicator...

Maybe I was wishful thinking... :-)

Follow me on Twitter Started this thread Reply With Quote
  #8 (permalink)
 daydaxer 
Madrid/Spain
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers/Kinetick
Trading: FDAX
Posts: 16 since Mar 2012
Thanks Given: 3
Thanks Received: 6

Well, following Fat Tails advice, I dumped the idea of a general purpose solution and just coded what I needed. A COBC false DM indicator to handle my exits.

Here is the modified DM indicator and an example strategy (which just do print outs of the intrabar DM values)

Hope it helps someone else. Comments are welcome.

Attached Files
Elite Membership required to download: DMtick.cs
Elite Membership required to download: COBTIndicators.cs
Follow me on Twitter Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 daydaxer 
Madrid/Spain
 
Experience: Beginner
Platform: NinjaTrader
Broker: Interactive Brokers/Kinetick
Trading: FDAX
Posts: 16 since Mar 2012
Thanks Given: 3
Thanks Received: 6

Hi,

I'm coding some other indicators that update in realtime even when using strategies with CalculateOnBarClose true.

I've coded so far: SMA, StdDev, DM, Bollinger and MACD indicators. RSI an some other will come soon.

I don't know if any of you guys have a use for them, but I was wondering if this thread was the proper place to upload them or should I place them somewhere else or under a better titled thread.

Any idea?

Follow me on Twitter Started this thread Reply With Quote
  #10 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103



daydaxer View Post
Hi,

I'm coding some other indicators that update in realtime even when using strategies with CalculateOnBarClose true.

I've coded so far: SMA, StdDev, DM, Bollinger and MACD indicators. RSI an some other will come soon.

I don't know if any of you guys have a use for them, but I was wondering if this thread was the proper place to upload them or should I place them somewhere else or under a better titled thread.

Any idea?


@daydaxer: You could upload them here, maybe someone will join the discussion.

Later the right place to post them would be the download section of this forum.

Reply With Quote




Last Updated on June 6, 2012


© 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