v5: replace ta.adx() with manual ADX calculation using selected OHLC (calcH/L/C)
This commit is contained in:
@@ -138,8 +138,17 @@ shortOk = not useMacd or (macdLine < macdSignal)
|
||||
buyFlip = trend == 1 and trend[1] == -1
|
||||
sellFlip = trend == -1 and trend[1] == 1
|
||||
|
||||
// ADX computation and gate
|
||||
adxVal = ta.adx(adxLen)
|
||||
// ADX computation (manual) and gate on selected source
|
||||
upMove = calcH - calcH[1]
|
||||
downMove = calcL[1] - calcL
|
||||
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0.0
|
||||
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0.0
|
||||
trADX = math.max(calcH - calcL, math.max(math.abs(calcH - calcC[1]), math.abs(calcL - calcC[1])))
|
||||
atrADX = ta.rma(trADX, adxLen)
|
||||
plusDI = atrADX == 0.0 ? 0.0 : 100.0 * ta.rma(plusDM, adxLen) / atrADX
|
||||
minusDI = atrADX == 0.0 ? 0.0 : 100.0 * ta.rma(minusDM, adxLen) / atrADX
|
||||
dx = (plusDI + minusDI == 0.0) ? 0.0 : 100.0 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
|
||||
adxVal = ta.rma(dx, adxLen)
|
||||
adxOk = not useAdx or (adxVal > adxMin)
|
||||
|
||||
// Entry buffer gates relative to current Money Line
|
||||
|
||||
Reference in New Issue
Block a user