Home | Trading Alchemy Manual | Alchemy Functions IndexAlchemyPivDiverge (Function)AlchemyPivDiverge is a
multiple-output function that provides the calculation of Bearish and
Bullish Divergence between price and a specified indicator. It also
passes the previous pivot high/low and the number of bars ago when this
previous pivot high/low occured. AlchemyPivDiverge (Bull, Bear, Occur, MinBarsBack, BearPrice, BullPrice, Osc, OVBOVS, OverB, OverS, Cycles, OverSCyc, OverBCyc, MinPos, MinNeg, Strength, MaxLength, MaxSwg, DivFact, oBearDiv, oBullDiv, oPiv, oPivBar) Parameters |
Bull |
Enables/disables the search for bullish divergence. |
Bear |
Enables/disables the search for bearish divergence. |
Occur |
Specifies which occurrence (that is, 1 = most recent, 2 = 2nd most recent, and so on. |
MinBarsBack | Specifies the minimum number of bars between the current divergence bar and the previous pivot where divergence is found. |
BearPrice | Specifies which price of the asset of interest is to be used for bearish divergence. |
BullPrice | Specifies which price of the asset of interest is to be used for bullish divergence. |
Osc |
Specifies the indicator applied to the asset of interest. |
OVBOVS |
The function looks for bearish divergence when the indicator is in overbought territory as determined by the OverB input and it looks for bullish divergence when the indicator is in oversold territory as determined by the OverS input. This input enables or disables these overbought/oversold zones restrictions. |
OverB |
The function looks for bearish divergence when the indicator is in overbought territory as determined by this input. |
OverS |
The function looks for bullish divergence when the indicator is in oversold territory as determined by this input. |
Cycles |
When the function finds bearish divergence in overbought territory, it requires for the indicator to cycle back down into oversold territory as determined by the OverSCyc input, in order to qualify for the next bearish divergence in overbought territory. When the function finds bullish divergence in oversold territory, it requires for the indicator to cycle back up into overbought territory as determined by the OverBCyc input, in order to qualify for the next bullish divergence in oversold territory. This input enables or disables these overbought/oversold cycle restrictions. |
OverSCyc |
When the function finds bearish divergence in overbought territory, it requires for the indicator to cycle back down to oversold territory as determined by this input, in order to qualify for the next bearish divergence in overbought territory. |
OverBCyc |
When the function finds bullish divergence in oversold territory, it requires for the indicator to cycle back up into overbought territory as determined by this input, in order to qualify for the next bullish divergence in oversold territory. |
MinPos |
Specifies the minimum positive value in which to look for bearish divergence. A negative setting disables the positive value requirement. |
MinNeg | Specifies the minimum negative value in which to look for bullish divergence. A negative setting disables the negative value requirement. |
Strength | Specifies the required number of bars on either side to determine a swing point. |
MaxLength | Specifies the number of trailing bars to consider. |
MaxSwg | Specifies the maximum number of swings back to search for divergence. |
DivFact | Specifies the minimum amount by which the divergent oscillator needs to fail the oscillator pivot it is compared to. |
oBearDiv | A numeric reference that receives a 1 if bearish divergence is found at the current bar and it receives a 0 if bearish divergence is not found at the current bar. |
oBullDiv | A numeric reference that receives a 1 if bullish divergence is found at the current bar and it receives a 0 if bullish divergence is not found at the current bar. |
oPiv | A numeric reference that receives the price of a previous pivot with which divergence is compared to. |
oPivBar | A numeric reference that receives the number of bars ago when a previous pivot with which divergence is compared to occurred. |
ReturnsAlchemyPivDiverge always returns a 1. If bearish divergence is found at the current bar, the value of 1 is passed by reference back to the variable oBearDiv. If bullish divergence is found at the current bar, the value of 1 is passed by reference back to the variable oBullDiv. The value for the price of a previous pivot with which divergence is compared to, is passed by reference back to the variable oPiv. The value for the number of bars ago when a previous pivot with which divergence is compared to occurred, is passed by reference back to the variable oPivBar. UsageThe AlchemyPivDiverge function checks for corresponding swing points between price and an indicator and evaluates if the most recent swing high or swing low values are moving in opposite directions. |