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

  #361 (permalink)
Elite Member
detroit,mi
 
Futures Experience: Beginner
Platform: NT
Favorite Futures: NQ
 
sudhirc's Avatar
 
Posts: 300 since Sep 2011
Thanks: 1,470 given, 326 received

errors

@Fat Tails

Rather than importing directly via File->Utilities->Import Ninja Script i unziped the attachment and copied the .cs folder into NT and opened through Edit NinjaScript and then complied.
The following are the errors in detail.

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

Reply With Quote
 
  #362 (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,602 received
Forum Reputation: Legendary


sudhirc View Post
@Fat Tails

Rather than importing directly via File->Utilities->Import Ninja Script i unziped the attachment and copied the .cs folder into NT and opened through Edit NinjaScript and then complied.
The following are the errors in detail.

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

You have probably an old version of the VisualSMA installed. Please uninstall vie File -> Utilities -> Remove Ninjascript Assembly.

Then import the latest version (August 2012) from the download section of this forum and it should work.

Prior to removing the assembly you will have to delete the access indicator, otherwise the assembly cannot be removed.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #363 (permalink)
Trading Apprentice
Earth
 
Futures Experience: Intermediate
Platform: NinjaTrader
 
Posts: 18 since Feb 2010
Thanks: 3 given, 6 received


Took a while to read the whole thread. And even after reading it I do not fully understand all the stuff involved.

But the indicator works and I'm really thankful Fat Tails!

Reply With Quote
The following user says Thank You to symphys for this post:
 
  #364 (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

Problems With Renko Setting

Hello Fat Tails,

I finally downloaded and installed the latest version of both VisualSMAMTF and VisualEMAMTF. I followed the directions carefully and removed the previous assembly and restarted NT. All were working fine with the old version. Now I am having the same problem with both SMA and EMA. I want to plot a bar graph on an indicator panel with the settings shown in the attached screen shot of the “Indicator Setup Menu.” I am trying to plot an 8 period Renko type onto a 450 period Tick chart. What I get is the result shown in attachment labeled “Renko Setting.” I.e., nothing, not even the proper label. I merely change the period type from Renko to Minute and everything looks fine, as shown in the attached screen shot labeled “Minute Setting.” A list of the errors shown in the NinjaTrader Log is shown in the fourth screen shot.

Any ideas as to what is going on?

Thanks for your help and the wonderful indicators. Looking forward to getting back to “normal.”

HDT

Attached Thumbnails
Coding Multi Time Frame (MTF) Indicators with NinjaTrader-indicator-setup-menu.png   Coding Multi Time Frame (MTF) Indicators with NinjaTrader-renko-setting.png   Coding Multi Time Frame (MTF) Indicators with NinjaTrader-minute-setting.png   Coding Multi Time Frame (MTF) Indicators with NinjaTrader-errors-vis-ema-sma.png  
Reply With Quote
 
  #365 (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,602 received
Forum Reputation: Legendary


HighDesertTrader View Post
Hello Fat Tails,

I finally downloaded and installed the latest version of both VisualSMAMTF and VisualEMAMTF. I followed the directions carefully and removed the previous assembly and restarted NT. All were working fine with the old version. Now I am having the same problem with both SMA and EMA. I want to plot a bar graph on an indicator panel with the settings shown in the attached screen shot of the “Indicator Setup Menu.” I am trying to plot an 8 period Renko type onto a 450 period Tick chart. What I get is the result shown in attachment labeled “Renko Setting.” I.e., nothing, not even the proper label. I merely change the period type from Renko to Minute and everything looks fine, as shown in the attached screen shot labeled “Minute Setting.” A list of the errors shown in the NinjaTrader Log is shown in the fourth screen shot.

Any ideas as to what is going on?

Thanks for your help and the wonderful indicators. Looking forward to getting back to “normal.”

HDT

The indicator does not work with Renko bars, I have to take out that options. This is due to a NinjaTrader limitation, as normally you cannot add other bar series dynamically.

There would be two workarounds possible to solve the problem:

-> add as many secondary bar series to the indicator as there are options
-> code a VisualSMA which works on RenkoBars only

I have not had the time to further enquire into this. I am currently waiting on feedback on another problem, which limits the use of the indicator when called by a strategy.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #366 (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,602 received
Forum Reputation: Legendary

Here is an update of the VisualSMA and VisualEMA indicators.

Those who dare please test:

- I have removed the option for Renko bars, this did not work anyhow, as the Renko bars cannot be added to the indicator dynamically.
- There was a bug discovered by @mborin, which prevented that the indicator could be accessed via a strategy using Rising(VisualSMA) or Rising(VisualEMA).

The indicators should work now. Those who dare, please test the attached assemblies and let me know whatever happens.

Before installing the new versions, please remove the prior versions via File -> Utilities -> Remove Ninjascript Assembly.

Attached Files
Register to download File Type: zip VisualEMA.zip (47.9 KB, 183 views)
Register to download File Type: zip VisualSMA.zip (48.3 KB, 158 views)
Reply With Quote
The following 11 users say Thank You to Fat Tails for this post:
 
  #367 (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,602 received
Forum Reputation: Legendary

Indicator Update VisualSMA and VisualEMA

