Coding Multi Time Frame (MTF) Indicators with NinjaTrader - NinjaTrader | futures io social day trading
futures io futures trading


Coding Multi Time Frame (MTF) Indicators with NinjaTrader
Updated: Views / Replies:103,339 / 411
Created: by Fat Tails Attachments:161

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 161  
 
Thread Tools Search this Thread
 

Coding Multi Time Frame (MTF) Indicators with NinjaTrader

  #71 (permalink)
Elite Member
Belgium
 
Futures Experience: Advanced
Platform: SaxoTrader
Broker/Data: SaxoBank
Favorite Futures: ESTX
 
Posts: 290 since Dec 2009
Thanks: 242 given, 109 received


Fat Tails View Post
The indicator currently allows you to set a starting time for an anchor point, but then will use the same starting time for every day. Of course, it is possible to add many other options, maybe I will do that in my second life....

Lol thanks again for your help. I am going to test this tomorrow

Reply With Quote
 
  #72 (permalink)
Elite Member
SE-Asia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Amp
Favorite Futures: ES
 
Posts: 141 since Jun 2009
Thanks: 57 given, 114 received


gomi View Post
Here's my contribution : a class GomMultiTFIndicator you can derive from.
This class allows you to

Is there any limitation?, If I use a 1000 vol chart with a 4 Renko MTFVol , the indi throw an exception.

Reply With Quote
 
  #73 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,177 since Oct 2009
Thanks: 228 given, 4,097 received


Sorry, I saw little interest so I didn't update the indy. Please find enclosed latest version.

GomMultiTFIndicatorBase is base class with no public properties
you must manually set properties

PeriodTypeBase (Tick, Second, Minute, ...)
PeriodLengthBase,
ResetModeBase (Bar, Daily,Weekly,Monthly, Quarterly, Annually)
RTHOnlyBase


GomMultiTFIndicator is the same, but with public properties you can change in indicator properties window.


Here are the exposed methods :


 
Code
                            
        //exposed to subclasses
        
protected  PeriodType PeriodTypeBase 
            
{get {return period;} set {period=value;}}

        protected 
int PeriodLengthBase 
                
{get {return periodlength;} set {periodlength=value;}}

        protected 
ResetType ResetModeBase 
                
{get {return reset;} set {reset=value;}}

        protected 
bool RTHOnlyBase 
                    
{get {return rthOnly;} set {rthOnly=value;}}
        
        
//property that tells you if current bar is RTH
        
protected bool  IsRTH get {return isRTH[0];}}
        
        
//if you want
        
protected virtual void GomInitialize() { }
        protected 
virtual void GomOnStartUp() { }

        protected 
virtual void GomOnNewBar() { }
        protected 
virtual void GomOnNewDay() { }
        protected 
virtual void GomOnNewWeek() { }
        protected 
virtual void GomOnNewMonth() { }
        protected 
virtual void GomOnNewQuarter() { }
        protected 
virtual void GomOnNewYear() { }

        
//mandatory
        
protected abstract void GomOnReset();
        protected abstract 
void GomOnData(double opendouble highdouble lowdouble closeint volume);
        protected abstract 
void GomOnDataDone(); 
You must implement GomOnReset (happens at the end of each period as defined in ResetMode), GomOnData : data arriving form second time series, and GomOnDataDone : all data from second time series sent, updating main time series.

Keep in mind you never know on which time series you are, so always use CurrentBars[0], Highs[0][0] etc to be sure you are always on the main time series.

There also a public property IsRTH you can always call in your code, that will tell if you are RTH or not on your main Time Series.

Whatever reset mode is ,you can always also call GomOnNewBar, GomOnNewDay, GomOnNewWeek etc...

GomOnNewBar is called on the beginning of each bar, then all the GomOnData, then GomOnDataDone.

Attached Files
Register to download File Type: zip GomMultiTF1.1.zip (3.2 KB, 114 views)
Reply With Quote
The following 6 users say Thank You to gomi for this post:
 
  #74 (permalink)
Elite Member
SE-Asia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Amp
Favorite Futures: ES
 
Posts: 141 since Jun 2009
Thanks: 57 given, 114 received


gomi View Post
Sorry, I saw little interest so I didn't update the indy. Please find enclosed latest version.

Thank you for your hard work I will try again in the weekend to see if I can make it work on my end :-(

Reply With Quote
 
  #75 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary

Not capable of understanding what it is doing...


gomi View Post
Sorry, I saw little interest so I didn't update the indy. Please find enclosed latest version

@gomi: I do not think that it is lack of interest.. I simply do not understand what you are doing, and then I do not know how to use it and how to make it work.

For example, I tried to set the indicator to RTH, but there was no impact on my chart. The RTH information is not stored in the master data for the instrument, so I am not astonished that there is not impact.

There are lots of variables defined in the Indicator Base, but I can't figure out what this all is needed for.

-> is OddType
-> is RTH
-> GetWeekNumber
-> OnNew (no idea what the resets are needed for)
-> MaxDate and MinDate

So the whole structure is unclear, I guess I need some guidance.

Attached Thumbnails
Coding Multi Time Frame (MTF) Indicators with NinjaTrader-es-09-11-10-min-08_07_2011.jpg  
Reply With Quote
 
  #76 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,177 since Oct 2009
Thanks: 228 given, 4,097 received

No problem, please don't feel you have to test it because you're the OP ;-)


Fat Tails View Post
For example, I tried to set the indicator to RTH, but there was no impact on my chart. The RTH information is not stored in the master data for the instrument, so I am not astonished that there is not impact.

RTH info is fetched from the master instrument setting, so if the contract has a default session of 24/5, RTH info won't show


