1

I have a persistent error on my code pine script v5 on the first letter of UseHollow only underlined I do not understand where the problem comes from if anyone can help me thank you in advance

error return : Syntax error at input 'useHollow'



//@version=5
strategy("Ma Stratégie", overlay=true)

// Ichimoku personnalisable
conversionPeriods = input.int(title="Conversion Periods", defval=9)
basePeriods = input.int(title="Base Periods", defval=26)
laggingSpan2Periods = input.int(title="Lagging Span 2 Periods", defval=52)
displacement = input.int(title="Displacement", defval=26)

donchian(len) =>
    ta.sma(ta.lowest(len), ta.highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadingSpanA = ta.sma(conversionLine, baseLine)
leadingSpanB = donchian(laggingSpan2Periods)

plot(leadingSpanA, color=color.blue, title="Tenkan-sen")
plot(leadingSpanB, color=color.orange, title="Kijun-sen")
fill(leadingSpanA, leadingSpanB, color=color.blue, title="Cloud")

plot(close, color=color.black, title="Price")
plot(close[displacement], color=color.red, title="Chikou Span")

// RSI avec un bollinger personnalisable
rsiSource = input.source(title="RSI Source",  defval=close)
rsiLength = input.int(title="RSI Length",  defval=14)
rsiOverbought = input.int(title="RSI Overbought Level", defval=70)
rsiOversold = input.int(title="RSI Oversold Level", defval=30)

rsi = ta.rsi(rsiSource, rsiLength)
bollingerLength = input.int(title="Bollinger Length", defval=20)
bollingerDeviations = input.float(title="Bollinger Deviations", defval=2.0)

upperBand = ta.sma(rsi, bollingerLength) + bollingerDeviations * ta.stdev(rsi, bollingerLength)
lowerBand = ta.sma(rsi, bollingerLength) - bollingerDeviations * ta.stdev(rsi, bollingerLength)

plot(rsi, color=color.black, title="RSI")
plot(upperBand, color=color.red, title="Upper Band")
plot(lowerBand, color=color.green, title="Lower Band")

// Signaux d'achat et de vente
longCondition = ta.crossover(leadingSpanA, leadingSpanB) and (rsi < rsiOversold)
shortCondition = ta.crossunder(leadingSpanA, leadingSpanB) and (rsi > rsiOverbought)

// Position
if (longCondition)
    strategy.entry("Achat", strategy.long)
else if (shortCondition)
    strategy.entry("Vente", strategy.short)

// Stop Loss
stopLoss = input.float(title="Stop Loss (%)", defval=1.0, step=0.1) / 100
strategy.exit("Stop Loss", "Achat", loss=stopLoss)
strategy.exit("Stop Loss", "Vente", loss=stopLoss)

// Take Profit
takeProfit = input.float(title="Take Profit (%)", defval=2.0, step=0.1) / 100
strategy.exit("Take Profit", "Achat", profit=takeProfit)
strategy.exit("Take Profit", "Vente", profit=takeProfit)



// Affichage des informations sur la stratégie
strategy.order("Achat", longCondition, displacement)
strategy.order("Vente", shortCondition, displacement)

// Déclaration des entrées

input bool useHollow = false // <- error here on this U the useHollow
input color bullishColor = color.green
input color bearishColor = color.red
input color volumeColor = color.blue

// Couleurs des bougies et des volumes
bullishColor = input.color(title="Bullish Candle Color", defval=color.green)
bearishColor = input.color(title="Bearish Candle Color", defval=color.red)
volumeColor = input.color(title="Volume Color", defval=color.white)

// Paramètres des bougies
useHeikinAshi = input.bool(title="Use Heikin-Ashi Candles", defval=false)
useHAColors = input.bool(title="Use Heikin-Ashi Candle Colors", defval=true)
// Initialisation de haOpen
var float haOpen = na
var color haColor = na
// Initialisation des variables pour les bougies Heikin-Ashi
var float haClose = na
var float haHigh = na
var float haLow = na

// Construction des bougies
if useHeikinAshi
haClose := (open + high + low + close) / 4
haOpen := nz(haOpen[1], (open[1] + close[1]) / 2)
haHigh := math.max(high, math.max(haOpen, haClose))
haLow := math.min(low, math.min(haOpen, haClose))
if useHAColors
haColor := haOpen > haClose ? bearishColor : bullishColor
else
haColor := na

// Calcul des bougies Heikin-Ashi
var haClose = security(syminfo.tickerid, "D", close)
var haOpen = na(haOpen[1]) ? (open + close) / 2 : na
var haHigh = max(high, max(haOpen, haClose))
var haLow = min(low, min(haOpen, haClose))
var haColor = haOpen < haClose ? bullishColor : bearishColor

// Stockage des valeurs calculées dans des variables
var haOpenPlot = haOpen
var haHighPlot = haHigh
var haLowPlot = haLow
var haClosePlot = haClose
var haColorPlot = haColor

// Tracé de la bougie Heikin-Ashi
plot(haOpenPlot, title="Heikin-Ashi Open", color=haColorPlot)
plot(haHighPlot, title="Heikin-Ashi High", color=haColorPlot)
plot(haLowPlot, title="Heikin-Ashi Low", color=haColorPlot)
plot(haClosePlot, title="Heikin-Ashi Close", color=haColorPlot)



if useHollow
    bullish = close > open
    bearish = open > close
    plot(open, title="Candle Open", color=bullish ? bullishColor : bearish ? bearishColor : color.black)
    plot(close, title="Candle Close", color=bullish ? bullishColor : bearish ? bearishColor : color.black)
    plot(math.max(open, close), title="Candle High", color=bullish ? bullishColor : bearish ? bearishColor : color.black)
    plot(math.min(open, close), title="Candle Low", color=bullish ? bullishColor : bearish ? bearishColor : color.black)
else
    plot(open, title="Candle Open", color=close > open ? bullishColor : bearishColor)
    plot(close, title="Candle Close", color=close > open ? bullishColor : bearishColor)
    plot(math.max(open, close), title="Candle High", color=close > open ? bullishColor : bearishColor)
    plot(math.min(open, close), title="Candle Low", color=close > open ? bullishColor : bearishColor)


// Affichage du volume
plot(volume, style=plot.style_columns, color=volumeColor, title="Volume")

I looked if the word useHollow was not reserved, I tried commas, semicolons, braces in the if at the end of the code which uses the useHollow and I don't see the problem

Cyril O
  • 11
  • 1

1 Answers1

0

input is a function not a type. Just get rid of that and that will fix that problem but there are many other issues in your code.

bool useHollow = false // <- error here on this U the useHollow
color bullishColor = color.green
color bearishColor = color.red
color volumeColor = color.blue
vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • thank you for the answer indeed it removes this error but creates a new one Erreur à 96:1 Mismatched input 'haClose' expecting 'end of line without line continuation' – Cyril O Mar 31 '23 at 09:46
  • As I said, there are many other issues. You need to lear how to code. You can start from [here](https://www.tradingview.com/pine-script-docs/en/v5/index.html). – vitruvius Mar 31 '23 at 09:47