Exclude empty values for calculations - NinjaTrader Programming | futures io social day trading
futures io futures trading


Exclude empty values for calculations
Updated: Views / Replies:417 / 7
Created: by tonycashflow 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
 
Thread Tools Search this Thread
 

Exclude empty values for calculations

  #1 (permalink)
Elite Member
Montreal Qc/Canada
 
Futures Experience: Intermediate
Platform: MT4 and others
Favorite Futures: ES, Forex
 
Posts: 4 since May 2012
Thanks: 6 given, 1 received

Exclude empty values for calculations

Hi,

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?

Thnaks

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

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.

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



tonycashflow View Post
Hi,

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?

Thnaks

What do you call an empty value?

Such thing does not exist.

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.

Reply With Quote
 
  #4 (permalink)
Elite Member
Montreal Qc/Canada
 
Futures Experience: Intermediate
Platform: MT4 and others
Favorite Futures: ES, Forex
 
Posts: 4 since May 2012
Thanks: 6 given, 1 received


Fat Tails View Post
What do you call an empty value?

Such thing does not exist.

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

Reply With Quote
The following user says Thank You to tonycashflow for this post:
 
  #5 (permalink)
Membership Temporarily Revoked
Calgary Alberta/Canada
 
Futures Experience: Advanced
Platform: TDWaterhouse
Favorite Futures: stocks (long term)
 
Posts: 934 since Feb 2014
Thanks: 180 given, 777 received

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.
Reply With Quote
The following user says Thank You to Underexposed for this post:
 
  #6 (permalink)
Elite Member
Montreal Qc/Canada
 
Futures Experience: Intermediate
Platform: MT4 and others
Favorite Futures: ES, Forex
 
Posts: 4 since May 2012
Thanks: 6 given, 1 received

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.
Reply With Quote
 
  #7 (permalink)
Membership Temporarily Revoked
Calgary Alberta/Canada
 
Futures Experience: Advanced
Platform: TDWaterhouse
Favorite Futures: stocks (long term)
 
Posts: 934 since Feb 2014
Thanks: 180 given, 777 received


tonycashflow View 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 calculated those on an array?

Thanks

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.

What type of array are you considering?

is it something like

Time interval: ................................................. T1.... T2... T3.... T4.... T5... T6
Indicator: ....................................................... I1 .... I2 .. I3 ... I4 .... I5... I6
Parameter (eg. volume or equivalent) ........... P1 .... P2 . P3 ... P4 ... P5... P6

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

Reply With Quote
 
  #8 (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


tonycashflow View Post
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).


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.

Reply With Quote

Reply



futures io > > > > > Exclude empty values for calculations

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
Chart Values/Tool Values Window is missing Big Mike Sierra Chart 17 August 24th, 2012 08:05 PM
UpTick/Downtick Calculations clement EasyLanguage Programming 3 January 13th, 2012 02:14 AM
Pivot Point calculations trendisyourfriend Investor/RT 11 May 2nd, 2011 07:50 PM
Slippage Calculations for Optimization benharrell Traders Hideout 7 December 20th, 2010 04:53 AM
Translating EMA-values to ZN-values or visaversa max-td NinjaTrader Programming 17 June 22nd, 2009 04:42 PM


All times are GMT -4. The time now is 04:40 AM.

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-15 in 0.13 seconds with 20 queries on phoenix via your IP 54.234.255.29