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,078 / 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

  #221 (permalink)
Elite Member
Albuquerque, New Mexico/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader-Continuum(Mirus)
Favorite Futures: emini Currency and Index Futures
 
Posts: 103 since Jan 2011
Thanks: 285 given, 104 received


Fat Tails View Post
I have been further digging into the NinjaTrader architecture, and the result is a simpler version of the VisualSMA and the VisualEMA. The new versions were entirely recoded from scratch and the code is about 80 lines shorter than the code of the previous versions.

Simplicity always means performance gain and robustness, so here are some of the main improvements:

-> loading time of the indicator on historical data reduced by a factor 10
-> lag of the indicators reduced
-> indicators can be safely called from other indicator or strategy

The chart below shows the 20-period EMA and 20-period SMA, both calculated from a 5 minute chart, but displayed on a 50 tick chart of the FDAX 12-11.

The new indicators are attached below. After installation you will find them as NewVisualSMA or NewVisualEMA in the dropdown menu of the indicator dialogue box. These are not the final versions, but pre-versions for testing.

Hello FAT TAILS,

Thanks for these incredible indicators. They have made a huge impact on my trading. I was wondering if it is possible to write a version of these indicators (Visual SMA/EMA) that have a color selection capability for the slope of the indicator (e.g., slope up = green/slope down = red, slope flat = yellow, etc.)?

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

Next Test Version (No.5) for Visual Indicators

Here comes the next version of new VisualSMA and VisualEMA. I have now tested it for hours and days on range, tick, volume and minute charts. The indicator was fast and reliable. I have not found any serious bugs. There was a smaller bug in the interpolation algorithm for the last period (@madLyfe: thank you for the hint!), and there were some smaller deviations at the intersection between historical and real-time data. This is the weak link of NinjaTrader bar processing, the composite bars built from historical and real-time ticks are quite strange and do not follow a simple logic. Fortunately there is only one transition bar on each chart. The indicator usually catches those transition bars in correctly. In rare cases - less than 1% - the composite bar of the secondary bar series is left out, and the last historical bar is directly connected to the first real-time bar.

The new indicators are attached. I am confident that I can upload the next version to the download section for general use.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Attached Files
Register to download File Type: zip VisualIndicatorsTest5.zip (46.7 KB, 112 views)
Reply With Quote
The following 16 users say Thank You to Fat Tails for this post:
 
  #223 (permalink)
Elite Member
Haifa,,,
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Futures
 
Posts: 186 since Mar 2011
Thanks: 181 given, 865 received



Fat Tails View Post
Here comes the next version of new VisualSMA and VisualEMA. I have now tested it for hours and days on range, tick, volume and minute charts. The indicator was fast and reliable. I have not found any serious bugs. There was a smaller bug in the interpolation algorithm for the last period (@madLyfe: thank you for the hint!), and there were some smaller deviations at the intersection between historical and real-time data. This is the weak link of NinjaTrader bar processing, the composite bars built from historical and real-time ticks are quite strange and do not follow a simple logic. Fortunately there is only one transition bar on each chart. The indicator usually catches those transition bars in correctly. In rare cases - less than 1% - the composite bar of the secondary bar series is left out, and the last historical bar is directly connected to the first real-time bar.

The new indicators are attached. I am confident that I can upload the next version to the download section for general use.

Hi Fat Tails,
I'm trying to use your latest version of visual SMA (VisualIndicatorsTest5) within another indicator.
Red line represents NewVisualSMA.
Blue line represents NewVisualSMA data series when called from another indicator with identical parameters.
I'm doing something wrong? Or the data series doesn’t reflect exact plot values?
Thanks

Erez

Attached Thumbnails
Coding Multi Time Frame (MTF) Indicators with NinjaTrader-visual-sma-6e-12-11.png  
Reply With Quote
 
  #224 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,651 since Mar 2010
Thanks: 4,226 given, 25,597 received
Forum Reputation: Legendary


Erez View Post
Hi Fat Tails,
I'm trying to use your latest version of visual SMA (VisualIndicatorsTest5) within another indicator.
Red line represents NewVisualSMA.
Blue line represents NewVisualSMA data series when called from another indicator with identical parameters.
I'm doing something wrong? Or the data series doesn’t reflect exact plot values?
Thanks

