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


MACD, RSI, CCI indicators with different time frames, coding help?
Updated: Views / Replies:4,645 / 11
Created: by hector24 Attachments:2

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
 2  
 
Thread Tools Search this Thread
 

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

  #1 (permalink)
Elite Member
austin, texas
 
Futures Experience: Intermediate
Platform: ninja trader
Favorite Futures: currency futures
 
Posts: 508 since Jan 2011
Thanks: 14 given, 231 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
 
  #2 (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,352 given, 83,233 received

Already done, MTF anything here:

https://futures.io/elite-circle/24875-xavmtf-debugging-optimization-thread-multi-time-frame-indicator.html

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

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 03:36 AM.
Reply With Quote
 
  #4 (permalink)
Elite Member
austin, texas
 
Futures Experience: Intermediate
Platform: ninja trader
Favorite Futures: currency futures
 
Posts: 508 since Jan 2011
Thanks: 14 given, 231 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)
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,601 received
Forum Reputation: Legendary

Answer
This post has been selected as an answer to the original posters question Answer


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.

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

Reply With Quote
The following 4 users say Thank You to Fat Tails for this post:
 
  #6 (permalink)
Ninja
Rochester, NY, United States
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: 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)
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,601 received
Forum Reputation: Legendary


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)
Ninja
Rochester, NY, United States
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: 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 10:30 PM.
Reply With Quote
 
  #9 (permalink)
Trading Apprentice
Prague, Czech Republic
 
Futures Experience: Beginner
Platform: ninjarader
Favorite Futures: ES
 
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)
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,601 received
Forum Reputation: Legendary



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.

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

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

Reply



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

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
Coding Multi Time Frame (MTF) Indicators with NinjaTrader Fat Tails NinjaTrader 411 June 28th, 2016 08:34 AM
Time frames and charts spikoloco Traders Hideout 10 February 22nd, 2012 08:49 PM
ninja 7 info on multiple time frames for indicators jrs659 NinjaTrader 6 August 16th, 2011 02:16 PM
Installed indicators all end up looking like RSI indicators! Angelo1 NinjaTrader 4 July 15th, 2011 06:10 AM
JMA CCI, JMA MACD Indicators emini_Holy_Grail Traders Hideout 2 January 23rd, 2011 01:45 PM


All times are GMT -4. The time now is 06:33 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-14 in 0.16 seconds with 40 queries on phoenix via your IP 54.226.227.175