NexusFi: Find Your Edge


Home Menu

 





Coding Multi Time Frame (MTF) Indicators with NinjaTrader


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 180 posts (562 thanks)
    2. looks_two Zondor with 19 posts (29 thanks)
    3. looks_3 madLyfe with 16 posts (10 thanks)
    4. looks_4 BankRobberNT with 14 posts (16 thanks)
      Best Posters
    1. looks_one gomi with 3.7 thanks per post
    2. looks_two Fat Tails with 3.1 thanks per post
    3. looks_3 Zondor with 1.5 thanks per post
    4. looks_4 BankRobberNT with 1.1 thanks per post
    1. trending_up 186,647 views
    2. thumb_up 743 thanks given
    3. group 87 followers
    1. forum 424 posts
    2. attach_file 166 attachments




 
Search this Thread

Coding Multi Time Frame (MTF) Indicators with NinjaTrader

  #41 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Zondor View Post
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.

I have tested the indicator on tick charts by calling it from JMA with the settings period = 2 and 2 minutes and it works well. I currently cannot reproduce the flat line.

Could you eventually post a screenshot of the chart and the indicator settings and share the tick data you have tested it on?

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
Better Renko Gaps
The Elite Circle
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Build trailing stop for micro index(s)
Psychology and Money Management
 
  #42 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: NinjatraderŽ
Broker: CQG, Kinetick
Trading: Gameplay KlownbineŽ Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

My VisualEMAX was flat lining on Friday because I did not have any minute historical data for that particular day.

The historical data manager took care of that in short order, and now the VisualEMAX4 and indicators based on it are working fine when I use a low period VisualEMAX as a proxy for the price series in a different time frame.

This is an extremely valuable tool, giving insights into multiple time frames on a single chart.
It's one of the best new ideas in quite a while. Nice work, FT.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #43 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



Zondor View Post
My VisualEMAX was flat lining on Friday because I did not have any minute historical data for that particular day.

The historical data manager took care of that in short order, and now the VisualEMAX4 and indicators based on it are working fine when I use a low period VisualEMAX as a proxy for the price series in a different time frame.

This is an extremely valuable tool, giving insights into multiple time frames on a single chart.
It's one of the best new ideas in quite a while. Nice work, FT.

The innovation of the indicator is the intrapolation of datapoints for visual display. It takes into account both equidistant and non-equidistant spacing. If you use it just to be called from other indicators, the xcMovAvg, which is much simpler, should also do. It can be downloaded here:

Links and Downloads Manager - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Why would you take an obfuscated assembly, if a simple, open code indicator may suit your needs?

Started this thread Reply With Quote
Thanked by:
  #44 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

This is the fourth pre-version of the multi-timeframe version of the OpeningRange indicator. I have found two minor bugs, which affected the training period of the indicator (first trading day after CurrentBar == 0).

I am relatively sure that it does now, what it is expected to do.

The indicator is a great improvement, if you use tick, volume or range charts, as the opening range will be calculated from the secondary minute bar series. It will no more rely on the primary bars, which cannot exactly provide the required information, as they may overlap with the end of the opening range.

See an example below, where the opening range cannot be calculated from the primary bar series, but can be correctly displayed, if the multi-timeframe indicator is used.

Other applications of this concept include a high resolution VWAP for larger time frames, and modified SuperTrend and MultiPeriodCandle indicators.

Attached Thumbnails
Click image for larger version

Name:	TF 09-11 (12 Min)  11_06_2011.jpg
Views:	411
Size:	97.5 KB
ID:	40756  
Attached Files
Elite Membership required to download: OpeningRangeV34MTFX4.zip
Started this thread Reply With Quote
Thanked by:
  #45 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

There is quite a number of indicators, which access ChartControl in OnStartUp() or OnBarUpdate(). All these indicators
cannot be called by other indicators or strategies unless ChartControl is checked for null prior to being accessed.

With the help of NinjaTrader's support team, here is the correct way to check, whether a chart uses equidistant bars or not:

 
Code
bool equidistantbars = true;
if(ChartControl == null)
{ 
     // do something here
}
else if (ChartControl.EquidistantBars)
    equidistantBars = true;
else
    equidistantBars = false;
There is actually a number of indicators affected by this problem. If you check for the candle style of a chart, you also need to check for null first, otherwise the indicator will not run, when called by another indicator or a strategy! This is an example that I have frequently seen and used for paint bars.

 
Code
if(ChartControl == null)
{ 
   // do something here
}
else if (ChartControl.ChartStyleType == ChartStyleType.CandleStick)
{
   BarColor = Color.Transparent 
}
else
   BarColor = upColor;
