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

  #31 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received

Zondor,

We are not aware of any limitation regarding plots updating only on BarsInProgress == 0. Please try the attached test reference on a 1min chart. The indicator adds two additional 30 second series which would process twice as much as the BIP0 of 1min. The indicator has 3 plots, each one representing the number of bars of each Bar series multiplied by a different factor so we can view them easily. With the Output Window open you can see the last BIP0 event shows CurrentBar counters of 4805, 22764, and 33738 for BIP0, BIP1, and BIP2 respectively. The next event was the BIP1 event which updated the BIP1 counter to 22766 and the final BIP2 event updated the BIP2 counter to 33741. There has been no subsequent BIP0 event yet so if it were the case that plots only updated on BIP0 then we would actually still be seeing the original values of 4805, 22764, and 33738, but instead we are seeing the BIP1 and BIP2 updated values on the chart of 4805, 22766, and 33738.

In our test the chart is “refreshing” and updating whenever deemed necessary by the code as it asks to update the plot values. I would be curious how your environment might differ from ours and/or how your code might be different? It would be great if you could breakdown how exactly you came to the conclusion that these values do not update on the chart outside of BIP0.

Thank you.

Attached Thumbnails
Coding Multi Time Frame (MTF) Indicators with NinjaTrader-1.png  
Attached Files
Register to download File Type: zip BIPTests.zip (1.9 KB, 45 views)
Reply With Quote
The following 3 users say Thank You to NinjaTrader for this post:
 
  #32 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received

Forced Refresh needed in practice


Quoting 
We are not aware of any limitation regarding plots updating only on BarsInProgress == 0.

Thanks for responding, Ninjatrader. Glad to see your interest in this important and under appreciated topic.

Right now, in real time, I am running an indicator that plots an ADDed series of ^TICK on a chart having primary series YM. To test it I run it side by side with a Time and Sales of ^TICK.

