Hi…
Depending on complexity of what your trying to do, the following could be an alternate option is some cases.
Basically, add a custom indicator, call it ‘MAIN’, that only contains a ‘CALL’ to another custom indicator let’s say ‘DATA’.
Add ‘MAIN’ to all desired charts.
Now the code in ‘DATA’ will run in all charts (price or stand alone) that contain ‘MAIN’.
Therefore the code in ‘DATA’ runs on all MAIN’s and if you modify ‘DATA’ and update it via the ‘ADD to indicator’ button, the changes are replicated onto all the charts. On the next tick event I think.
Since, number of bars,barindex,intradaybarindex values are going to be different on different timeframes, using the x an y scale value of time and price, which appear the same on all charts, allows certain drawn objects to appear on all charts.
Below are some simple examples of what could be achieved.
Things to note, IMO, are:
PRT appears to be an EVENT driven system, and the events are ‘ticks’
For a bar to exist it needs a ‘tick’
Code runs at the end of each bar.
NO tick/bar, no bar, no run code, no update.
regards druby
DATA
// 'CALL' this file from multiple charts and
// replicate objects over all the charts from this file
// object related to the 'x' and 'y' scale's of the chart
// time, price.
if islastbarupdate then // only draw objects on last bar
//------------------------------------------------- V Line
dt = 20240322// options -> YYYYMMDD//yesterday//today
tm = 123500 // hhmmss
x1 = (dt * 1000000) + tm
drawVline(datetoBarindex(x1)) coloured("violet",150)style(dottedline,1)
//------------------------------------------------- line segment
x1 = 20240319000000
y1 = 60.6
x2 = 20240323140000
y2 = 73.1
drawsegment(datetobarindex(x1),y1,datetobarindex(x2),y2)coloured("pink",150)
x1 = 20240319080000
y1 = 56
x2 = 20240324163000
y2 = 70
drawsegment(datetobarindex(x1),y1,datetobarindex(x2),y2)coloured("pink",150)
//------------------------------------------------- H Line
level = 64
drawHline(level) coloured("violet",150)style(dottedline,1)
//------------------------------------------------- anchored text
drawtext("Hello World!",0,0)anchor(middle,xshift,yshift)
//------------------------------------------------- rectangle
// YYYYMMDDhhmmss
x1 = 20240323080000
y1 = 60
x2 = 20240323163000
y2 = 65
drawrectangle(datetobarindex(x1),y1,datetobarindex(x2),y2)coloured("aqua",55)bordercolor("aqua",255)
//------------------------------------------------- arrow
drawArrowUp(datetobarindex(x1),66 )coloured("lime")
endif // islastbarupdate
//------------------------------------------------- backgroundcolor
// trade session
if opentime < 80000 or opentime > 163000 then
if opendayofweek < 5 then
backgroundcolor("grey",20)
endif
endif
return
MAIN
CALL "DATA"
return