2
$\begingroup$

Imagine I have a list of Forex data as below:

data= {{"2014 06 30  07:49", {1.36535, 1.36525, 1.36543, 1.36542, 81}}, 
       {"2014 06 30  07:50", {1.36543, 1.3654, 1.36545, 1.36544, 25}}, 
       {"2014 06 30  07:51", {1.36544, 1.36544, 1.36562, 1.36552, 116}}

The list has different sizes in different case. Then using FinancialIndicator["WildersMovingAverage", i][data] you can get a list of WildersMovingAverage given period i. The output of this function is a list.

My question is how one may limit the function in order to just compute the value of WildersMovingAverage for last data point and not to compute the whole list which is time consuming when the list is huge?

$\endgroup$
0
$\begingroup$

From the docs on WildersMovingAverage

Blockquote

That is, the second argument is the number of periods used in calculating the moving average. So, we can pass the last n periods of the data to the function FinancialIndicator["WildersMovingAverage", n] to get the "last" value of the indicator:

 data = FinancialData["MSFT", {{2009, 1, 1}, {2009, 3, 31}}]; 
 FinancialIndicator["WildersMovingAverage", 5][data[[-5 ;;, 2]]]
 (* {15.842} *)
 FinancialIndicator["WildersMovingAverage", 10][data[[-10 ;;, 2]]]
 (* {15.556}*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.