Apprendre a coder des stratégies de trading en future soi même sous TradingView a l'aide de Chat GPT en 5 minutes :-)
//@version=6
strategy("BB CryptoHaltéro Strategy", overlay=true)
// Paramètres des bandes de Bollinger
length = input.int(50, minval=1)
maType = input.string("SMA", "Basis MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = input.float(1.5, minval=0.001, maxval=50, title="StdDev")
// Fonction de calcul de la moyenne mobile
ma(source, length, _type) =>
switch _type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// Calcul des bandes de Bollinger
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
// Conditions d'entrée et de sortie
longCondition = ta.crossover(close, upper)
shortCondition = ta.crossunder(close, lower)
exitLongCondition = ta.crossunder(close, basis)
exitShortCondition = ta.crossover(close, basis)
// Exécuter les trades conditionnellement
if (longCondition)
strategy.entry("Long", strategy.long)
if (exitLongCondition)
strategy.close("Long")
if (shortCondition)
strategy.entry("Short", strategy.short)
if (exitShortCondition)
strategy.close("Short")
// Affichage des bandes de Bollinger
plot(basis, "Basis", color=color.blue)
plot(upper, "Upper", color=color.red)
plot(lower, "Lower", color=color.green)