All the indicators that use ChartControl without checking for null first need to be modified. This includes some of my own indicators such as the anaSuperTrend or the MACDdeLuxe2. Note that these indicators will work correctly, if applied to a chart, but they won't work (nor produce false results), if they are called.

Updated install file for VisualEMA is attached.

Attached Files
Elite Membership required to download: VisualEMAX5.zip
Started this thread Reply With Quote
  #46 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505

Here's my contribution : a class GomMultiTFIndicator you can derive from.
This class allows you to
  • Add another time series that will be sent to your indicator for calculations
  • Use only RTH (as defined in master instrument)
  • Reset your internal data on bar, daily, weekly, monthly, quarterly and annually

You will nee to define 4 methods
  • GomInitialize : replaces Initialize method
  • GomOnReset : is called on the beginning of each new bar/day/week etc.
  • GomOnData : this is where you receive the secondary time series data and update your internal objects
  • GomOnDataDone : data sent, update your indicators here.

Here is an example of code to get simple volume (included as demo in zip)

 
Code
                            
         protected override void GomInitialize()
        {
            
Add(new Plot(Color.FromKnownColor(KnownColor.RoyalBlue), PlotStyle.Bar"Vol"));
            
Overlay                false;
        }
        
        protected 
override void GomOnReset()
        {
            
vol=0;
        }
        
        protected 
override void GomOnData(double opendouble highdouble lowdouble closeint volume)
        {
            
vol+=volume;
        }
        
        protected 
override void GomOnDataDone()
        {
            
Vol.Set(vol);
        } 
And what you get :


Using RTH only :


All the indicators will inheritate these settings:

Attached Files
Elite Membership required to download: GomMultiTFIndicator1.0.zip
Reply With Quote
  #47 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


gomi View Post
Here's my contribution : a class GomMultiTFIndicator you can derive from.
This class allows you to
  • Add another time series that will be sent to your indicator for calculations
  • Use only RTH (as defined in master instrument)
  • Reset your internal data on bar, daily, weekly, monthly, quarterly and annually

You will nee to define 4 methods
  • GomInitialize : replaces Initialize method
  • GomOnReset : is called on the beginning of each new bar/day/week etc.
  • GomOnData : this is where you receive the secondary time series data and update your internal objects
  • GomOnDataDone : data sent, update your indicators here.


This looks fantastic! Will at least try to understand how it works and do some experiments.

Thank you.

Started this thread Reply With Quote
Thanked by:
  #48 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: NinjatraderŽ
Broker: CQG, Kinetick
Trading: Gameplay KlownbineŽ Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

Thanks Gomi, this is a wonderful contribution.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #49 (permalink)
 
kronie's Avatar
 kronie 
NYC + NY / USA
 
Experience: Advanced
Platform: "I trade, therefore, I AM!"; Theme Song: "Atomic Dog!"
Trading: EMD, 6J, ZB
Posts: 796 since Oct 2009


gomi View Post
Here's my contribution : a class GomMultiTFIndicator you can derive from.
This class allows you to
  • Add another time series that will be sent to your indicator for calculations
  • Use only RTH (as defined in master instrument)
  • Reset your internal data on bar, daily, weekly, monthly, quarterly and annually

You will nee to define 4 methods
  • GomInitialize : replaces Initialize method
  • GomOnReset : is called on the beginning of each new bar/day/week etc.
  • GomOnData : this is where you receive the secondary time series data and update your internal objects
  • GomOnDataDone : data sent, update your indicators here.

thanks, this really holds promise for having a unified chart instead of three charts linked to inverse contracts,

hopefully I will be able to show inverse relationships,
between contracts all on one chart,
and then only have two or three main charts,
instead of a 4plex (multi monitor) confusion of charts

Reply With Quote
  #50 (permalink)
 maxreturn 
Grand Rapids, Michigan, United States
 
Experience: Intermediate
Platform: NinjaTrader
Trading: TF, 6E
Posts: 319 since Dec 2010
Thanks Given: 264
Thanks Received: 114


A heartfelt THANKS to Fat Tails for his terrific work on MTF indicators. Also for the contributions of Zondor and others to help fine tune the indicators. I am only using VisualSMAX3 right now on the TF and it has made a dramatic improvement in my ability to read what's happening in the market and consequently, my bottom line. Thanks guys. HUGH ROCK!

Kindest Regards
Chuck

Reply With Quote




Last Updated on April 19, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts