(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.

I want to calculate a SMA and standard deviation for an indicator that has some empty values which I believe will skew the results. For example, if I calculate a SMA on a 100 data points where 25% are empty values, that will obviously skew my mean downwards. That is, it would be lower than if it was calculating the SMA of the other 75 data points which is what Im hoping to do. Same goes for the StDev.

Is there a way to exclude these empty values from the SMA and StDev calculations?

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

Either there is no bar. In that case the SMA is calculated from the data points as you wish.

Or there are bars that show the same value as the prior bar, because there was no incoming tick. In that case the SMA is calculated from the regular bars and those inserted bars.

Sorry if my expression "empty value" didnt make sense. What I meant is when an indicator shows N/A in the Data box.

I wish there was a way to omit those when calculating SMA and StDev so that they are calculated on those 75 values in my example in my previous post instead of calculating the whole 100 values and including those N/A.

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

The following user says Thank You to tonycashflow for this post:

You are not looking at a "SMA" when you are eliminating data as by definition you are taking the closing prices at the end of an interval summing them and dividing the number by the total number of intervals to arrive at a SIMPLE Moving Average.

Whether the interval is traded or not, the interval has a value as far as the chart is concerned.

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

Consider the above chart of a lightly traded stock. The each interval is 5 minute so the 20 SMA (total of 100minutes of data) as you can see is smooth and calculated from the closing price and when there is no volume the closing price is the same as the previous close.

So....if you want to calculate "empty" cells then you would eliminate all 5 min data points that have a zero volume over the 100 minutes, keeping track of the number of positive volume numbers to arrive at your average of the sum of positive volume prices.

But I fail to see how this has any meaning in reality.

You would be treating prices where the volume was in the range > 20,000 shares (eg. latter half of the second PM hour of the first day) the same as weight as data with very low data < 1000 shares ( the two 5 min intervals in the following day between 2:00pm - 3:00pm

So as I see it you could use all price data and multiplying it by volume (thereby eliminating zero volume intervals) and then adding the results and dividing by the total intervals in the average period. I suppose this would have some relevance.

But to cherry pick data without zero volumes does not make much sense to me, when as little as 1 share traded would be considered the same significance as say 10,000 shares.

At least the SMA which is calculated without reference to volume has a consistency to its interpretation.

Edit: I guess my example is not the same as yours as I only deal in share prices but the thoughts behind my discussion probably still applies in your case as well. If not, Just ignore me

Last edited by Underexposed; June 23rd, 2014 at 09:45 AM.

The following user says Thank You to Underexposed for this post:

Underxposed, thanks for your answer and I understand that, but it doesnt really apply. All I am trying to do is calculating the average and SD of the indicator when its not N/A.

I thought of using an array and then calculating the Avg and SD on that array. How would I calculate those on an array?

Thanks

Last edited by tonycashflow; June 23rd, 2014 at 11:04 AM.

Sorry, I should check what folder I am in before answering.

I have done a fair bit of programming in my working life but I don't do the type of trading you do and certainly don't use NinjaTrader so my comments on what you are attempting may be off base here.

then you would write some kind of script where you would test "P" to see if it would be NULL and ignore "I" otherwise add "I" to an accumulator and increment a counter by one...then at the end of the "SMA" (it is not really a SMA as it is not simple anymore) make your division.

Actually in practise I suppose you would just consider the the first number of the addition array and the next number

Let us say you are doing a 5"SMA"....then you would compute the first sma on I1 to I5 as I described above... for the second SMA you would have to check out P1 to see if it was a valid number (ie. you then have used I1 in the calculation)

if P1 were " null" then you would not subtract I1 from the accumulator as it was not used in the calculation and leave the counter unchanged

if P1 was "non-null" then I1 would be subtracted from the accumulator and the counter decreased by one

From the result of the above "IF" statements...

Then you would perform an inspection on P6...

if P6 was "null" the "SMA" would be simply the division of the adjusted accumulator value by the adjusted counter value...as you would ignore I6

if P6 was "non-null" then you would add I6 to the accumulator and increment the counter by one and perform the division

then you loop back and continue a similar analysis with rest of the data.

This is in general what I would do...handicapped by not knowing the script language and the data

That is the limit to what I can suggest...hope it helps

Maybe your indicator should hold a value instead of holding nothing. I guess that it is badly coded.

What is the purpose of that indicator?

Alternatively you may want to code a new SMA that first builds a secondary array from the input values by omitting those price bars that do not contain any values.