How can I obtain the data of the trace of a RenkoChart? Any code available?

Something like obtaining the range of dates or the middle point of the box.

data = {{{2010, 1, 4}, 130.54}, {{2010, 1, 5}, 128.96}, {{2010, 1, 6}, 128.13}, 
      {{2010, 1, 7}, 127.68} , {{2010, 1, 8}, 128.96}, {{2010, 1, 11}, 127.61}, 
      {{2010, 1, 12}, 128.63}, {{2010, 1, 13}, 128.35}, {{2010, 1, 14}, 130.4}, 
      {{2010, 1, 15}, 129.88}, {{2010, 1, 19}, 132.21}, {{2010, 1, 20}, 128.37}} ;

rc = RenkoChart[data, PerformanceGoal -> "Speed"];
pts = Cases[rc, Rectangle[a_, b_, ___] :> Mean[{a, b}], ∞]; 
Show[rc, Epilog -> {PointSize[Large], Point @ pts}]

enter image description here

Alternatively, you can extract the tooltips which contain the information on dates and values:

DeleteDuplicates @ Cases[ RenkoChart[data], Tooltip[_,  t_] :> 
 ({DateList[#], ToExpression @ #2} & @@@
  Partition[DeleteCases[StringSplit @ t[[1]], "~"],  2]), ∞]

{{{{2010, 1, 4, 0, 0, 0.}, 130.54}, {{2010, 1, 5, 0, 0, 0.}, 128.96}},
{{{2010, 1, 6, 0, 0, 0.}, 128.13}}, {{{2010, 1, 7, 0, 0, 0.}, 127.68}},
{{{2010, 1, 8, 0, 0, 0.}, 128.96}, {{2010, 1, 14, 0, 0, 0.}, 130.4}},
{{{2010, 1, 15, 0, 0, 0.}, 129.88}, {{2010, 1, 19, 0, 0, 0.}, 132.21}},
{{{2010, 1, 20, 0, 0, 0.}, 128.37}}}

  • Excelent answer. I was no able to do it. Thanks – roble_t yesterday

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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