VWAPT MTF : ATR /EMA 21/50

Nous avons amélioré le premier indicateur VWAP MTF celui ci vous aidera à gérer votre trading plus efficacement.  Ce script Pine Script™ est conçu pour fournir des niveaux de stop loss (SL) et de take profit (TP) basés sur l'indicateur Average True Range (ATR) ainsi que sur la valeur pondérée du volume (VWAP) et une combinaison de moyennes exponentielles mobiles (EMAs) sur plusieurs périodes de temps.

Fonctionnalités Principales:

  1. ATR Stop Loss & Take Profit:

    • Le script calcule les niveaux de stop loss et de take profit en fonction de l'ATR, qui mesure la volatilité du marché.
    • Les niveaux de SL et TP sont ajustés en fonction du type d'ordre (Long ou Short) et du ratio de risque-rendement cible spécifié par l'utilisateur.
  2. VWAP (Volume Weighted Average Price):

    • Le script calcule le VWAP sur plusieurs périodes de temps (15 minutes, 1 heure, 4 heures et journalière) et en tire une moyenne.
    • Il affiche le VWAP ainsi que des bandes colorées pour indiquer si le prix est au-dessus ou en dessous du VWAP.
  3. Moyennes des EMAs sur Différentes Périodes de Temps:

    • Le script calcule les moyennes exponentielles mobiles (EMAs) sur trois périodes de temps différentes (courte, moyenne et longue).
    • Il combine ensuite ces EMAs pour obtenir une moyenne des EMAs sur tous les intervalles de temps.

