display CAGR* on line or channel ? (one-year growth equivalent)
Forums › ProRealTime English forum › ProRealTime platform support › display CAGR* on line or channel ? (one-year growth equivalent)
-
-
02/18/2025 at 5:54 PM #243990
Hi,
I wondered if any PRT object would display the one-year growth rate for a line or channel ? Many thanks !
- in the same way as “horizontal segment” options allow to display the value level.
- CAGR is calculated here https://www.prorealcode.com/prorealtime-indicators/cagr-compound-annual-growth-rate/
To make things fully explicit, I would expect the following calculation, as an example :
- for a price moving from 2,0 to 4,0 in 30 days, displayed in a PRT window over 1 quarter;
- a line (or channel) joining the first day (price 2,0) to the last day (4,0) would display +5,9%;
- calculated as +5,9%= (4,0 / 2,0) ^ (30/365)
side-note:
my value doesn’t need to be very exact (it’s an indication), so something calculating based on 360 days a year, or whatever, would be fine !
the value doesn’t change with a change of display scale (one quarter or one week)
If this doen not exist as a standard, what would be needed to develop it as a custom-designed tool ?
Hope my request is fairly clear. My apologies if the answer is too obvious. Feel free to refer me to any post/resource.
Many thanks !
02/19/2025 at 1:11 PM #244032As far as I know, there is no (standard) PRT object available for this…
You can use Ivan’s indicator and set the number of days via the number of units used…
Additionally, you can have the indicator draw two extra lines for the start and end points…CAGR1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859//-------------------------------------------------------////PRC_CAGR and Growth rate//version = 1//22.03.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------------------------////-----Inputs--------------------------------------------//defparam drawonlastbaronly = trueFinValue = Close[0]IniValue = close[barindex]//-------------------------------------------------------////-----Calculate number of periods-----------------------//tm = gettimeframeif tm > 86400 thenperiod = barindexelseif day <> day[1] thenperiod = 1+periodelseperiod = periodendifendif//-------------------------------------------------------////---Check timeframe for CAGR calculation----------------//if tm = 2592000 then //monthly timeframen = 12drawtext("Period: #period# months",-100,+60)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )elsif tm = 604800 then //weekly timeframen = 52drawtext("Period: #period# weeks",-100,+60)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )elsif tm <=86400 then //Other timeframes (daily or less)n = 252drawtext("Period: #period# days",-100,+60)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )elsedrawtext("Period: #period# bars",-100,+60)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )endif//-------------------------------------------------------////-----CAGR and Growth Rate------------------------------//if barindex < n thenCAGR = undefinedelseCAGR = round((POW((FinValue/IniValue),(n/period))-1)*100,2)GR = round((FinValue / IniValue - 1) * 100,2)endif//-------------------------------------------------------////-----Plot----------------------------------------------//if tm=2592000 or tm=604800 or tm<=86400 thendrawtext("Growth rate: #GR# %",-100,100)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )drawtext("CAGR: #CAGR# %",-100,+80)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )drawrectangle(-200,110,-10,50)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )fillcolor("blue",50)elsedrawtext("Growth rate: #GR# %",-100,100)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )drawrectangle(-200,110,-10,50)anchor(BOTTOMRIGHT ,XSHIFT ,YSHIFT )fillcolor("blue",50)endif//-------------------------------------------------------//DrawHLine(Close[0])DrawHLine(Open[BarIndex])return3 users thanked author for this post.
02/19/2025 at 4:09 PM #24407302/20/2025 at 4:22 PM #244104Hi,
thanks again JS, although what I meant to have was different from above: I’m looking for an object, with a calculated metric, calculated from the start and end point of that object, upon drwaing the object (whereas above “indicator path” adds a window, which displays that metric, which parameters to be given)
To clarify: a graph should be clearer than a long talk, attached is a simulated graph of what I’m looking for :
- the bold line in orange, with +12% automaticaly calculated, is the expected result;
- the date- and level- lines are here just to illustrate the calculation of +12%, and wouldn’t be displayed.
- note: +12% = (136,7 / 117,6) ^ (360/524) -1,
- with 524 being the number of days from 3/8/23 (ini date) to 23/1/25 (final date).
This metric could be displayed on top of a segment, line, or channel (here a standard-error channel).
It could even be added as a tick box in the parameter window for any of these objects (it’s a most basic metric, if not the most …)
From JS earlier post, I assume it does not exist in PRT “as-is”. But I would very much appreciate if it could !
I guess I should request it for a future PRT release (shouldn’t be too heavy to implement – but would be mooost helpful).
Thanks in advance for your inputs !
-
AuthorPosts
Find exclusive trading pro-tools on