NexusFi: Find Your Edge


Home Menu

 





mean absolute deviation formula


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one raker with 2 posts (0 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 BobF with 1 posts (0 thanks)
    4. looks_4 sptrader with 1 posts (0 thanks)
    1. trending_up 3,262 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

mean absolute deviation formula

  #1 (permalink)
raker
Birmingham , United Kingdom
 
Posts: 2 since Dec 2013
Thanks Given: 0
Thanks Received: 0

Hi there ,

New to this forumn I am looking for formula /code for the mean absolute deviation not a fixed parameter one but a variable period like what vwap is , a variable period volume weighted average . I have already written and done a formula for a variable period standard deviation because there are a couple of alternate formulas to produce the same result . But the mean absolute is proving rather difficult . The formula itself is fairly straight forward but it is proving difficult to code . I do not have a lot of experience in languages , the platform I use is Neoticker and the language they use is called "formula language" . Any help would be appreciated.

THx

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #3 (permalink)
 
sptrader's Avatar
 sptrader 
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
Posts: 535 since Apr 2010
Thanks Given: 1,097
Thanks Received: 701



raker View Post
Hi there ,

New to this forumn I am looking for formula /code for the mean absolute deviation not a fixed parameter one but a variable period like what vwap is , a variable period volume weighted average . I have already written and done a formula for a variable period standard deviation because there are a couple of alternate formulas to produce the same result . But the mean absolute is proving rather difficult . The formula itself is fairly straight forward but it is proving difficult to code . I do not have a lot of experience in languages , the platform I use is Neoticker and the language they use is called "formula language" . Any help would be appreciated.

THx

***************************************************************************
You said: "The formula itself is fairly straight forward", could you post the formula, and maybe we can help..

Reply With Quote
  #4 (permalink)
raker
Birmingham , United Kingdom
 
Posts: 2 since Dec 2013
Thanks Given: 0
Thanks Received: 0

the formula is just taking the average distance away from the mean e.g. ;

take the following numbers:

1,2,3,4

add them up and divide by number of data points (4) :

(1+2+3+4)/4 =2.5 this is the mean ;

then take the mean and subtract that from each value;

(1-2.5)+(2-2.5)+(3-2.5)+(4-2.5) this gives us the following :

(-1.5)+(-0.5)+(0.5)+(1.5) at this point some we take the absolute value of the data points which basically
means get rid of the negative sign and add them up :

(1.5)+(0.5)+(0.5)+(1.5) = 4 then take this number and divide by number of data points ;

4/4 = 1 this is the mean absolute deviation.

The part I am having a problem with is the part where you subtract the mean from all the previous data points , I do not know how to loop back to previous values...

Reply With Quote
  #5 (permalink)
 BobF 
Hyannis, MA
 
Experience: Advanced
Platform: TradeStation
Trading: ES
Posts: 3 since Nov 2011
Thanks Given: 0
Thanks Received: 2

You do not specify where the data points are coming from. I assumed they are in an array.

Here is a function that should do what you want.

---

Input: aValues[S1](NumericArray), Size(NumericSimple);

Vars: j(0), Sum(0), Mean(0);

Sum = 0;
for j = 1 to Size begin
Sum = Sum + aValues[j];
end;
Mean = Sum / Size;

Sum = 0;
for j = 1 to Size begin
Sum = Sum + AbsValue(aValues[j] - Mean);
end;

MeanDeviation = Sum / Size;

Reply With Quote




Last Updated on February 17, 2014


© 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