Erez

@Erez: This is as expected, but thank you for putting up this question. The VisualEMA and VisualSMA have three different ways of displaying the moving average, which are Strategy Mode, One-Tick-Repainting Mode and Visual Mode. These three modes work in a different way. For showing the difference I have added two charts below, which shows the VisualEMA in Strategy Mode (green), One Tick Repaint Mode (red) and VisualMode (blue).

Strategy Mode: Whenever the indicator detects a new bar close for the secondary bar series, it will write the moving average value associated with the bar close to the DataSeries which will be used to plot the indicator. The indicator is therefore displayed as a step series. The indicator does not repaint in strategy mode.

One-Tick-Repainting Mode: For historical data this mode is similar as the strategy mode. However, on real-time data, the close of the bar (other than tick and volume bars, where you could use a counter) can only be detected with the first tick of the next bar. At that stage the prior value of the moving average calculated from the secondary is painted back one tick to the previous bar. This one tick repainting is not done to introduce a hindsight bias, but to compensate for one of the shortcomings of the event driven architecture of NinjaTrader.

Visual Mode: The visual mode is based on the one-tick-repainting mode. However it interpolates the distance between to steps of the step function. In doing this the exact visual appearance of the original other timeframe indicator is obtained. This interpolation requires that the indicator paints back from the current node (shown as blue or orange dot on the chart) to the previous node. This painting back is the exact equivalent of what NinjaTrader does with the current unstable period, if you set any indicator to CalculateOnBarClose = false.


Calling the VisualEMA or VisualSMA by another indicator or from within a strategy

The backpainting is only conceived as a visual aid for the discretionary trader. The real-time gain in one-tick-repaint mode is 1 tick, which results in a lag compensation of 1 bar. In visual mode the backpainting is only used for the distance back to the last node as represented by a blue or orange dot. I believe that the repainting issues are creating problems, if you wish to call the indicator from another indicator or strategy. This would require updating of prior values of your indicators as well. For that reason and to avoid confusion, the indicator will automatically switch to strategy mode, if it is called. The one-tick gain on real-time data is not worth the confusion created, and the visual interpolation is not necessary, if the indicator is used within the context of a strategy.


Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Last edited by Fat Tails; November 3rd, 2011 at 09:16 AM.
Reply With Quote
The following 8 users say Thank You to Fat Tails for this post:
 
  #225 (permalink)
Elite Member
Rio de Janeiro
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire, IB
Favorite Futures: Equity & Futures
 
prisonbreaker82's Avatar
 
Posts: 312 since Jun 2010
Thanks: 57 given, 141 received

Hi Fat Tails,

Still receives the message on version 5 (when trying to save the template). When I use your old anaVisualEMA I do not get it...

Thank you for your great contribution!



Fat Tails View Post
I suppose that you got that message, when you tried to save the template. I think that there is a NinjaTrader bug, which occasionaly hits and causes problems with the serialization. Best solution is to shutdown NinjaTrader and to restart it again.

If this does not help, please let me know what exactly you did to produce this message.

If anybody else has made the same observation, please let me also know.


Reply With Quote
 
  #226 (permalink)
Elite Member
Haifa,,,
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: CQG
Favorite Futures: Futures
 
Posts: 186 since Mar 2011
Thanks: 181 given, 865 received


Fat Tails View Post
@Erez: This is as expected, but thank you for putting up this question. The VisualEMA and VisualSMA have three different ways of displaying the moving average, which are Strategy Mode, One-Tick-Repainting Mode and Visual Mode. These three modes work in a different way. For showing the difference I have added two charts below, which shows the VisualEMA in Strategy Mode (green), One Tick Repaint Mode (red) and VisualMode (blue).

Strategy Mode: Whenever the indicator detects a new bar close for the secondary bar series, it will write the moving average value associated with the bar close to the DataSeries which will be used to plot the indicator. The indicator is therefore displayed as a step series. The indicator does not repaint in strategy mode.

