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 sptrader with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 BobF with 1 posts (0 thanks)
    1. trending_up 3,943 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
Iran Fired a Missile at Israel Last Night. The $8M June …
Prediction Markets & Event Contracts
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 thanks
  #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: 702



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


© 2026 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 - Downloads - Top
no new posts