I have updated the indicators in the download section. They are identical with the versions in the previous post # 366.

https://futures.io/download/ninjatrader-7/indicators/942-download.html?view
https://futures.io/download/ninjatrader-7/indicators/939-download.html?view

Reply With Quote
The following 8 users say Thank You to Fat Tails for this post:
 
  #368 (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,602 received
Forum Reputation: Legendary

Accessing the VisualSMA and VisualEMA

I just want to explain another time, how the indicators work and can be correctly accessed. The explanation refers to the VisualSMA but also applies to the VisualEMA


Strategy mode

Indicator collects data from secondary bar series. When a bar of the secondary bar series is complete, the value is displayed on the chart. This typically results in a step function.


One-Tick Repaint Mode

This mode corrects a weakness of the multi-barseries concept of NinjaTrader. OnBarUpdate() will be triggered for the primary bars and then for the secondary bars. Now imagine that you have a 15 min chart and want to display an hourly SMA. Then t the full hour NinjaTrader will first run the primary bars (allowing to write values to the chart) and then the secondary bars calculating the values from the hourly bars, which it should have written to the primary 15 min bars during the prior run of OnBarUpdate(). This mean that for the bar close of the 15 min bar, the last tick of the 60 min bar cannot be taken into account, because it is not available.

The solution adopted is to repaint the value to the prior bar with the first tick of the new 15 minute bar. The indicator therefore repaints the prior bar a single time, but only uses information from the prior 60 minute bar, which is unfortunately processed after the 15 min bar.

The result also is a step function, but the lag of 1 bar is eliminated when real-time data is processed.


Visual Mode

With each incoming tick the distance between the last node - in the example above that would be the close of the hourly bar - and the current value of the indicator is repainted by using a linear interpolation. In COBC = false mode you can see the last leg moving up and down.


Accessing the indicator

In strategy mode it is pretty easy to access the indicator via another indicator or a strategy. This is possible because the indicator does not repaint. However, there is a limitation. Any multi-timeframe indicator that loads range bars, cannot be properly accessed via another indicator or strategy. Sometimes the indicator values will be vertically shifted, that is the indicator values would be false.

Therefore the VisualSMA cannot be accessed when the period type selected via the indicator parameters is set to "Range".

If you want to access the VisualSMA in One-Tick Repaint or Visual mode you would need to take into account that the indicator repaints. When the indicator is accessed in One-Tick Repaint mode, you need to access the last 2 values for your strategy and let it recalculate. When you access the indicator in Visual mode, things are more complicated, as the indicator repaints over the last swinging leg. Here you would need to call all indicator values that cover this period.

The indicator offers you a Public IntSeries, which can be accessed and which tells you how many bars it paints back for the currennt value. The IntSeries can be accessed as VisualSMA(period, false, false, thisCalcMode, thisPeriodType, thisPeriodValue, thisPriceType).Repaint[0] and then used to collect the last indicator values. You can then use the integer to loop through the bars back to the last node, which is used as anchor point.

For those who are interested I have attached a model indicator that accesses the VisualSMA and plots the values on a chart. Please copy the model indicator into the directory NinjaTrader 7 -> bin -> custom -> Indicator and compile. It will only compile, if you have the VisualSMA installed.

In case that you have installed the model indicator or any other indicator or strategy that accesses the VisualSMA, do not forget to remove those indicators/strategies first before you uninstall the assembly.

Attached Files
Register to download File Type: cs AccessVisualSMA.cs (10.9 KB, 107 views)
Reply With Quote
The following 8 users say Thank You to Fat Tails for this post:
 
  #369 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,354 given, 83,237 received

Notifications sent.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following 3 users say Thank You to Big Mike for this post:
 
  #370 (permalink)
Elite Member
London, UK
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: EUR/USD
 
Posts: 58 since Jul 2012
Thanks: 3 given, 4 received

MTF Coding Issue


Hi guys, I've just finished reading this post. I must say it's really great. Thanks

I don't have strong programming skills and I am struggling trying to code a MTF strategy in NT7. I am sure this is simple and really would appreciate your help.

I have a few strategies that run on 10-15 min time frames, however I notice there are multiple fake signals that occur due to the fact that the strategies take-profit is very close and NT7 often enters&exits the trade within the same candle, ignoring the real price path. I think this issue could easily be solved by working on a Multi-Time-Frame Strategy. I tried using the Visual EMA when coding my strategy but it doesn't work. Probably because I am using the wizard to create the new strategy.

Lets assume I want to run the below strategy on 1 min time frame, but I want to use indicators (in the example below the 25 and 50 SMA) that refers to a 15 min time frame, and ALSO that I want to enter in position not more than once every 15 minutes. Could somebody please help me to figure out what code to use:

protected override void OnBarUpdate()
{
// Condition set 1
if (SMA,50 [0] > SMA,50 [1]
&& Close[0] > SMA, 25 [0])
{
EnterLongLimit(DefaultQuantity, SMA,25 [0], "");


Thanks for your help. This might be a stupid request but it's driving me crazy! Thanks

Reply With Quote

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 03:07 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-16 in 0.17 seconds with 20 queries on phoenix via your IP 54.163.209.109