-2

I am really beginner in programming / python.

I don't have the MACD INDICATOR in python.

for MACD indicator, how to say ' when the 2 lines are crossing (histograms flip from down to up) and vice versa, so buy '

I can do the buy order, but how to write the cross/flip action.

I am trying with python on binance.

Thanks

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21

1 Answers1

0

I have just finished my code for MACD, MACD done by, 1.Calculate a 12-period EMA of the price for the chosen time period. raw['EMA12'] = raw.close.ewm(span=12).mean().dropna() 2.Calculate a 26-period EMA of the price for the chosen time period. raw['EMA26'] = raw.close.ewm(span=26).mean().dropna() 3.Subtract the 26-period EMA from the 12-period EMA. raw['diffEMA'] = raw.EMA12 - raw.EMA26 4.Calculate a nine-period EMA of the result obtained from step 3. raw['EMA9diff'] = raw.diffEMA.ewm(span = 9).mean().dropna() 5. histograms / MACD signal line raw['MACDline'] = raw['diffEMA'] - raw['EMA9diff']