code: def QA_indicator_DMI(DataFrame, M1=14, M2=6):
      
      HIGH = DataFrame.high
      LOW = DataFrame.low
      CLOSE = DataFrame.close
      OPEN = DataFrame.open
  
      TR = SUM(MAX(MAX(HIGH-LOW, ABS(HIGH-REF(CLOSE, 1))),
                   ABS(LOW-REF(CLOSE, 1))), M1)
      HD = HIGH-REF(HIGH, 1)
      LD = REF(LOW, 1)-LOW
      DMP = SUM(IFAND(HD>0,HD>LD,HD,0), M1)
      DMM = SUM(IFAND(LD>0,LD>HD,LD,0), M1)
      DI1 = DMP*100/TR
      DI2 = DMM*100/TR
      ADX = MA(ABS(DI2-DI1)/(DI1+DI2)*100, M2)
      ADXR = (ADX+REF(ADX, M2))/2
  
      return pd.DataFrame({
          'DI1': DI1, 'DI2': DI2,
          'ADX': ADX, 'ADXR': ADXR
      })
docs: 趋向指标 DMI