MACD, RSI, CCI indicators with different time frames, coding help? - futures io
futures io futures trading



MACD, RSI, CCI indicators with different time frames, coding help?


Discussion in NinjaTrader

Updated by Fulgor
      Top Posters
    1. looks_one Fat Tails with 3 posts (6 thanks)
    2. looks_two SirNicolaus with 2 posts (0 thanks)
    3. looks_3 hector24 with 2 posts (1 thanks)
    4. looks_4 viktor17 with 2 posts (0 thanks)
    1. trending_up 6,124 views
    2. thumb_up 7 thanks given
    3. group 6 followers
    1. forum 11 replies
    2. attach_file 2 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

(If you already have an account, login at the top of the page)

 
Thread Tools Search this Thread
 

MACD, RSI, CCI indicators with different time frames, coding help?

  #1 (permalink)
austin, texas
 
Experience: Intermediate
Platform: ninja trader
Trading: currency futures
 
Posts: 503 since Jan 2011
Thanks: 14 given, 233 received

MACD, RSI, CCI indicators with different time frames, coding help?

I was wondering if anyone knows how to code something that could be beneficial to everyone. Currently there is an indicator called Visual EMA and one called Visual SMA. These indicators allow you to see the moving averages of another time frame on the same chart that you have up. Example if you have a 5 minute chart up you can apply one these indicators to get a moving average from a 15 minute chart. I was thinking that maybe someone could code the same concept but have parameters that would let you choose another indicator like a MACD, RSI, CCI or the like. So you could have a 15 minute RSI on your 5 minute chart. Just wondering if this can be done. If anyone could help, it would be appreciated.

Reply With Quote

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
ThinkOrSwim
Moving average with Lag reduction
NinjaTrader
Linux?
ThinkOrSwim
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Spoo-nalysis ES e-mini futures S&P 500
400 thanks
VWAP for stock index futures trading?
47 thanks
Want your NinjaTrader indicator created, free?
46 thanks
Is Amp at risk of going under?
26 thanks
What is your single biggest weakness?
25 thanks
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 48,718 since Jun 2009
Thanks: 31,454 given, 93,974 received

Already done, MTF anything here:



Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
 
  #3 (permalink)
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,346 since Jul 2009
Thanks: 1,245 given, 2,713 received

Idea for using 1 period VSMA to feed indicators


Using a 1 period VISUAL SMA in the desired higher time frame as the input of your RSI or whatever DOES NOT seem to work.

I think you would need to call the methods of the AccessVisualSMA indicator from within the RSI etc. Maybe I will fool around with that at some point.

"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
“Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014
“The greatest shortcoming of the human race is our inability to understand the exponential function.”
Prof. Albert Bartlett

Last edited by Zondor; January 7th, 2013 at 02:36 AM.
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
  #4 (permalink)
austin, texas
 
Experience: Intermediate
Platform: ninja trader
Trading: currency futures
 
Posts: 503 since Jan 2011
Thanks: 14 given, 233 received

Multiple

Thanks Mike but that does not have the selection parameters that I was thinking about. But thanks anyways.
Zondor thanks I will look into that.

Thanks,
Hector

Reply With Quote
The following user says Thank You to hector24 for this post:
 
  #5 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,824 since Mar 2010
Thanks: 4,237 given, 26,521 received


Zondor View Post
Using a 1 period VISUAL SMA in the desired higher time frame as the input of your RSI or whatever DOES NOT seem to work.

I think you would need to call the methods of the AccessVisualSMA indicator from within the RSI etc. Maybe I will fool around with that at some point.

@Zondor: The VisualSMA repaints back to the last node, if it used in Visual mode. The number of bars that it repaints are exposed, so you can access it via an access indicator. In One-Tick-Correction mode, it repaints 1 bar, in strategy mode it does not repaint at all, which leads to a lag of one bar and does not allow for visual interpolation.

Let us remind that MTF indicators are only needed to avoid non-equidistant bar spacing. Otherwise you can add a transparent secondary bar series to your chart and use it for calculating indicator values.

If you want to avoid non-equidistant bar spacing, there are three paths that lead to the desired outcome:

(1) a multi-timeframe indicator that loads a secondary bar series (type XavMTF or VisualSMA)
(2) a multi-timeframe indicator that first calculates composite bars from N consecutive bars and then calculates the indicator values for those composite bars
(3) directly tweaking the formula

Let us for example take a MACD. The chart below shows a 5 min chart with the MACD calculated for 5 min bars (1x Cornflower), 15 min bars (3x white), 30 min bars (6x, orange), 60 min bars (12x violet red). The MACDs on the midpanel are calculated from composite bars - as MetaTrader does. The MACDs on the lower panel is built from tweaked moving averages. The tweaking was obtained by replacing the period N_old of the EMA for a timeframe multiplier M with the period N_new

k_old = 2/(N_old + 1)
k_new = 1 - Power(1 - k_old, 1/M)
N_new = 2/k_New - 1

