This ProBuilder script demonstrates how to perform multi-timeframe analysis and display various indicators and price differences using anchored text on a trading chart. The code snippet below includes calculations for exponential moving averages (EMAs), simple moving averages (SMAs), and volume-weighted average price (VWAP) across different timeframes (1 minute, 5 minutes, and 15 minutes). It also shows how to anchor text elements to specific positions on the chart, which remain fixed regardless of chart resizing.
DefParam DrawOnLastBarOnly = True
TimeFrame(15 minutes)
My15MnEMA200 = Average[50,1](close)
My15MnSMA50 = Average[50,0](close)
TimeFrame(5 minutes)
My5MnEMA200 = Average[200,1](close)
My5MnSMA50 = Average[50,0](close)
TimeFrame(1 minute, Default)
d = max(1, intradaybarindex)
MyVwap = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
MyVwapRounded = Round(MyVwap, 2)
My1MnEMA200 = Average[200,1](close)
My1MnSMA50 = Average[50,0](close)
MyPrice = Close
MyPriceRounded = Round(MyPrice, 2)
MyDiffPriceVwap = MyPriceRounded - MyVwapRounded
My15MnAboveEMA200 = Close > My15MnEMA200
My15MnAboveSMA50 = Close > My15MnSMA50
My5MnAboveEMA200 = Close > My5MnEMA200
My5MnAboveSMA50 = Close > My5MnSMA50
My1MnAboveEMA200 = Close > My1MnEMA200
My1MnAboveSMA50 = Close > My1MnSMA50
DrawText ("Vwap: #MyVwapRounded#", -240, 125, SansSerif, Bold, 12) anchor(BottomRight) coloured (0,0,0)
DrawText ("Prix: #MyPrice#", -140, 125, SansSerif, Standard, 12) anchor(BottomRight) coloured (0,0,0)
DrawText ("Diff: #MyDiffPriceVwap#", -50, 125, SansSerif, standard, 12) anchor(BottomRight)
DrawText("EMA200 SMA50 ", -110, 100, dialog, standard,12) anchor(BottomRight)
DrawText("15 Minutes ", -250, 75, dialog, standard,12)anchor(BottomRight)
DrawText("5 Minutes ", -250, 50, dialog, standard,12)anchor(BottomRight)
DrawText("1 Minute ", -250, 25, dialog, standard,12)anchor(BottomRight)
If My15MnAboveEMA200 then
DrawText("#My15MnEMA200#", -150, 75, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
Else
DrawText("#My15MnEMA200#", -150, 75, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
Endif
If My15MnAboveSMA50 then
DrawText("#My15MnSMA50#", -50, 75, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
Else
DrawText("#My15MnSMA50#", -50, 75, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
Endif
If My5MnAboveEMA200 then
DrawText("#My5MnEMA200#", -150, 50, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
Else
DrawText("#My5MnEMA200#", -150, 50, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
Endif
If My5MnAboveSMA50 then
DrawText("#My5MnSMA50#", -50, 50, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
Else
DrawText("#My5MnSMA50#", -50, 50, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
Endif
If My1MnAboveEMA200 then
DrawText("#My1MnEMA200#", -150, 25, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
Else
DrawText("#My1MnEMA200#", -150, 25, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
Endif
If My1MnAboveSMA50 then
DrawText("#My1MnSMA50#", -50, 25, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
Else
DrawText("#My1MnSMA50#", -50, 25, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
Endif
DrawRectangle(-290,140,-10,10) anchor(BottomRight) coloured(220,220,220,100) borderColor(0,0,0,0)
DrawRectangle(-195,110,-100,10) anchor(BottomRight) coloured(211,211,211,100) borderColor(0,0,0,0)
Return
Explanation of the Code:
Check out this related content for more information:
https://www.prorealcode.com/topic/affichage-ema-200-sur-ut-15-et-15-mn/#post-197461
Visit Link