Supertrend Code for Python

Omkar.Dhavan
Hi Guys,

I am finding it bit difficult to code supertrend in python. I am not getting expected results for long time now. Has anyone already coded it in past/can anyone help me code it?

Thanks & Regards,
Omkar
  • asif09ansari
    BASIC UPPERBAND = (HIGH + LOW) / 2 + Multiplier * ATR
    BASIC LOWERBAND = (HIGH + LOW) / 2 - Multiplier * ATR

    FINAL UPPERBAND = IF( (Current BASICUPPERBAND < Previous FINAL UPPERBAND) and (Previous Close > Previous FINAL UPPERBAND)) THEN (Current BASIC UPPERBAND) ELSE Previous FINALUPPERBAND)

    FINAL LOWERBAND = IF( (Current BASIC LOWERBAND > Previous FINAL LOWERBAND) and (Previous Close < Previous FINAL LOWERBAND)) THEN (Current BASIC LOWERBAND) ELSE Previous FINAL LOWERBAND)

    SUPERTREND = IF(Current Close <= Current FINAL UPPERBAND ) THEN Current FINAL UPPERBAND ELSE Current FINAL LOWERBAND
  • arkochhar
    Hi @Omkar.Dhavan and @asif09ansari, I have written Python functionality to compute SuperTrend. I invite you check it out on GitHub and provide me your feedback. Thanks
  • shankarpandala
    @arkochhar
    I am getting this error for supertrend
    TypeError: cannot insert DatetimeIndex with incompatible label
    remaining indicators worked fine.
  • arkochhar
    @shankarpandala could you please share a code snippet which is giving you error?
Sign In or Register to comment.