Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can the data of the directional movement index below be extracted from this chart? It seems to be embedded in some kind of dynamic module.

data = FinancialData["IBM", "OHLCV",
   {{2013, 12, 31}, {2014, 3, 31}}];
chart = TradingChart[data,
  {FinancialIndicator["AverageDirectionalMovementIndex", 7]},
  Appearance -> "Line"]

enter image description here

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

1. You can also use all FinancialIndicator[...] functions directly on data:

data = FinancialData["IBM", "OHLCV", {{2013, 12, 31}, {2014, 3, 31}}];
admi = FinancialIndicator["AverageDirectionalMovementIndex", 7][data]
(* {22.3186, 25.4227, 27.7113, 30.474, 34.1408, 38.1074, 41.6553, 44.6964, 47.9435, 
    51.9707, 55.5629, 55.1122, 52.5314, 45.1471, 38.9678, 37.5043, 37.1767, 34.0487,
    33.8211, 33.626, 35.1984, 36.5461, 38.589, 40.3401, 41.841, 44.0037, 46.6283, 
    49.0705, 47.2018, 49.0292, 51.285, 53.5837, 55.9859, 52.8501, 50.3013, 47.5135, 
    42.8011, 41.419, 35.6862, 33.3807, 29.597, 26.9006, 25.2456, 24.9361, 29.7563, 
    34.0085, 32.7614, 31.3429, 31.3501} *)

2. Or you can use Setting on your original chart and extract the parts you need using Cases[...] as in @Kuba's answer:

 Cases[Cases[Setting@chart, _Graphics, \[Infinity]][[3]], 
         Line[x_, ___] :> x, {0, \[Infinity]}][[-1]]
 (* {{14., 22.3186}, {15., 25.4227}, {16., 27.7113}, {17., 30.474},
     {18., 34.1408}, {19., 38.1074}, {20., 41.6553}, {21., 44.6964}, 
     {22., 47.9435}, {23., 51.9707}, {24., 55.5629}, {25., 55.1122},
     {26., 52.5314}, {27., 45.1471}, {28., 38.9678}, {29., 37.5043}, 
     {30., 37.1767}, {31., 34.0487}, {32., 33.8211}, {33., 33.626}, 
     {34., 35.1984}, {35., 36.5461}, {36., 38.589}, {37., 40.3401},
     {38., 41.841}, {39., 44.0037}, {40., 46.6283}, {41., 49.0705}, 
     {42., 47.2018}, {43., 49.0292}, {44., 51.285}, {45., 53.5837}, 
     {46., 55.9859}, {47., 52.8501}, {48., 50.3013}, {49., 47.5135}, 
     {50., 42.8011}, {51., 41.419}, {52., 35.6862}, {53., 33.3807},
     {54., 29.597}, {55., 26.9006}, {56., 25.2456}, {57., 24.9361}, 
     {58., 29.7563}, {59., 34.0085}, {60., 32.7614}, {61., 31.3429},
     {62.,  31.3501}} *)
share|improve this answer
add comment

You can suppress those functionalities with PerformanceGoal:

chart = TradingChart[data, {FinancialIndicator["AverageDirectionalMovementIndex", 7]}, 
         Appearance -> "Line", PerformanceGoal :> "Speed"]

and proceed further with Cases to extract what you need:

Cases[chart, _Graphics, ∞]

enter image description here

Cases[Cases[chart, _Graphics, ∞][[3]], Line[x_, ___] :> x, {0, ∞}][[-1]]

enter image description here

share|improve this answer
    
Aha! PerformanceGoal - Thanks –  Chris Degnen Apr 22 at 23:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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