One-Tick-Repainting Mode: For historical data this mode is similar as the strategy mode. However, on real-time data, the close of the bar (other than tick and volume bars, where you could use a counter) can only be detected with the first tick of the next bar. At that stage the prior value of the moving average calculated from the secondary is painted back one tick to the previous bar. This one tick repainting is not done to introduce a hindsight bias, but to compensate for one of the shortcomings of the event driven architecture of NinjaTrader.

Visual Mode: The visual mode is based on the one-tick-repainting mode. However it interpolates the distance between to steps of the step function. In doing this the exact visual appearance of the original other timeframe indicator is obtained. This interpolation requires that the indicator paints back from the current node (shown as blue or orange dot on the chart) to the previous node. This painting back is the exact equivalent of what NinjaTrader does with the current unstable period, if you set any indicator to CalculateOnBarClose = false.


Calling the VisualEMA or VisualSMA by another indicator or from within a strategy

The backpainting is only conceived as a visual aid for the discretionary trader. The real-time gain in one-tick-repaint mode is 1 tick, which results in a lag compensation of 1 bar. In visual mode the backpainting is only used for the distance back to the last node as represented by a blue or orange dot. I believe that the repainting issues are creating problems, if you wish to call the indicator from another indicator or strategy. This would require updating of prior values of your indicators as well. For that reason and to avoid confusion, the indicator will automatically switch to strategy mode, if it is called. The one-tick gain on real-time data is not worth the confusion created, and the visual interpolation is not necessary, if the indicator is used within the context of a strategy.

@Fat Tails,

Thanks for this detailed explanation, I'm aware of to repainting issue after bar is close in secondary series.
I'm trying to do some calculation on this MTF line, but this can be done only on visual mode data series, this data also required to display the visual mode line as is.
Can you release experimental version with exposed visual mode data series?
I assume I can add some code in my indicator, to recognize these events of repaint and sync with it.
Thanks

Erez

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


Erez View Post
@Fat Tails,

Thanks for this detailed explanation, I'm aware of to repainting issue after bar is close in secondary series.
I'm trying to do some calculation on this MTF line, but this can be done only on visual mode data series, this data also required to display the visual mode line as is.
Can you release experimental version with exposed visual mode data series?
I assume I can add some code in my indicator, to recognize these events of repaint and sync with it.
Thanks

Erez


@Erez: I am not posting this publicly, because I know that there will be a huge number of issues.

If you are interested send me a private message and I will produce a specific version for you. Basically what would be required is an additional variable, which needs to be exposed and will allow you to catch the current value for the numbers of bars that are being painted back. Then you have the information, how many bars you need to set when calling the indicator.

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


prisonbreaker82 View Post
Hi Fat Tails,

Still receives the message on version 5 (when trying to save the template). When I use your old anaVisualEMA I do not get it...

Thank you for your great contribution!

@prisonbreaker82: I can save the template here. Do not really know, what causes your problem. If you wish contact me via private message, so that I can have a look at your chart template.

Reply With Quote
 
  #229 (permalink)
Elite Member
Albuquerque, New Mexico/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader-Continuum(Mirus)
Favorite Futures: emini Currency and Index Futures
 
Posts: 103 since Jan 2011
Thanks: 285 given, 104 received


gpquigley View Post
Hello FAT TAILS,

Thanks for these incredible indicators. They have made a huge impact on my trading. I was wondering if it is possible to write a version of these indicators (Visual SMA/EMA) that have a color selection capability for the slope of the indicator (e.g., slope up = green/slope down = red, slope flat = yellow, etc.)?


Perhaps not. Thanks anyway!

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



gpquigley View Post
Perhaps not. Thanks anyway!

I had already answered this question:

https://futures.io/ninjatrader/9393-coding-multi-time-frame-multiple-time-frames-indicators-ninjatrader-20.html#post164330

First comes the indicator.

Colors and alerts and the capability of sending an e-mail to your girl friend, when the moving average is sloping upwards will come later.

Reply With Quote
The following user says Thank You to Fat Tails 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)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

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 10:39 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-10 in 0.18 seconds with 20 queries on phoenix via your IP 54.221.73.186