-2

i need help to convert this Indicator from V2 to V5. It is very complex for me.

//@version=2
study("Heiken Ashi MTF")
ha_t = heikinashi(tickerid)

res = input('60', title="TM 1")
ha_open = security(ha_t, res, open)
ha_close = security(ha_t, res, close)
ha_dif = ha_open-ha_close
ha_diff=iff(ha_dif > 0, 1, iff(ha_dif<0, 2, 3))

res2 = input('240', title="TM 2")
ha_open2 = security(ha_t, res2, open)
ha_close2 = security(ha_t, res2, close)
ha_dif2 = ha_open2-ha_close2
ha_diff2=iff(ha_dif2 > 0, 1, iff(ha_dif2<0, 2, 3))

res3 = input('D', title="TM 3")
ha_open3 = security(ha_t, res3, open)
ha_close3 = security(ha_t, res3, close)
ha_dif3 = ha_open3-ha_close3
ha_diff3=iff(ha_dif3 > 0, 1, iff(ha_dif3<0, 2, 3))

plot(15, title="TF1", color=iff(ha_diff==1, red, iff(ha_diff==2, green, white)), style=circles, linewidth=5, join=true)
plot(14, title="TF2", color=iff(ha_diff2==1, red, iff(ha_diff2==2, green, white)), style=circles, linewidth=5, join=true)
plot(13, title="TF3", color=iff(ha_diff3==1, red, iff(ha_diff3==2, green, white)), style=circles, linewidth=5, join=true)

the code is v2 and i need v5. but this is so complicated. i need some features in v5.

Fabian D.
  • 1
  • 1

1 Answers1

-2
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © seriousCockato20483

//@version=5
indicator("Heiken Ashi MTF")
ha_t = ticker.heikinashi(syminfo.tickerid)

res = input('60', title="TM 1")
ha_open = request.security(ha_t, res, open, barmerge.gaps_off, barmerge.lookahead_on)
ha_close = request.security(ha_t, res, close, barmerge.gaps_off, barmerge.lookahead_on)
ha_dif = ha_open-ha_close
ha_diff=ha_dif > 0?  1: (ha_dif<0? 2: 3)

res2 = input('240', title="TM 2")
ha_open2 =  request.security(ha_t, res2, open, barmerge.gaps_off, barmerge.lookahead_on)
ha_close2 =  request.security(ha_t, res2, close, barmerge.gaps_off, barmerge.lookahead_on)
ha_dif2 = ha_open2-ha_close2
ha_diff2=ha_dif2 > 0?  1: (ha_dif2<0? 2: 3)

res3 = input('D', title="TM 3")
ha_open3 =  request.security(ha_t, res3, open, barmerge.gaps_off, barmerge.lookahead_on)
ha_close3 = request.security(ha_t, res3, close, barmerge.gaps_off, barmerge.lookahead_on)
ha_dif3 = ha_open3-ha_close3
ha_diff3=ha_dif3 > 0?  1: (ha_dif3<0? 2: 3)

plot(15, title="TF1", color=ha_diff==1? color.red:(ha_diff==2? color.green: color.white), style=plot.style_circles, linewidth=5, join=true)
plot(14, title="TF2", color=ha_diff2==1? color.red:(ha_diff2==2? color.green: color.white), style=plot.style_circles, linewidth=5, join=true)
plot(13, title="TF3", color=ha_diff3==1? color.red:(ha_diff3==2? color.green: color.white), style=plot.style_circles, linewidth=5, join=true)
Rohit Agarwal
  • 1,258
  • 1
  • 3
  • 9
  • Welcome to Stackoverflow. Code only answers does not provide any value to the community. Furthermore, you should answer well asked questions. Please take some time to read [How to answer](https://stackoverflow.com/help/how-to-answer) FAQ page. – vitruvius Jun 30 '22 at 10:54