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

  #321 (permalink)
Elite Member
uk
 
Futures Experience: Intermediate
Platform: ninja
Broker/Data: amp
Favorite Futures: ES
 
Posts: 164 since Aug 2009
Thanks: 102 given, 80 received

I have a multi-timeframe indicator for metatrader which colours the background of the chart that i'm on, based on the MACD cross of whichever timeframe I choose.

Is there an NT7 version available?

Reply With Quote
 
  #322 (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


subterfuge View Post
I have a multi-timeframe indicator for metatrader which colours the background of the chart that i'm on, based on the MACD cross of whichever timeframe I choose.

Is there an NT7 version available?

As far as I know, MetaTrader only uses minute charts. The best solution depends on your case:

(a) You can calculate the MACD values for a multiple of the original chart period (for example if you have a 5-minute chart, you can calculate the MACD for 10-minute, 15-minute, bars etc. , or if you have a 233-tick chart, you can calculate the MACD based on 466-tick bars, 699-tick bars. Those values can be calculated from the original bar series.

(b) To speed up the indicator you can use a different MACD formula to calculate them from the original bar series only. I have already coded such an indicator.

(c) A real multi-timeframe indicator is more difficult to code and needs to load a secondary bar series. There are some limitations to its use, when being called by a strategy. However you are very flexible, you can for example display an MACD calculated from 1000-volume bars on 8-Renko chart.

Comparison:

(a) requires synthetic bars, indicator coding is difficult

(b) fastest indicator, as there is a specific solution for the MACD (which is itself a derivative of EMAs)

(c) more work to code it properly

The difficulty is the treatment of the unstable period. To understand this imagine a MACD calculated from hourly bars displayed on a 5-min chart. When the hour is not closed, all hourly MACD values are preliminary, so if price moves up or down you would eventually need to repaint until the beginning of the hour, unless you accept to use the value at the end of the prior hour.

The solution (b) is a special approach which will work without repainting.

So you would need to explain, what you really need, and what you don't.

Reply With Quote
 
  #323 (permalink)
Elite Member
uk
 
Futures Experience: Intermediate
Platform: ninja
Broker/Data: amp
Favorite Futures: ES
 
Posts: 164 since Aug 2009
Thanks: 102 given, 80 received



Fat Tails View Post
As far as I know, MetaTrader only uses minute charts. The best solution depends on your case:

(a) You can calculate the MACD values for a multiple of the original chart period (for example if you have a 5-minute chart, you can calculate the MACD for 10-minute, 15-minute, bars etc. , or if you have a 233-tick chart, you can calculate the MACD based on 466-tick bars, 699-tick bars. Those values can be calculated from the original bar series.

(b) To speed up the indicator you can use a different MACD formula to calculate them from the original bar series only. I have already coded such an indicator.

(c) A real multi-timeframe indicator is more difficult to code and needs to load a secondary bar series. There are some limitations to its use, when being called by a strategy. However you are very flexible, you can for example display an MACD calculated from 1000-volume bars on 8-Renko chart.

Comparison:

(a) requires synthetic bars, indicator coding is difficult

(b) fastest indicator, as there is a specific solution for the MACD (which is itself a derivative of EMAs)

(c) more work to code it properly

The difficulty is the treatment of the unstable period. To understand this imagine a MACD calculated from hourly bars displayed on a 5-min chart. When the hour is not closed, all hourly MACD values are preliminary, so if price moves up or down you would eventually need to repaint until the beginning of the hour, unless you accept to use the value at the end of the prior hour.

The solution (b) is a special approach which will work without repainting.

So you would need to explain, what you really need, and what you don't.

The one of I have uses minute charts which is fine for me.
I can have open any timeframe chart, and can choose what 'macd timeframe' I want (which colours the background of my current chart, based on whether it's crossed up or down)

The issue of the unstable period is sometimes apparent. Yesterday my chart was light green as if the bigger timeframe MACD was crossed up, although if you went to the bigger timeframe, the macd was actually crossed down.
This I assume is because it was waiting for the bigger timeframe's bar to end. It later re-painted the indicator which I didn't much like.

In an ideal world, there'd maybe be a setting to be able to choose how it handles the unstable period, although for now, whilst playing around with some ideas, I'd be happy with anything.

Reply With Quote
 
  #324 (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


subterfuge View Post
The one of I have uses minute charts which is fine for me.
I can have open any timeframe chart, and can choose what 'macd timeframe' I want (which colours the background of my current chart, based on whether it's crossed up or down)

The issue of the unstable period is sometimes apparent. Yesterday my chart was light green as if the bigger timeframe MACD was crossed up, although if you went to the bigger timeframe, the macd was actually crossed down.
This I assume is because it was waiting for the bigger timeframe's bar to end. It later re-painted the indicator which I didn't much like.

In an ideal world, there'd maybe be a setting to be able to choose how it handles the unstable period, although for now, whilst playing around with some ideas, I'd be happy with anything.

The problem with the unstable period can be handled if you tweak the MACD formula. The MACD is based on a few EMAs and each of the EMAs has a smoothing constant k. All you need to do is to calculate a new smoothing constant for the higher timeframe. For example if your larger timeframe MACD is N times the bar period, then you can calculate the new smoothing constant k_new as 1 - Nth root of (1-k). This will not get you the original MACD, but something that comes very close, and you will benefit from two huge advantages

-> unstable period reduced to the last bar of the smaller timeframe
-> lower CPU load

I have already once tweaked a MACDOverlay, which is shown in the chart attached. However, this is not what you look for, as the four MACDs below are normalized to allow for the overlay. The classic MACD does not have any normalization.

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

Reply With Quote
 
  #325 (permalink)
Elite Member
Mérida, Mexico
 
Futures Experience: Intermediate
Platform: NinjaTrader 8
Broker/Data: looking
Favorite Futures: CL
 
michaelf's Avatar
 
Posts: 508 since Mar 2011
Thanks: 1,153 given, 512 received

Hi Fat Tails

short question, for the VisualEMA the data are from LAST, ASK or BID tick.

thanks

Michael

Reply With Quote
 
  #326 (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


michaelf View Post
Hi Fat Tails

short question, for the VisualEMA the data are from LAST, ASK or BID tick.

thanks

Michael

NinjaTrader does not store historical bid and ask data. The VisualSMA also works with historical data, and does not use bid or ask data. Basically no moving average does.

The Visual SMA loads a secondary bar series (minute, tick, volume, range or Renko) and calculates the moving average by using that bar series. All calculations use the last price traded either historical data from the historical data base, or real-time data when connected to a datafeed or replay data.

The result is then displayed on the chart with the primary bars. The main advantage of the VisualSMA is that you can calculate a moving average from a secondary bar series without paying the price of non-equidistant bar spacing. If you do not mind unevenly spread bars, then you do not need the VisualSMA.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #327 (permalink)
Elite Member
Mérida, Mexico
 
Futures Experience: Intermediate
Platform: NinjaTrader 8
Broker/Data: looking
Favorite Futures: CL
 
michaelf's Avatar
 
Posts: 508 since Mar 2011
Thanks: 1,153 given, 512 received


Fat Tails View Post
NinjaTrader does not store historical bid and ask data. The VisualSMA also works with historical data, and does not use bid or ask data. Basically no moving average does.

The Visual SMA loads a secondary bar series (minute, tick, volume, range or Renko) and calculates the moving average by using that bar series. All calculations use the last price traded either historical data from the historical data base, or real-time data when connected to a datafeed or replay data.

The result is then displayed on the chart with the primary bars. The main advantage of the VisualSMA is that you can calculate a moving average from a secondary bar series without paying the price of non-equidistant bar spacing. If you do not mind unevenly spread bars, then you do not need the VisualSMA.


When I look under Historical Data Manager, I see Historical Data from Bid and Ask!?

I have a big problem with Last data, it does not record correctely, thats the reason why I asked.

Like you can see on the screenshot, because of the wrong Last data the VisualSMA are a mess.

Perhaps you have an resolution for this or I have to try something else.

Thank you for you time

Michael

Edit: In Data Series, when I have Price based on - Bid, then the indicators are calculated with the Bid data and not with the Last data?

Attached Thumbnails
Coding Multi Time Frame (MTF) Indicators with NinjaTrader-4-chart.jpg  

Last edited by michaelf; July 25th, 2012 at 05:00 PM.
Reply With Quote
 
  #328 (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


michaelf View Post
Edit: In Data Series, when I have Price based on - Bid, then the indicators are calculated with the Bid data and not with the Last data?

That affects just the calculation of RJay'S Renko Hybrid, which are the primary bars. It has no impact on how the indicator calculates, as it always collects the last price.

I still have an issue with my version of the VisualSMA and Renko bars, which I have to check. Will take some time to answer.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #329 (permalink)
Elite Member
Mérida, Mexico
 
Futures Experience: Intermediate
Platform: NinjaTrader 8
Broker/Data: looking
Favorite Futures: CL
 
michaelf's Avatar
 
Posts: 508 since Mar 2011
Thanks: 1,153 given, 512 received

Hi Fat Tails

again me , sorry about that

Small question, on the visual's the nodes are always showed on the input panel, is it posible to change that so they showing always with the line no matter in wich panel they are.

thank you

michael

Reply With Quote
 
  #330 (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

VisualSMA


Hi @Fat Tails,

I 'm trying to use "VisualSMA" with displacement (positive number) and there is small issue with line plot color (last bar only) that paints with default gray color instead the selected rising/falling colors.
I've noticed that this behavior exist in all indicators that use "PlotColors[0][x]"
And my way to solve this in my indicators, is to use the inverse displacement value in "PlotColors"

I hope you will have time to check this issue.
Thanks

Erez

 
Code
protected override void OnStartUp(){PhaseShift = -1 * Displacement;}

 protected override void OnBarUpdate(){PlotColors[0][PhaseShift]}

Attached Thumbnails
Coding Multi Time Frame (MTF) Indicators with NinjaTrader-visualsma.png  
Reply With Quote
The following user says Thank You to Erez 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:32 AM.

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-14 in 0.16 seconds with 20 queries on phoenix via your IP 54.221.76.68