Open papee opened 3 years ago
happy to add this (I've implemented the tradingview version of supertrend V3) when I get to tidying up the code and make my first git submission :D
happy to add this (I've implemented the tradingview version of supertrend V3) when I get to tidying up the code and make my first git submission :D
Will really appreciate this feature :)
@peerchemist is there any plan to add this? I’m not that experienced in python but if you have no one else working on this, I would be happy to try implementing this
You can use this code for supertrend
get_atr = ATR(high_array, low_array, close_array, atr_period, atr_multiplier)
previous_final_upperband = 0
previous_final_lowerband = 0
previous_close = 0
previous_supertrend = 0
supertrend = []
supertrendc = 0
for i in range(0, len(close_array)):
if np.isnan(close_array[i]):
pass
else:
highc = high_array[i]
lowc = low_array[i]
atrc = get_atr[i]
closec = close_array[i]
if math.isnan(atrc):
atrc = 0
hl2 = (highc + lowc) / 2
basic_upperband = hl2 + atr_multiplier * atrc
basic_lowerband = hl2 - atr_multiplier * atrc
if basic_upperband < previous_final_upperband or previous_close > previous_final_upperband:
final_upperband = basic_upperband
else:
final_upperband = previous_final_upperband
if basic_lowerband > previous_final_lowerband or previous_close < previous_final_lowerband:
final_lowerband = basic_lowerband
else:
final_lowerband = previous_final_lowerband
if previous_supertrend == previous_final_upperband and closec <= final_upperband:
supertrendc = final_upperband
else:
if previous_supertrend == previous_final_upperband and closec >= final_upperband:
supertrendc = final_lowerband
else:
if previous_supertrend == previous_final_lowerband and closec >= final_lowerband:
supertrendc = final_lowerband
elif previous_supertrend == previous_final_lowerband and closec <= final_lowerband:
supertrendc = final_upperband
supertrend.append(supertrendc)
previous_close = closec
previous_final_upperband = final_upperband
previous_final_lowerband = final_lowerband
previous_supertrend = supertrendc
return supertrend
Sorry if this is not the right section but could you think about adding SUPERTREND indicator please ? here it is : https://www.netpicks.com/supertrend-indicator/
http://www.freebsensetips.com/blog/detail/7/What-is-supertrend-indicator-its-calculation
Kind regards,