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,462 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

  #91 (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


maxreturn View Post
Hello Fat Tails. As you know by now I use a 12 tick SBS Renko chart for longer term analysis and a 6 tick SBS Renko chart for timing the entry. One of the most useful indicators I've found for help in timing entry is the Swing Ray2 indicator (see attached) which does a terrific job of highlighting important price pivot support and resistance levels.

What I thought would be useful is to modify this indicator so that when setting up the indi on the 6 tick chart; both the rays from the 6 tick chart and 12 tick chart would print on the 6 tick chart. The lines derived from the 12 tick chart could be made thicker to indicate stronger support and resistance. Your thoughts?

Best Regards
Chuck

Several things come to my mind here:

(1) The SBS Renko bars are somewhat flawed. My multitimeframe indicators work with NinjaTrader default Renko bars and they also work with BetterRenko charts, but they cannot use SBS Renko.

(2) If you want to have the rays printed from a (genuine) 6 tick and a 12 tick chart, this is pretty easy. You do not need to code anything. If the ray strength is 5, just apply the indicator a second time with ray strength of 10. A ray strength of 10 on a 6-tick chart is equivalent to a ray strength of 5 on a 12-tick chart.

(3) The above logic holds true for minute, tick and volume charts, but not for range or Renko charts. If you want to display the rays of a 12-SBS-renko chart on a 6-SBS-Renko, you can use the square of the ray strength selected for the 12-SBS-Renko chart to derive it from the 6-SBS-Renko. This is not an exact but an approximative value.

Example: You wish to display rays with a trend strength of 5 derived from 12-SBS-Renko. So you would enter a ray strength of 5 * 5 = 25 into your 6-SBS-Renko indicator, and it should display what you look for.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Are there any eval firms that allow you to sink to your …
Traders Hideout
Futures True Range Report
The Elite Circle
Deepmoney LLM
Elite Quantitative GenAI/LLM
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #92 (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


davidfa View Post
Hello guys,
I am working on an indicator that would paint minute based bars on top of a range chart. Would also work for other combinations, but that is basically the need.
The idea is similar to @ Fat Tails anaMultiPeriodCandles from where I got the plot logic.

The problem I am facing is to put the added second data series as a minute amount parameter as NT logic needs that value in the Initialize proc and it seems doesn't allow that as a parameter.

As I downloaded and had a glance to @ gomi GomMultiTFIndicator, I realise that would be a nice workaround. Is there any indicator using this so as I can have it a as a sample implementation?

The code under development and image attached correspond to a version with fixed (no parameter) 5 minute bars as added dataseries.

Thanks for your work.
David

You could for example try to declare a variable thisPeriodValue and use it as shown below:

 
Code
#region Variables
        private int  thisPeriodValue = 5;
.......
#endregion
protected override void Initialize()
{
               Add(PeriodType.Minute, thisPeriodValue);
.......
}
Then add a property ThisPeriodValue to allow for values different from 5.

Started this thread Reply With Quote
  #93 (permalink)
 
perryg's Avatar
 perryg 
Rechovot
 
Experience: Advanced
Platform: NinjaTrader
Broker: CQG
Trading: Index,Currency and Energy futures
Posts: 1,644 since Jan 2010
Thanks Given: 508
Thanks Received: 6,288


Hello @Fat Tails,

Is it possible to have a version of the VisualSMA or VisualEMA as a LinReg version. So far I have been using both very successfully.

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


perryg View Post
Hello @ Fat Tails,

Is it possible to have a version of the VisualSMA or VisualEMA as a LinReg version. So far I have been using both very successfully.

What do you call a LinReg Version? Do you mean a LinReg instead of a moving average?

Started this thread Reply With Quote
  #95 (permalink)
 
perryg's Avatar
 perryg 
Rechovot
 
Experience: Advanced
Platform: NinjaTrader
Broker: CQG
Trading: Index,Currency and Energy futures
Posts: 1,644 since Jan 2010
Thanks Given: 508
Thanks Received: 6,288


Fat Tails View Post
What do you call a LinReg Version? Do you mean a LinReg instead of a moving average?

A LinReg Moving Average. At the moment we have an EMA and SMA moving average, and I would like to see also a LinReg moving average

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


perryg View Post
A LinReg Moving Average. At the moment we have an EMA and SMA moving average, and I would like to see also a LinReg moving average

I have not coded it so far. That said it can be done.

Started this thread Reply With Quote
Thanked by:
  #97 (permalink)
 
davidfa's Avatar
 davidfa 
Barcelona / Spain
 
Experience: Intermediate
Platform: NT
Broker: ZenFire
Trading: CL
Posts: 118 since Feb 2010
Thanks Given: 366
Thanks Received: 148


Fat Tails View Post
You could for example try to declare a variable thisPeriodValue and use it as shown below:
.......
}[/CODE]Then add a property ThisPeriodValue to allow for values different from 5.

Ooops!
in a single test with that code had bad results and just asked too quickly before giving it another try.
Thank you @Fat Tails very much.

Visit my NexusFi Trade Journal Reply With Quote
  #98 (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

I have looked for a way to code "false" multi-timeframe indicators from a single bar series. This has both advantages and inconvenients compared to real multi- timeframe indicators.

Advantage: Only loading 1 bar series, faster loading and calculation, robustness.

Inconvenient: The concept is limited to the same bar type, you cannot create range bars from minute bars, you only can create integer multiples of minute bars. The implementation uses artificial composite bars which are stocked in expandable ArrayList obejcts. These are the possible implementation.

(1) Replicating the higher timeframe indicator values. Below you will see the 25 min MACD calculated from a 5 min bar series. The Default mode reshapes the original NinjaTrader MACD as shown on a 25 minute chart. This requires repainting within the last unstable period of the composite bar. This makes the replication of the 25 min MACD less attractive for strategy applications.

(2) Raw mode shows the indicator values as calculated on a rolling basis without smoothing. The raw mode is useful, it the indicator values are accessed by another indicator or strategy, as it does not repaint.

(3) For use as a visual indicator with a slightly higher resolution than the original 25 min MACD, the raw values can be smoothed over the composite bar. This visual indicator does not repaint either, the smoothing introduces a small acceptable lag.

(4) The higher timeframe values can also be shown as a step function, which reflects the values as generated by the composite bars. The step function repaints 1 tick at the session end, as the session end is often charaterized by an odd period, which can not be predicted from the multplier used to generate the composite bars.

Chart attached for illustration: The concept can be applied to any indicator.


Started this thread Reply With Quote
  #99 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,171
Thanks Received: 6,018

What is the difference between using a 5 x 5minutes and using a normal MACD with 12x5, 26x5, 9x5 periods ?

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



trendisyourfriend View Post
What is the difference between using a 5 x 5minutes and using a normal MACD with 12x5, 26x5, 9x5 periods ?

Your idea would work for a simple moving average. A 60-period SMA on a 1 min chart, would come quite close to a 12-period SMA on a 5 minute chart. Please see chart 1 below for comparison.

However, a 60-minute EMA on a 1 minute chart is already a little bit different from a 12-period EMA on a 5 minute chart, because of the recursive formula. See chart 2 below.

Attached Thumbnails
Click image for larger version

Name:	Chart 1.jpg
Views:	247
Size:	87.7 KB
ID:	45952   Click image for larger version

Name:	Chart 2.jpg
Views:	231
Size:	86.5 KB
ID:	45954  
Started this thread 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