You can tweak the formulae of many indicators, the period can be calculated in OnStartUp(), therefore the tweaked indicator is faster to calculate than the one built from composite bars. None of them is a genuine MTF indicator, but they can be used for the same purpose. And both of them can be easily used as a trendfilter in a strategy.


Reply With Quote
The following 4 users say Thank You to Fat Tails for this post:
 
  #6 (permalink)
Rochester, NY, United States
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 6 since Dec 2012
Thanks: 8 given, 0 received

Averages

Is there an easy way to take for example a MACD plot from mutliple MACDs and average them into 1 plot then smooth em and post them to the chart as an ema??

example

Fast1 = 1
Slow1 = 4
Smooth1 = 8

Take the plot of the MACD = macd0

Fast2 = 4
Slow2 = 8
Smooth2 = 8

Take plot from macd = int macd1

etc take 4 plots then average them into 1 int output as EMA in an indicator?

Is this doable?

Thanks guys

This is my first post... so if i am in the wrong place just let me know... thanks

Reply With Quote
 
  #7 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,824 since Mar 2010
Thanks: 4,237 given, 26,521 received


SirNicolaus View Post
Is there an easy way to take for example a MACD plot from mutliple MACDs and average them into 1 plot then smooth em and post them to the chart as an ema??

example

Fast1 = 1
Slow1 = 4
Smooth1 = 8

Take the plot of the MACD = macd0

Fast2 = 4
Slow2 = 8
Smooth2 = 8

Take plot from macd = int macd1

etc take 4 plots then average them into 1 int output as EMA in an indicator?

Is this doable?

Thanks guys

This is my first post... so if i am in the wrong place just let me know... thanks

@SirNicolaus: The MACD is an oscillator. You cannot average an oscillator into EMAs.

Also, I doubt that if you take a collection of EMAs and calculate the average of those EMAs that you will get a better EMA.

And then the EMA will only tell you what happened in the past. It is a bad predictor. For details see that book by David Aronson : Evidence Based Technical Analysis.

Reply With Quote
The following user says Thank You to Fat Tails for this post:
 
  #8 (permalink)
Rochester, NY, United States
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
 
Posts: 6 since Dec 2012
Thanks: 8 given, 0 received


Fat Tails View Post
@SirNicolaus: The MACD is an oscillator. You cannot average an oscillator into EMAs.

Also, I doubt that if you take a collection of EMAs and calculate the average of those EMAs that you will get a better EMA.

And then the EMA will only tell you what happened in the past. It is a bad predictor. For details see that book by David Aronson : Evidence Based Technical Analysis.

well i know when i put 4 MACD on a chart and only show the macd plot i can see it trending and was hoping to combine and average those macd plots into 1 plot... if the plot is a ma EMA HMA i don't care i just want the visual movement and or bar painting

i am looking for divergence across multiple macds but less clutter

Thanks for the Recommended book i will look into it...


Last edited by SirNicolaus; January 22nd, 2013 at 09:30 PM.
Reply With Quote
 
  #9 (permalink)
Prague, Czech Republic
 
 
Posts: 2 since Feb 2015
Thanks: 1 given, 0 received

Hi Fat Tails,

I was trying to modify/tweak MACD indicator based on your formula, but I'm not able to find out what is 'k_old' and 'n_old'. I was trying to change MACD indicator directly from ninjatrader 7. Can you please help me what to exactly change (I'm primary using 5min ES and I want to access MACD of 15min ES) or can you please send me source code of indicator which generated your picture (with tweaked) MACDs?

I can't submit post with links(your image submitted in your post January 7th, 2013 11:39 PM) , because of forum rules - this is my the first post.

Thank you
viktor


Fat Tails View Post
@Zondor: The VisualSMA repaints back to the last node, if it used in Visual mode. The number of bars that it repaints are exposed, so you can access it via an access indicator. In One-Tick-Correction mode, it repaints 1 bar, in strategy mode it does not repaint at all, which leads to a lag of one bar and does not allow for visual interpolation.

Let us remind that MTF indicators are only needed to avoid non-equidistant bar spacing. Otherwise you can add a transparent secondary bar series to your chart and use it for calculating indicator values.

If you want to avoid non-equidistant bar spacing, there are three paths that lead to the desired outcome:

(1) a multi-timeframe indicator that loads a secondary bar series (type XavMTF or VisualSMA)
(2) a multi-timeframe indicator that first calculates composite bars from N consecutive bars and then calculates the indicator values for those composite bars
(3) directly tweaking the formula

Let us for example take a MACD. The chart below shows a 5 min chart with the MACD calculated for 5 min bars (1x Cornflower), 15 min bars (3x white), 30 min bars (6x, orange), 60 min bars (12x violet red). The MACDs on the midpanel are calculated from composite bars - as MetaTrader does. The MACDs on the lower panel is built from tweaked moving averages. The tweaking was obtained by replacing the period N_old of the EMA for a timeframe multiplier M with the period N_new

k_old = 2/(N_old + 1)
k_new = 1 - Power(1 - k_old, 1/M)
N_new = 2/k_New - 1