Fat Tails View Post
There are lots of variables defined in the Indicator Base, but I can't figure out what this all is needed for.

-> is OddType
-> is RTH
-> GetWeekNumber
-> OnNew (no idea what the resets are needed for)
-> MaxDate and MinDate

These objects are internal objects, you don't need them.
The OnNew events are triggered during bar progression : each new bar fires OnNewBar, each new Day fires OnNewDay etc...

OnReset is fired depending on the Reset property : if it's Daily, it fires on the start of each new day, if it's weekly it fires on the start of each new week etc...
You could use the OnNewDay and OnNewWeek, but the OnReset method has all the logic already built to be synchronized to Reset property, so you can create daily/monthly/weekly indies with zero line of code.


Fat Tails View Post
So the whole structure is unclear, I guess I need some guidance.

Yes, I know, what you mean is ..... aargh... documentation.!.

Reply With Quote
The following 3 users say Thank You to gomi for this post:
 
  #77 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


gomi View Post
RTH info is fetched from the master instrument setting, so if the contract has a default session of 24/5, RTH info won't show

But there is no information on RTH i nthe master data. When I set your volume indicator to RTH, the RTH session in my template is simply ignored. I am not astonished, because how shall the indicator find out, which session is the RTH session?


gomi View Post
You could use the OnNewDay and OnNewWeek, but the OnReset method has all the logic already built to be synchronized to Reset property, so you can create daily/monthly/weekly indies with zero line of code.

Strange, when I try to add a daily data series to an intraday data series, NinjaTrader always inserts the daily data in the middle of the day. Actually I have had cases, where the data was inserted, before it was available and other cases, where it was inserted one session too late. So how do you make sure that the data is inserted when it should be inserted and not earlier or later?

This problem was the reason that I did not include an option to calculate intraday indicators from daily data for my MTF indicators. It always yielded false results. The reason is that the heuristic of NinjaTrader to add daily timestamps is flawed, if you use a session template with more than one session per day.

So I do not see how to use MTF indicators in RTH mode (your volume MTF example did not work), and I do not see how to add daily data.

Reply With Quote
 
  #78 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,177 since Oct 2009
Thanks: 228 given, 4,097 received


Fat Tails View Post
But there is no information on RTH i nthe master data. When I set your volume indicator to RTH, the RTH session in my template is simply ignored. I am not astonished, because how shall the indicator find out, which session is the RTH session?

I use the info here to define RTH:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).



Fat Tails View Post
Strange, when I try to add a daily data series to an intraday data series, NinjaTrader always inserts the daily data in the middle of the day. Actually I have had cases, where the data was inserted, before it was available and other cases, where it was inserted one session too late. So how do you make sure that the data is inserted when it should be inserted and not earlier or later?

This problem was the reason that I did not include an option to calculate intraday indicators from daily data for my MTF indicators. It always yielded false results. The reason is that the heuristic of NinjaTrader to add daily timestamps is flawed, if you use a session template with more than one session per day.

Well, I guess it won't work if session template has more than 1 session per day.
Concerning bar synchronization, session aligns the timestamps of the time series, and always starts with BarsInProgress=0 , the BarsInProgress=1 etc.. So you always know when the bars will arrive, don't you ?

I have only tested with intraday time frames, though. (not daily, weekly, etc...)

Reply With Quote
The following 2 users say Thank You to gomi for this post:
 
  #79 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,601 received
Forum Reputation: Legendary


gomi View Post
I use the info here to define RTH:

If you add a second BarSeries to produce a standard MTF indicator, it will always use the same session template as selected for the primary DataSeries. Or does your indicator use a different method?

Under instruments settings I have typically defined a multi-session template, which reflects the contractual trading times of the instrument - imagine the trading day divided into the RTH session and the remaining parts of the Globex session.

What does the RTH option change in this case?

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #80 (permalink)
Elite Member
Paris
 
Futures Experience: None
Platform: NinjaTrader
 
Posts: 1,177 since Oct 2009
Thanks: 228 given, 4,097 received



Fat Tails View Post
If you add a second BarSeries to produce a standard MTF indicator, it will always use the same session template as selected for the primary DataSeries. Or does your indicator use a different method?

The indicator considers that the default session template used in the instrument manager is what defines RTH, whatever session template you use for your chart.


Fat Tails View Post
Under instruments settings I have typically defined a multi-session template, which reflects the contractual trading times of the instrument - imagine the trading day divided into the RTH session and the remaining parts of the Globex session.

What does the RTH option change in this case?

RTH option will consider all time intervals defined in the master instrument session template as RTH.
If you split the whole 24/24 interval in the master instrument session template, so that all the hours are contained in the session template, obviously the RTH option won't do anything.

Reply With Quote
The following user says Thank You to gomi for this post:

Reply



futures io > > > > Coding Multi Time Frame (MTF) Indicators with NinjaTrader

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Time Frame Strategy Cancellation jthom NinjaTrader Programming 2 October 9th, 2014 12:00 PM
Close bar recognization in multi time frame strategy pinto552 NinjaTrader Programming 6 September 6th, 2011 10:07 AM
Multi-time frame strategy with periods of different size pequemec NinjaTrader Programming 2 February 24th, 2010 01:41 PM
visual multi-time frame scoring system. benbrooke Traders Hideout 1 October 4th, 2009 06:49 PM
Multi Volume/Time Frame Trading wh The Elite Circle 7 September 15th, 2009 05:55 PM


All times are GMT -4. The time now is 02:17 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-15 in 0.16 seconds with 20 queries on phoenix via your IP 54.82.56.95