1. you need at least two points of contact.
2. sometimes wicks (shadows) contain outliers. try to imagine the distribution of the data and draw lines accordingly
and if you know a bit about models and fitting: i see this as an approximation problem. e.g. take all the max-points for a given sliding and overlapping interval (i.e. "top points") and approximate them via a linear function. (it's also linear if you take the logarithm). then, the residual could be calculated using the L-1 or L-2 norm. L-1 referrs to point 1 of arepo, L-2 is his/her second point.
Advanced data fitters might also consider to assign weights to the points, e.g. the last points have an exponentially higher weight than the first ones. e.g. in python/numpy: np.exp(np.linspace(-1, 0, 10)) if you have 10 points.
in python's "statsmodesl" it's OLS and WLS.
and if you have more points to fit and want to take outliers into account, look into RLS:
http://statsmodels.sourceforge.net/devel/examples/generated/example_rlm.html