Reda AR
Reda AR

Reputation: 1

i got this how do i solve it?Line 10: no viable alternative at input 'if'. Try to add line '//@version=2' to the top of your script

// Calcule le VWAP sur une période de 10 jours
vwap = vwap(10)

// Définit les bandes de VWAP comme étant +/- 2 écart-types du VWAP
vwap_lower_band = vwap - stdev(vwap, 10) * 2
vwap_upper_band = vwap + stdev(vwap, 10) * 2

// Vérifie si le prix actuel est inférieur à la bande inférieure de VWAP
if (close < vwap_lower_band) then
  // Achete si le prix actuel est inférieur à la bande inférieure de VWAP
  strategy.entry("Long", strategy.long)

// Vérifie si le prix actuel est supérieur à la bande supérieure de VWAP
if (close > vwap_upper_band) then
  // Vends si le prix actuel est supérieur à la bande supérieure de VWAP
  strategy.entry("Short", strategy.short)

I expected to get an error as always. I already added the version but i dont know how to solve the error

Upvotes: 0

Views: 1746

Answers (2)

theCrypster
theCrypster

Reputation: 103

As well as removing the "then" statement..

Add:

//version=5
strategy("My Script")

At the top of your code


Change:

vwap(10)

For:

ta.vwap(10)

Change:

stdev

For:

ta.stdev

Also, you might need to Tab those strategy.entry() functions in another tab :)

Upvotes: 0

G.Lebret
G.Lebret

Reputation: 3058

Replace your :

if ... then

By

if ...

No 'then' in Pinescript v5

Upvotes: 1

Related Questions