Not sure of value in divergence but try the following to get there:
SYNTAX lowestsince ( Nth, EXPRESSION, DATA ARRAY ) FUNCTION Returns the lowest value of DATA ARRAY since the Nth most recent occurrence of EXPRESSION was true. This includes all data loaded in the chart. EXAMPLE The formula "lowestsince( 2, cross(c,mov(c,10,s), close )" returns lowest value of the close since the second most recent occurrence of the close crossing above its 10-day moving average. ---------------------------
SYNTAX divergence( DATA ARRAY 1, DATA ARRAY 2, % MINIMUM CHANGE ) FUNCTION Plots a +1 if DATA ARRAY 1 diverges from DATA ARRAY 2 (i.e., DATA ARRAY 1 is increasing and DATA ARRAY 2 is decreasing). Plots a -1 if DATA ARRAY 1 converges from DATA ARRAY 2 (i.e., DATA ARRAY 1 is decreasing and DATA ARRAY 2 is increasing). A zero is plotted if they are moving in the same direction. Movements in DATA ARRAY 1 less than % MINIMUM CHANGE are ignored.
The Divergence function is based on the Zig Zag formula. First, a % MINIMUM CHANGE Zig Zag is calculated for DATA ARRAY 1. Next, a Zig Zag is calculated for DATA ARRAY 2 using the % MINIMUM CHANGE required to match the number of Zig Zag segments in DATA ARRAY 1 over the data range loaded. The two Zig Zags are then compared for divergence and convergence.
EXAMPLE The formula "divergence( close, rsi(21), 3 )" looks for divergences between the close and a 21-period RSI. Movements in the close less than 3% are ignored. |