If the line (#303)
 
Code
 if(!Historical  && BarsInProgress==1 && displayprice!=mrp && forcerefresh && lastBar>0 )ChartControl.Refresh();
,
is in the code, the plot of ^TICK updates in lockstep to the T &S. As soon as I comment out the line and refesh the chart, the plot of ^TICK only updates when there is a trade of the YM, which sometimes doesn't happen for a while.

It's ideal to test this on the chart of a master instrument that trades much slower than the ADDed secondary instrument. Then it is very noticeable when the chart does nothing in response to ticks of the secondary instrument that print to the Time and Sales.

I mentioned this on the Ninjatrader forums using my secret identiy of "Ricam". RyanM responded with a request for clarification.

In your code, all the events happen as they should. So the print statements all fire. Mine did that too. But the plots would not update on the screen image unless it was a BIP=0 update. It's only the visual appearance of the chart on the screen that lags. As far as I know the code in the OnBarUpdate method always DOES respond correctly to the events generated for each of the Bars series.

My indicator is attached fo you to play with. I would call this version a "pre-beta". You will see that I have been doing a lot of error tracking. It runs without any runtime errors most of the time now. It seems to be accurate for real time data, but maybe not for backfilled data... but that's a whole other story.

Attached Files
Register to download File Type: cs SecondaryIndicatorLinePlot3.cs (24.4 KB, 69 views)

Last edited by Zondor; May 26th, 2011 at 12:52 PM.
Reply With Quote
The following 3 users say Thank You to Zondor for this post:
 
  #33 (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

How is OnBarUpdate() Triggered in Real-Time



NinjaTrader View Post
Zondor,

We are not aware of any limitation regarding plots updating only on BarsInProgress == 0. Please try the attached test reference on a 1min chart. The indicator adds two additional 30 second series which would process twice as much as the BIP0 of 1min. The indicator has 3 plots, each one representing the number of bars of each Bar series multiplied by a different factor so we can view them easily. With the Output Window open you can see the last BIP0 event shows CurrentBar counters of 4805, 22764, and 33738 for BIP0, BIP1, and BIP2 respectively. The next event was the BIP1 event which updated the BIP1 counter to 22766 and the final BIP2 event updated the BIP2 counter to 33741. There has been no subsequent BIP0 event yet so if it were the case that plots only updated on BIP0 then we would actually still be seeing the original values of 4805, 22764, and 33738, but instead we are seeing the BIP1 and BIP2 updated values on the chart of 4805, 22766, and 33738.

In our test the chart is “refreshing” and updating whenever deemed necessary by the code as it asks to update the plot values. I would be curious how your environment might differ from ours and/or how your code might be different? It would be great if you could breakdown how exactly you came to the conclusion that these values do not update on the chart outside of BIP0.

Thank you.

I have now slightly modified the indicator to show a problem that I have encountered. Same indicator, but I now use a 2 minute chart of 6E and add the 7-min and 29-min bar series of the same instrument 6E. Further I check for historical data to identify whether the ticks shown on the output window are historical or real-time ticks. Then I use the indicator in CalculateOnBarClose = false mode. Indicator is attached.

Below is an excerpt from the output file. In real-time, I would have expected that an incoming tick of 6E triggers BarsInProgress 0, 1 and 2 in an alternating way. However, what the output file shows, is that BarsInProgress is not at all called in a logical, but in a fuzzy way.


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 output.zip (14.9 KB, 21 views)
Register to download File Type: zip BIPTest.zip (1.9 KB, 28 views)
Reply With Quote
 
  #34 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received

Ninja flunks the BIP test.

I ran the BIP test and agree with FT that something looks fishy.

Since all the bars are for the same instrument, all three of the Bar Series should update everytime there is a trade in the instrument. Or so it would seem.

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


Zondor View Post
The VisualEMAX with a period of 1 can be used as a proxy for the price of a series with any time frame including or other than that of the chart. But when I try to take advantage of this by runnng an indicator that calls the VisualEMAX3 I get the error:

Error on calling OnStartUp method for indicator VisualEMAX3, Object reference not set to instance of an object.

My indicator then displays nothing.

The same thing happens when I try to apply another indicator to the VisualEMAX3 using the NT7 indicator-of-an -indicator feature of the indicators dialog box.


Because the code is in a DLL I can't do anything about the error. FT, could you please consider adding try{ }catch error handlers to all of the methods of the indicator to make sure that all exceptions are handled to prevent crashing of indicator from unhandled exceptions. Thanks.

@Zondor: Thanks again for identifying the bug. I have tested the indicator and identified the source of the problem. It is the code snippet below, which I used in OnStartUp().

 
Code
if(ChartControl.EquidistantBars)
	equidistantBars = true;
else
	equidistantBars = false;
It seems that ChartControl.EquidistantBars does not return a proper value.

I had used this because the algorithm, which interpolates the values calculated from the secondary bars series works in a different way on equidistant bars and non-equidistant bars as used for multi time series charts.

In case that the VisualEMA is called by another indicator or used in an indicator-on-indicator approach the visual interpolation cannot be used, so the indicator

-> should not be used in visual mode (repainting the distance between current and previous value of secondary bar series
-> does not need the information whether the chart is equidistant or non-equidistant

Does anybody know, how I can check whether the indicator is used for another indicator or whether it plots to a chart?

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #36 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received


Quoting 
Does anybody know, how I can check whether the indicator is used for another indicator or whether it plots to a chart?

I don't know how to do this either, but as an expedient you could add a Parameter that allows the user to specify whether the indicator is being used by another indicator, or being displayed on a chart (default).

Needs to be under Category "Parameters" so it will be accessible in the dialog box when setting up the indicator of an indicator.

I asked Ninatrader Support to look into the BIP test. They have been extremely gracious, responsive and helpful.

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


Zondor View Post
I don't know how to do this either, but as an expedient you could add a Parameter that allows the user to specify whether the indicator is being used by another indicator, or being displayed on a chart (default).

Needs to be under Category "Parameters" so it will be accessible in the dialog box when setting up the indicator of an indicator.

I asked Ninatrader Support to look into the BIP test. They have been extremely gracious, responsive and helpful.

I have overwhelmingly positive experience with the support staff as well. Basically there are just a fwe pending issues that are difficult to reproduce.

I do not want to go the route with the user selectable option, whether the indicator will be used within a strategy or by another indicator. As you suggested, I used try{} catch{}, so in case that ChartControl cannot be accessed the indicator will automatically switch to strategy mode. As the information, whether the indicator runs on equidistant bars or not is only needed for the interpolation in visual mode of the indicator, this should be a first solution. This is what I used and it seems to work.

 
Code
try
{
      if (ChartControl.EquidistantBars)
          equidistantBars = true;
      else
          equidistantBars = false;
}
catch
{
      thisCalcMode = VisualEMAX4CalcMode.StrategyMode;
}
Not elegant, but prevents that the indicator stops working.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #38 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received

NoGo in Strategy Mode (without error handler)

Again tried using the VisualEMAX as the base for another indicator, this time choosing strategy mode, but got the same error from OnStartUp. I do realize that there is no error handler in this version, but this shows that simply switching to Strategy mode will, by itself, not prevent the error.

Eagerly awaiting the next version....

Thanks.

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


Zondor View Post
Again tried using the VisualEMAX as the base for another indicator, this time choosing strategy mode, but got the same error from OnStartUp. I do realize that there is no error handler in this version, but this shows that simply switching to Strategy mode will, by itself, not prevent the error.

Eagerly awaiting the next version....

Thanks.

Switching to strategy mode alone will not help, as the error was caused by calling 'ChartControl.EquidistantBars'.

The version attached uses the code snippet as per post # 37.

Let me know, whether it works.

Attached Files
Register to download File Type: zip VisualEMAX4.zip (40.3 KB, 83 views)
Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #40 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received

Test of VisualEMAX4: Much better but not quite there.


Tested on an 80 tick chart of YM going back 2 days. Plotted the 10 period JMA and the 10 period RSX of the 2 period 2 minute VisualEMAX4

No errors appeared in the output window. Worked fine for the PREVIOUS day, but for the CURRENT (latest) day, got a flat line for both indicators.

This is a big improvement. Looks very promising. Thanks again.

Reply With Quote
The following user says Thank You to Zondor 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 05:46 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-11 in 0.16 seconds with 20 queries on phoenix via your IP 54.82.79.109