You can tweak the formulae of many indicators, the period can be calculated in OnStartUp(), therefore the tweaked indicator is faster to calculate than the one built from composite bars. None of them is a genuine MTF indicator, but they can be used for the same purpose. And both of them can be easily used as a trendfilter in a strategy.


Reply With Quote
 
  #10 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,824 since Mar 2010
Thanks: 4,237 given, 26,521 received



viktor17 View Post
Hi Fat Tails,

I was trying to modify/tweak MACD indicator based on your formula, but I'm not able to find out what is 'k_old' and 'n_old'. I was trying to change MACD indicator directly from ninjatrader 7. Can you please help me what to exactly change (I'm primary using 5min ES and I want to access MACD of 15min ES) or can you please send me source code of indicator which generated your picture (with tweaked) MACDs?

I can't submit post with links(your image submitted in your post January 7th, 2013 11:39 PM) , because of forum rules - this is my the first post.

Thank you
viktor


Maybe that my description was not very clear. I will take your example. You wish to access a MACD calculated from a 15 min chart on a 5 min chart. This means that there is a timeframe multiplier of M = 3. The MACD is basically built from two exponential moving averages. The signal line itself is an exponential moving average of the MACD. As we know, exponential moving averages use a smoothing constant of

k = 2/(1+n)

where n is the period of the moving average. It is also possible to use a smoothing constant of k= 1/n. This was the solution adopted by Welles Wilder and is known as Wilder's Average. The now prevailing formula of k= 2/(1+n) was chosen by Jack Hutson (see Stocks & Commodities, Volume 2, Issue March 1984) to harmoize the average age of data for simple and exponential moving averages. The coefficient k is used to calculate the current value of the exponential moving average via a recursive formula

(1) ...... EMA[0] = k*Close[0] + (1-k)*EMA[1]

where EMA[0] is the current value of the moving average and EMA[1] is the previous value of the moving average. Now let us come back to the task to calculate an EMA from the 15 min bars. In this case you would need to take every third bar to perform the calculations

(2) ...... EMA[0] = k*Close[0] + (1-k)*EMA[3]

Now I look for an appropriate q to replace (2) with (1):

(3) ...... EMA[0] = q*Close[0]+(1-q)*EMA[1] = q*Close[0]+(1-q)*q*Close[1]+(1-q)*(1-q)*EMA[2] = q*Close[0]+(1-q)*q*Close[1]+(1-q)*(1-q)*q*Close[2]+(1-q)*(1-q)*(1-q)*EMA[3]

The 15 minute chart does not have the resolution of the 5 min chart, hence I replace Close[1] and Close[2] with Close[0]. However, I am mostly interested in the last term (1-q)*(1-q)*(1-q)*EMA[3], because this term tells me to what extent prior price action is taken into account. Therefore to obtain the 5 min smoothing constant q from my 15 min smoothing constant k, it is necessary that

(4) ...... (1-q)*(1-q)*(1-q) = 1 - k -> q = 1 - Math.Pow(1-k, 1/3)


This is the equation that allows me to obtain the smoothing constant required to display the 15-min EMA on a 5-min chart. Now let us take a MACD(12,26,9) on a 15 min chart. We wish to display this MACD on a 5-min chart.

The smoothing constants for the EMAs are

k1 = 2 /(12 +1) = 2/13 = 0.1538
k2 = 2/(26 +1) = 2/27 = 0.0741
k3 = 2/(9 +1) = 2/10 = 0.2000

By applying the formula above we can now calculate the smoothing constants required for displaying that same EMA on a 5-min chart

q1 = 1 - Math.Pow(1-0.1538, 1/3) = 1 - 0.9458 = 0.0542
q2 = 1 - Math.Pow(1-0.0741, 1/3) = 1 - 0.9747 = 0.0253
q3 = 1 - Math.Pow(1-0.2000, 1/3) = 1 - 0.9283 = 0.0717

q1, q2 and q3 are the three smoothing constants which you need to use to calculate the 3 exponential moving averages. With q = 2/(n+1) you may also calculate the periods as n = 2/q - 1

n1 = 2/0.0542 - 1 = 35.90
n2 = 2/0.0253 - 1 = 78.05
n3 = 2/0.0717 - 1 = 26.89

The solution of the puzzle is that you can approximate your MACD (12,26,9) calculated from 15 min bars with a MACD(35.90, 78.05, 26.89) calculated from a 5 min chart. Please note that broken (non-integer) periods are allowed for exponential moving averages, but that the default EMA/MACD do not support them.

Now let us compare the outcome. The chart below has loaded a secondary bar series of 15-min bars which I have set to transparent. You will find the tweaked (high definition) MACD calculated from 5 minute data and below the original MACD calculated from 15 min data. As you can see, the tweaked version is an excellent approximation of the original MACD and is fit for all practical purposes.


Reply With Quote
The following user says Thank You to Fat Tails for this post:



futures io Trading Community Platforms and Indicators NinjaTrader > MACD, RSI, CCI indicators with different time frames, coding help?




Upcoming Webinars and Events
 

Bookmap

May 28
     



Copyright © 2020 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