Utilisation:

  • Les utilisateurs peuvent spécifier la longueur de l'ATR, le type de lissage de l'ATR (RMA, SMA, EMA, WMA), le multiplicateur d'ATR et d'autres paramètres.
  • Ils peuvent également définir le type d'ordre (Long ou Short) et le ratio de risque-rendement cible.
  • Les niveaux de SL et TP sont tracés sur le graphique, ainsi que le VWAP et les bandes de prix colorées indiquant la position par rapport au VWAP.
  • Les moyennes des EMAs sont également tracées pour fournir une indication de la tendance actuelle du marché.
  • Originalité:

    • Ce script combine plusieurs concepts d'analyse technique, y compris l'ATR, le VWAP et les EMAs, pour fournir une approche holistique de la gestion des risques et de l'analyse de tendance.
    • Il offre une visualisation claire des niveaux de SL et TP ainsi que du contexte du prix par rapport au VWAP et aux moyennes des EMAs, ce qui peut aider les traders à prendre des décisions éclairées.

    Utilisation Avancée:

    • Les traders peuvent ajuster les paramètres du script en fonction de leur stratégie de trading spécifique et de leurs préférences de gestion des risques.
    • En comprenant les principes sous-jacents de l'ATR, du VWAP et des EMAs, les utilisateurs peuvent mieux interpréter les signaux générés par le script et les intégrer dans leur processus de prise de décision.

    En combinant ces fonctionnalités, ce script offre une solution complète pour les traders souhaitant gérer efficacement les risques et identifier les opportunités de trading basées sur une analyse technique approfondie.

  • _____________________________________________________________________________________Pine  Script indicateur_________________________________________________________

 

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © SESE04
//@version=5indicator('ATR Stop Loss & Take Profit with VWAP Mtf', overlay=true, max_bars_back=500)
ATRSFlength = input.int(title='ATR Length', defval=14)ATRSFsmoothing = input.string(title='ATR Smoothing', defval='RMA', options=['RMA', 'SMA', 'EMA', 'WMA', 'NONE'])ATRSFm = input(1.5, 'ATR Multiplier')ATRSFsrc1 = input(close, title='ATR Additional Value for Long')ATRSFsrc2 = input(close, title='ATR Additional Value for Short')ATRSFpline = input(false, 'Show Price Lines')
TypeofOrder = input.string("Long", options=["Long","Short"], title="Type of Open Position")TargetRR = input.float(2, title="Target Risk Reward Ratio")
ATRSFcollong = input.color(color.blue, 'Long Stop Loss Color')ATRSFcolshort = input.color(color.red, 'Short Stop Loss Color')
ATRSFma_function(source, length) =>    if ATRSFsmoothing == 'RMA'        ta.rma(source, length)    else        if ATRSFsmoothing == 'SMA'            ta.sma(source, length)        else            if ATRSFsmoothing == 'EMA'                ta.ema(source, length)            else                 if ATRSFsmoothing == 'WMA'                    ta.wma(source, length)                else                     source
ATRSF = ATRSFma_function(ta.tr(true), ATRSFlength) * ATRSFmATRSFH = ATRSFma_function(ta.tr(true), ATRSFlength) * ATRSFm + ATRSFsrc1ATRSFL = ATRSFsrc2 - ATRSFma_function(ta.tr(true), ATRSFlength) * ATRSFm
p1 = plot(ATRSFpline ? ATRSFH : na, title='ATR Short Stop Loss', color=color.new(ATRSFcolshort,20), trackprice=false )p2 = plot(ATRSFpline ? ATRSFL : na, title='ATR Long Stop Loss', color=color.new(ATRSFcollong,20), trackprice=false)
var float sl = 0var float tp = 0var float et = 0
if TypeofOrder == "Long"    sl := ATRSFL    et := close    tp := (TargetRR*(close-sl)) + close    else if TypeofOrder == "Short"    sl := ATRSFH    et := close    tp := (TargetRR*(close-sl)) + close
var line SLLine = navar line TPLine = navar line ETLine = na
line.delete(ETLine[1])ETLine := line.new(bar_index-1,et,bar_index,et,color=color.white,extend=extend.right,style=line.style_dashed)
line.delete(SLLine[1])SLLine := line.new(bar_index-1,sl,bar_index,sl,color=color.red,extend=extend.right,style=line.style_dashed)
line.delete(TPLine[1])TPLine := line.new(bar_index-1,tp,bar_index,tp,color=color.blue,extend=extend.right,style=line.style_dashed)
drawTester = input.bool(true, "Draw Tester", group='Table Setting')
truncate(_number, _decimalPlaces) =>    _factor = math.pow(10, _decimalPlaces)    int(_number * _factor) / _factor
var table IndicatorTable = table.new(position.top_right, 6, 1, border_width=1)
var bgcolor = color.new(color.blue,0)
if drawTester    table.cell(table_id=IndicatorTable, column=0, row=0, text="SL/TP", width=3, height=5.5, text_color=#ffee00, text_halign=text.align_center, text_valign=text.align_center, text_size=size.normal, bgcolor=#000000)    table.cell(table_id=IndicatorTable, column=1, row=0, text=str.tostring(truncate(et, 5)), width=7, height=5.5, text_color=color.rgb(255, 235, 59), text_halign=text.align_center, text_valign=text.align_center, text_size=size.normal, bgcolor=#060007)    table.cell(table_id=IndicatorTable, column=2, row=0, text="SL", width=2, height=3.5, text_color=color.white, text_halign=text.align_center, text_valign=text.align_center, text_size=size.normal, bgcolor=#f80808)    table.cell(table_id=IndicatorTable, column=3, row=0, text=str.tostring(truncate(sl, 5)), width=7, height=5.5, text_color=#ffffff, text_halign=text.align_center, text_valign=text.align_center, text_size=size.normal, bgcolor=#f10505)    table.cell(table_id=IndicatorTable, column=4, row=0, text="TP", width=2, height=3.5, text_color=color.white, text_halign=text.align_center, text_valign=text.align_center, text_size=size.normal, bgcolor=color.new(#0840f8,0))    table.cell(table_id=IndicatorTable, column=5, row=0, text=str.tostring(truncate(tp, 5)), width=7, height=5.5, text_color=color.rgb(255, 255, 255), text_halign=text.align_center, text_valign=text.align_center, text_size=size.normal, bgcolor=#0840f8)
// Fonction pour calculer le VWAPvwapSource(src, length) =>    sum = 0.0    sumVolume = 0.0    for i = 0 to length - 1        sum := sum + request.security(syminfo.tickerid, src, close[i]) * volume[i]        sumVolume := sumVolume + volume[i]    vwap = sum / sumVolume
length = 30
vwap15 = request.security(syminfo.tickerid, "15", close)vwap60 = request.security(syminfo.tickerid, "60", close)vwap240 = request.security(syminfo.tickerid, "240", close)vwapDaily = request.security(syminfo.tickerid, "D", close)
vwapAvg = (vwap15 + vwap60 + vwap240 + vwapDaily) / 4
vwap_color = vwapAvg > vwapAvg[1] ? #3b08f3 : color.rgb(247, 9, 9)
vwapPlot = plot(vwapAvg, color=vwap_color, linewidth=2, title="VWAP")
price_above_vwap = close > vwapAvgprice_below_vwap = close < vwapAvg
band_color = price_above_vwap ? color.new(#05ff9b, 100) : price_below_vwap ? color.new(#ff0583, 100) : color.new(#cccccc, 100)
h_band_plot = plot(price_above_vwap ? high : na, color=band_color, linewidth=0, title="High Band")l_band_plot = plot(price_below_vwap ? low : na, color=band_color, linewidth=0, title="Low Band")
fill(h_band_plot, vwapPlot, color=color.new(#0042f7, 92), title="High Band Fill")fill(l_band_plot, vwapPlot, color=color.new(#b8005d, 92), title="Low Band Fill")

// Fonction pour calculer la moyenne des EMAs sur différentes périodes de temps
length0 = input(21)length1 = input(50)

get_ema_avg(source, length) =>    ta.ema(ta.ema(source, length), length)
// Calculer les moyennes des EMAs pour les différentes périodes de tempsprice_15 = request.security(syminfo.tickerid, "15", close)price_60 = request.security(syminfo.tickerid, "60", close)price_240 = request.security(syminfo.tickerid, "240", close)
ma0_15 = get_ema_avg(price_15, length0)ma1_15 = get_ema_avg(price_15, length1)
ma0_60 = get_ema_avg(price_60, length0)ma1_60 = get_ema_avg(price_60, length1)
ma0_240 = get_ema_avg(price_240, length0)ma1_240 = get_ema_avg(price_240, length1)
// Moyenne des deux EMAs pour chaque période de tempsma0_avg = (ma0_15 + ma0_60 + ma0_240) / 3ma1_avg = (ma1_15 + ma1_60 + ma1_240) / 3
// Calculer la moyenne des EMAs sur tous les intervalles de tempsma_avg = (ma0_avg + ma1_avg) / 2
// Changement de couleur en fonction de la direction de l'EMAma_color = ma_avg > ma_avg[1] ? color.rgb(0, 4, 255) : #ff0707plot(ma_avg, color=ma_color, title="Combined EMA", linewidth=3)