StockFetcher Forums · General Discussion · I need to exclude last day's data from CMA function<< >>Post Follow-up
Underworlds
30 posts
msg #90472
Ignore Underworlds
3/27/2010 6:28:10 PM

I am trying to calculate the average body height of candlesticks over the past 45 days using the CMA() function, as follows...

set{avgbodyheight,CMA(close,45) - CMA(open,45)}

The problem I am having is that the CMA() function includes the data from the most recent candlestick, which I need to exclude from the average.

Does anyone here know a trick or two that I might be able to use to exclude the last day's data from the CMA() function?

Thanx

four
5,087 posts
msg #90474
Ignore four
3/27/2010 7:03:09 PM

Fetcher[
set{avgbodyheight, CMA(close,45) - CMA(open,45)}
add column avgbodyheight

set{subtract, cma(close,1) - cma(open,1)}
add column subtract

set{result, avgbodyheight - subtract}
add column result
]



Kevin_in_GA
4,599 posts
msg #90475
Ignore Kevin_in_GA
3/27/2010 7:58:28 PM

just add 1 day ago to the end of the function ...

Underworlds
30 posts
msg #90476
Ignore Underworlds
3/27/2010 8:00:44 PM

four - Thanx for the effort, but I don't see how your solution shifts the range back by one day.

While I was waiting for help, I think I figured out a more direct solution to the problem by simply reversing the averaging process.

Fetcher[/* Get the average of the past 45 days */
set{var1,CMA(high,45) - CMA(low,45)}
/* Multiply by 45 to have the sum of the body heights */
set{var2,var1 * 45}
/* Get the height of the current day */
set{var3,high - low}
/* Get the height of the day 1 day past the 45 day range */
set{var4,high 46 days ago - low 46 days ago}
/* Subtract the current day's height from the sum */
set{var5,var2 - var3}
/* Add the height from 1 day previous to the range */
set{var6,var5 + var4}
/* Divide by 45 to convert back into an average */
set{avgbodyheight,var6 / 45}
add column avgbodyheight
]



Underworlds
30 posts
msg #90489
Ignore Underworlds
3/28/2010 1:57:26 AM

Thanx for all the help, guys. I am new to StockFetcher, and at candlesticks in general. To help familiarize myself with the different types of candlesticks, I have been writing code to help me select candlesticks based on their relative sizes with the preceding candlesticks in the charts.

I know that this may seem very elementary to many of the older members of this site, but it has already taught me a lot more about charts than I knew before I started.

The only candlestick code that I have left to write is for the High Wave. Once that bit of code is complete, I plan on expanding on my candlestick code to identify the various patterns.

I know... many of the patterns are already built into StockFetcher. Still, its a learning experience.

StockFetcher Forums · General Discussion · I need to exclude last day's data from CMA function<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.