NexusFi: Find Your Edge


Home Menu

 





EMA begin from chosen point in time


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one subterfuge with 3 posts (0 thanks)
    2. looks_two Fat Tails with 2 posts (4 thanks)
    3. looks_3 shodson with 1 posts (0 thanks)
    4. looks_4 Tasker_182 with 1 posts (0 thanks)
    1. trending_up 3,715 views
    2. thumb_up 6 thanks given
    3. group 6 followers
    1. forum 8 posts
    2. attach_file 1 attachments




 
Search this Thread

EMA begin from chosen point in time

  #1 (permalink)
 subterfuge 
uk
 
Experience: Intermediate
Platform: ninja
Broker: amp
Trading: ES
Posts: 179 since Aug 2009

Hi,

I have a feeling that my idea has already been done on here (but I can't seem to find it), so i'm hoping someone
can link me too it (assuming i'm correct)

I want a moving average indicator where I choose what bar the the indicator begins from.

So, if I was to take Fridays' CL chart, and decide I wanted my ema to begin from, 3pm, or 84 bars away, it
would look something like this:

cheers

Attached Thumbnails
Click image for larger version

Name:	emcl.jpg
Views:	204
Size:	73.5 KB
ID:	117997  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
 
  #2 (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,103


subterfuge View Post
Hi,

I have a feeling that my idea has already been done on here (but I can't seem to find it), so i'm hoping someone
can link me too it (assuming i'm correct)

I want a moving average indicator where I choose what bar the the indicator begins from.

So, if I was to take Fridays' CL chart, and decide I wanted my ema to begin from, 3pm, or 84 bars away, it
would look something like this:

cheers


@subterfuge: Funny you selected an EMA to start with. The EMA is an infinite impulse response (IIR) filter, and it is therefore influenced by all of its prior values. In general IIR filters have training periods during which they do not show accurate results. The EMA is an exception as it only uses its value one bar ago. You can therefore create a specific anchored EMA for any bar on your chart.

Your concept can be implemented, you can also use a volume-weighted EMA with a large period. This would create a MIDAS variation that lets drop out part of the old information.

If you wish to take the MIDAS idea and use it with other moving averages this is also possible, as long as you apply it to finite impulse response (FIR) filters. You can recognize a FIR filter, as it does not use any recursive formulae, or explained in a different way, it does not use any of its prior value in the calculation for the current values. The SMA is a FIR filter and your idea would promote it to a TWAP on a time-based chart.

Reply With Quote
Thanked by:
  #3 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709



subterfuge View Post
Hi,

I have a feeling that my idea has already been done on here (but I can't seem to find it), so i'm hoping someone
can link me too it (assuming i'm correct)

I want a moving average indicator where I choose what bar the the indicator begins from.

So, if I was to take Fridays' CL chart, and decide I wanted my ema to begin from, 3pm, or 84 bars away, it
would look something like this:

cheers

I'm not sure I quite understand what you're looking for.

In your example are you looking to plot an EMA with a period of 84, and only show the EMA starting from the first bar in the series? Or, is it an EMA with a period of X to start plotting Y bars back, where X does not equal Y? And, do you want the starting bar to be a certain number of bars back or based on a starting time, like 3pm?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (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,103


shodson View Post
I'm not sure I quite understand what you're looking for.

In your example are you looking to plot an EMA with a period of 84, and only show the EMA starting from the first bar in the series? Or, is it an EMA with a period of X to start plotting Y bars back, where X does not equal Y? And, do you want the starting bar to be a certain number of bars back or based on a starting time, like 3pm?


I have thought about that as well. There are in fact several options.

(1) The first one is to use a fixed period for the EMA. Let us take the example of an EMA(15).

You would start with the close of the anchor point (high bar or low bar) and then calculate the following values by using the smoothing constant alpha = 2/(n+1) = 1/8. For the anchor bar the EMA would show the close of the anchor bar, the second and all consecutive values can be calculated as 0.875*Close[1] + 0.125*Close[0]. After some time this EMA would converge to the regular EMA(15).

The inconvenience of this approach is that the outcome depends on the selected period. There is not one such EMA that can be constructed from a high point or low point, but there is a whole collection of EMAs that can be built by using this method.

(2) You could also use a second concept and increase the period of the EMA with each bar. If we take Wilder's smoothing we obtain alpha = 1/n. For the first value we would get the Close[0], for the second bar 1/2*(Close[0] + Close[1]), for the third bar 2/3 * 1/2 (Close[2] + Close[1]) + 1/3 * Close[0] = 1/3(Close[2] + Close[1] + Close[0]) etc. This would be in fact the same result that we get, if we use a SMA with an increasing period. Used on minute bars we obtain our anchored time-weighted average price (TWAP).

(3) If we do not use Wilder's smoothing, but use the habitual smoothing alpha = 2/(n+1), then the result would look slightly different. Starting again with Close[0]., the value for the second bar would be 1/3 * Close[1] + 2/3 * Close[0], the value for the third bar would be 1/6 * Close[2] + 1/3 * Close[1] + 1/2 * Close[0], the fourth bar 1/10 * Close[3] + 1/5 * Close[2] + 3/10 * Close[1] + 2/5 * Close[0] etc. This is an average that tracks price closer than the TWAP like moving average explained under (2).

However, the logic of the original MIDAS concept is more appealing to me, as it relies on the volume-weighted average price, which I think is a better choice as a benchmark than the simple TWAP or a fantasy EMA.

Reply With Quote
Thanked by:
  #5 (permalink)
 subterfuge 
uk
 
Experience: Intermediate
Platform: ninja
Broker: amp
Trading: ES
Posts: 179 since Aug 2009


shodson View Post
I'm not sure I quite understand what you're looking for.

In your example are you looking to plot an EMA with a period of 84, and only show the EMA starting from the first bar in the series?

No. Although I can see how my example might have made things more confusing!



shodson View Post

Or, is it an EMA with a period of X to start plotting Y bars back, where X does not equal Y? ?

Yes. I think that is what I am talking about. The period isn't that important. Ideally is would be customizable, but a 20 ema for example would be fine.



shodson View Post
And, do you want the starting bar to be a certain number of bars back or based on a starting time, like 3pm

I want to choose what bar I want as the starting bar. It would be different every day.
It's almost like drawing a trendline. I want to look back at the chart and pick out a bar to begin my 'ema line'.

Hopefully that makes more sense.

Started this thread Reply With Quote
  #6 (permalink)
 subterfuge 
uk
 
Experience: Intermediate
Platform: ninja
Broker: amp
Trading: ES
Posts: 179 since Aug 2009


subterfuge View Post

Hopefully that makes more sense.

I guess that didn't make more sense then, lol.

Started this thread Reply With Quote
  #7 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401


subterfuge View Post
I guess that didn't make more sense then, lol.


In your example of a 20 ema there are two questions:

1) Are you saying you want to start calculating the 20 period ema beginning with a bar you specify (Understanding that it would not actually plot until 20 bars later)?

2) Or do you want the 20 ema to be plotted starting on a bar you specify (understanding that the 20 ema would actually begin calculating 20 bars before that point)?

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
  #8 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,460 since Jun 2009
Thanks Given: 33,235
Thanks Received: 101,655

Look at this thread:



@Fat Tails has coded gapless indicators and shown how to reset the MA at the start of a session, you could apply this to any method you wish.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
sixteencorners
Nantes France
 
Posts: 2 since Dec 2016
Thanks Given: 1
Thanks Received: 0

Hello @subterfuge

I am searching for this exact same indicator.
I will have a look at what Fat tails has coded.

Reply With Quote




Last Updated on December 8, 2016


© 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