Indicator value on chart
Forums › ProRealTime English forum › ProBuilder support › Indicator value on chart
- This topic has 20 replies, 3 voices, and was last updated 3 years ago by robertogozzi.
-
-
05/05/2021 at 1:05 PM #168841
Hello Gents,
I am relatively new here. I have a fairly simple and general question.
If my Indicator returns a value (for example 100), is it possible to show that value directly on the chart (above or below the last bar)?
If possible, what is the syntax that I can use to achieve this?
Thank you in advance.
Regards
05/05/2021 at 1:38 PM #168851Data RETURNed are plotted every bar and this cannot be changed.
You can plot data using a DRAW…. (see graphic instructions at https://www.prorealcode.com/documentation/category/graphical/), with which you can use DEFPARAM DRAWONLASTBARONLY=TRUE to plot only on the last candle only.
05/05/2021 at 1:43 PM #168853Thanks Robert.
So how would I show the value of my indicator directly above or below the current bar?
For example a simple VWAP indicator returning 5000. How would I put that 5000 number directly above the current bar?
05/05/2021 at 2:05 PM #168859Add this line as first line:
1DEFPARAM DRAWONLASTBARONLY =truethen add this one before RETURN (I assume your data is retained by variable VWAP, but it can be anything else):
1DrawText(“Vwap #Vwap#”,barindex,high+range*2)remove any data after RETURN.
05/06/2021 at 12:27 AM #168890Thank you Rob. It worked. The # did the trick 🙂
05/06/2021 at 12:37 AM #168891How do I increase the font of the text?
05/06/2021 at 12:48 AM #168892You can add Font, Style and Size, as best described at https://www.prorealcode.com/documentation/drawtext/.
05/06/2021 at 2:35 AM #168896Excellent thank you.
I have the chart on 15 mins intraday and the vwap value resets every 15mins when a new bar forms (which is what i want it to do).
Now how would I leave a copy of the value on the previous bar as soon as the new bar forms? is there a trick to do this?
05/06/2021 at 2:38 AM #168897for example, how would I define the last second of a bar? for example 14 mins and 59 seconds (on a 15 min bar)?
05/06/2021 at 9:07 AM #168918To plot the last two values, since it always plots on the last bar, deleting what’s been plotted before, you have to save the previous bar’s value of the indicator.
The first line after DEFPARAM must be:
1Vwap1 = Vwap //save the previos value before VWAP is recalculatedthen use two separate DRAWTEXT lines:
12DrawText(“Vwap1 #Vwap1#”,barindex-1,high+range*3)DrawText(“Vwap #Vwap#” ,barindex, high+range*2)05/06/2021 at 10:12 AM #168927As to your last question, this is an indicator to be added under your 1-second price chart:
12345678Timeframe(15 minute,default)Minute15 = OpenMinute + 14Timeframe(1 second,default)x = 0IF (OpenMinute = Minute15) AND (CurrentSecond = 59) THENx = 1ENDIFreturn x AS "Next one is the Last Second"05/06/2021 at 1:01 PM #168936Thank you Robert. Much appreciated.
Assume my indicator is calculating difference between two numbers (say a-b=c). Now is c is being continually calculated and is dynamically changing on the chart.
Now let’s say c happens to be < 0 (say for argument sake = -100). Now as long as c is decreasing is value (eg -105, -107, -109 etc…) I keep on colouring c in red. But when c increases in value say switches from -105 to -103 (notice c is till <0 but increased in value), how do I then show it in green?
05/06/2021 at 2:10 PM #168942There you go (not tested):
1234567891011Once b = 0 //BlueOnce t = 255 //TransparencyMyCCI = Cci[14](TypicalPrice)If MyCCI < MyCCI[1] thenr = 255 //Redg = 0 //GreenElsIf MyCCI >= MyCCI[1] thenr = 0 //Redg = 255 //GreenEndifReturn MyCCI coloured(r,g,b,t) as “Cci”05/06/2021 at 2:30 PM #168949Tnx but your code is looking at a value 1 bar ago i.e. mycci[1]. The two values I need to compare are both occurring in the current bar (1 variable dynamically changing in the current bar so it need to compare it to itself ( i.e. its currentvalue – its previous value) …so I need something else other than [1] syntax
05/06/2021 at 3:18 PM #168955Drawonlastbaronly1234567891011121314//Zigo 6/05/2021Defparam DRAWONLASTBARONLY =truemycci=round(CCI[14](typicalPrice))if mycci <0 thenr=255g=0bl=0elsif mycci > 0 thenr=0g=255bl=0endifDRAWTEXT(" #mycci#", barindex, mycci, dialog,standard, 18)coloured(r,g,bl,255)return -
AuthorPosts
Find exclusive trading pro-tools on