0
$\begingroup$

Here are two lists as lstClose and lstCCI, the lstCCI is computed from lstClose, as follows:

lstClose = {4.96, 5.11, 5.37, 5.6, 5.38, 5.42, 5.36, 4.9, 4.92, 4.98, 4.89, \
4.99, 4.8, 4.79, 4.62, 4.65, 4.7, 4.68, 4.7, 4.81, 4.84, 4.77, 4.85, \
4.78, 4.69, 4.71, 4.66, 4.69, 4.78, 4.78, 4.81, 4.85, 4.78, 5.1, \
5.29, 5.19, 5.28, 5.22, 5.18, 5.07, 5.08, 5.09, 5.07, 5.1, 5.05, \
5.05, 5.13, 5.1, 5.09, 5.21, 5.24, 5.26, 5.35, 5.19, 5.24, 5.09, \
5.18, 5.19, 5.18, 5.13, 5.15, 5.06, 5.09, 5.08, 5.01, 4.99, 4.99, \
4.94, 4.98, 4.92, 4.87, 4.91, 4.91, 4.92, 4.95, 4.9, 4.93, 4.99, \
5.04, 4.98, 5.17, 5.07, 5.08, 5.14, 5.17, 5.08, 5.53, 5.57, 5.49, \
5.47, 5.64, 5.48, 5.47, 5.31, 5.36, 5.35, 5.31, 5.37, 5.35, 5.09, \
5.04, 4.99, 5.03, 5.05, 5.06, 5.06, 5.23, 5.22, 5.21, 5.18, 5.05, \
5.15, 5.11, 5.03, 5.02, 5.01, 4.93, 4.93, 4.86, 4.88};

lstCCI = {0., 20.7871, 61.8995, 94.235, 26.6075, 31.4117, 12.6703, -100.471, \
-84.3804, -60.9756, -78.1093, -46.1936, -91.2502, -87.306, -127.692, \
-103.179, -74.7508, -68.43, -60.3753, -12.4072, 17.7126, -18.0747, \
43.2532, 2.83447, -61.6957, -28.6649, -74.6305, -37.7155, 47.5671, \
39.4391, 67.1769, 98.0066, 11.1801, 307.857, 289.864, 161.92, \
148.571, 98.3493, 69.0131, 28.7543, 23.6857, 19.5836, 5.70228, \
10.1807, -27.8349, -42.9582, -4.62321, -36.1969, -31.6395, 97.6938, \
125.874, 147.783, 195.455, 41.7023, 72.0339, -55.4608, 14.9502, \
19.0856, 1.40056, -58.7508, -43.9831, -138.353, -103.175, -102.6, \
-139.164, -129.246, -104.217, -138.913, -85.9709, -126.532, -130.928, \
-85.5388, -76.0255, -62.1693, -23.9425, -72.4394, -26.0417, 71.649, \
157.143, 61.6197, 271.978, 117.417, 108.462, 129.758, 120.495, \
44.223, 275.522, 212.289, 136.606, 101.33, 124.962, 61.9489, 49.8132, \
-7.96332, 4.84322, -6.94605, -33.2401, -15.4427, -35.9869, -177.656, \
-182.158, -168.734, -121.365, -90.6816, -66.4835, -58.1035, 19.9007, \
20.4389, 21.8198, 13.6199, -53.2683, 18.8394, 4.08497, -70.7143, \
-75.0812, -83.9947, -145.01, -128.311, -154.937, -117.942};

when they are plotted with this code

ListLinePlot[lstClose, PlotRange -> All, Ticks -> None, 
 PlotStyle -> Gray, ImageSize -> Large]
ListLinePlot[lstCCI, PlotRange -> All, AspectRatio -> 1/5, 
 Ticks -> None, ImageSize -> Large]

and a plot is shown asenter image description here

So how to draw the local trend line and divergence line from the lists and the plot ? it may become like the bellow one. enter image description here

Thanks!

$\endgroup$
  • 1
    $\begingroup$ What are the criteria for which peaks to draw lines in between? $\endgroup$ – C. E. May 23 '17 at 10:40
  • $\begingroup$ I think using FindPeaks to get peaks from the frist one, and take elements with the same indexes of the second one. $\endgroup$ – Jerry May 23 '17 at 10:43
  • $\begingroup$ Is there a (mathematical-ish) definition of local trend line or standard methodologies for computing them? (Ditto for divergence line.) $\endgroup$ – Michael E2 May 23 '17 at 11:36
  • $\begingroup$ Measuring slope of adjacent peaks, the definition of local trend and divergence line in the upper plot case could be opposite. $\endgroup$ – Jerry May 23 '17 at 11:55
  • 1
    $\begingroup$ scale = 0; Line /@ Partition[FindPeaks[lstClose, scale], 2, 1] gives all such lines. Ratios @@@ Differences /@ Partition[FindPeaks[lstClose, scale], 2, 1] gives the slopes. $\endgroup$ – Michael E2 May 23 '17 at 12:10

Your Answer

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

Browse other questions tagged or ask your own question.