1

import TradingView/ta/5

 s21 = supertrend(21,1)
 s14 = supertrend(14,2)
 s7  = supertrend(17,3)
 long = color(s21)=color(s14)=color(s7)=color.green
 short = color(s21)=color(s14)=color(s7)=color.red
 start = timestamp(IST,2020,1,1,0,0,0)
 end = timestamp(IST,2023,6,250,0,0,0)
 strategy.entry("Buy",strategy.long,100,when = long)
 strategy.close("buy",when = short)

I want to buy when the specified supertrends are in an up trend(green) and sell when they are in a down trend(red). I am trying to convert it to version 5 but sends an error please help...

I tried correcting it in chatgpt,bard and all others did not work ta.supertrend is not recognized

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24

1 Answers1

0

Functions and variables have namespaces in v5. See this.

You should be using ta.supertrend.

Also, below two lines will not compile.

long = color(s21)=color(s14)=color(s7)=color.green
short = color(s21)=color(s14)=color(s7)=color.red
vitruvius
  • 15,740
  • 3
  • 16
  • 26