Using the ncbar style from this question: Is there a TikZ equivalent to the PSTricks \ncbar command?, whether the bar appears on the top or the bottom of the nodes depends on the relative position of the \tikztostart and \tikztotarget coordinates. If \tikztostart is to the left of \tikztotarget, then the bar appears on the top, but if \tikztostart is to the right of \tikztotarget the bar appears on the bottom. Changing the angle of the bar from 90 to -90 will put it back on top.
I'd like to make a macro which uniformly puts the bar on the top, independent of the relative position of the start an target nodes. What seems like the simplest way, in principle, would be to test for the relative positions of the start and target coordinates, and then adjust the angle accordingly, but I don't know how to do that.
Here's an example. I want the red arrow to be created automatically without passing the angle explicitly.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
ncbar angle/.initial=90,
ncbar/.style={
to path={
(\tikztostart)
-- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
-- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
-- (\tikztotarget)
}},
ncbar/.default=.5cm
}
\newcommand{\toparrow}[3][]{\draw[->] (#2) [ncbar,#1] to (#3);}
\begin{document}
\begin{tikzpicture}
\node[draw] (A) at (0,0) {A};
\node[draw] (B) at (1,0) {B};
\toparrow{A}{B}
\toparrow{B}{A}
\toparrow[ncbar angle=-90,red]{B.north east}{A.north west} % I want this automatically
\end{tikzpicture}
\end{document}

\pgfpointdiff{\tikz@scan@one@point\relax{#1}}{\tikz@scan@one@point\relax{#2}}and then\ifdim\pgf@x>0pt... – Symbol 1 Aug 09 '17 at 20:52let p1=...syntax. But I personally consider it ugly. – Symbol 1 Aug 09 '17 at 21:08