Indicator value on chart

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #168841 quote
    IG_CFD_Trader
    Participant
    Average

    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

    #168851 quote
    robertogozzi
    Moderator
    Master

    Data 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.

    #168853 quote
    IG_CFD_Trader
    Participant
    Average

    Thanks 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?

    #168859 quote
    robertogozzi
    Moderator
    Master

    Add this line as first line:

    DEFPARAM DRAWONLASTBARONLY =true

    then add this one before RETURN (I assume your data is retained by variable VWAP, but it can be anything else):

    DrawText(“Vwap #Vwap#”,barindex,high+range*2)

    remove any data after RETURN.

    #168890 quote
    IG_CFD_Trader
    Participant
    Average

    Thank you Rob. It worked. The # did the trick 🙂

    #168891 quote
    IG_CFD_Trader
    Participant
    Average

    How do I increase the font of the text?

    #168892 quote
    robertogozzi
    Moderator
    Master

    You can add Font, Style and Size, as best described at https://www.prorealcode.com/documentation/drawtext/.

    #168896 quote
    IG_CFD_Trader
    Participant
    Average

    Excellent 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?

    #168897 quote
    IG_CFD_Trader
    Participant
    Average

    for example, how would I define the last second of a bar? for example 14 mins and 59 seconds (on a 15 min bar)?

    #168918 quote
    robertogozzi
    Moderator
    Master

    To 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:

    Vwap1 = Vwap      //save the previos value before VWAP is recalculated

    then use two separate DRAWTEXT lines:

    DrawText(“Vwap1 #Vwap1#”,barindex-1,high+range*3)
    DrawText(“Vwap  #Vwap#” ,barindex,  high+range*2)
    #168927 quote
    robertogozzi
    Moderator
    Master

    As to your last question, this is an indicator to be added under your 1-second price chart:

    Timeframe(15 minute,default)
    Minute15 = OpenMinute + 14
    Timeframe(1 second,default)
    x = 0
    IF (OpenMinute = Minute15) AND (CurrentSecond = 59) THEN
       x = 1
    ENDIF
    return x AS "Next one is the Last Second"
    #168936 quote
    IG_CFD_Trader
    Participant
    Average

    Thank 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?

    #168942 quote
    robertogozzi
    Moderator
    Master

    There you go (not tested):

    Once b = 0     //Blue
    Once t = 255   //Transparency
    MyCCI = Cci[14](TypicalPrice)
    If MyCCI < MyCCI[1] then
       r = 255     //Red
       g = 0       //Green
    ElsIf MyCCI >= MyCCI[1] then
       r = 0       //Red
       g = 255     //Green
    Endif
    Return MyCCI coloured(r,g,b,t) as “Cci”
    #168949 quote
    IG_CFD_Trader
    Participant
    Average

    Tnx 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

    #168955 quote
    Zigo
    Participant
    Master
    //Zigo 6/05/2021
    Defparam DRAWONLASTBARONLY =true
    mycci=round(CCI[14](typicalPrice))
    if mycci <0 then
    r=255
    g=0
    bl=0
    elsif mycci > 0 then
    r=0
    g=255
    bl=0
    endif
    DRAWTEXT("           #mycci#", barindex, mycci, dialog,standard, 18)coloured(r,g,bl,255)
    return
    NASDAQ-7-minutencc.png NASDAQ-7-minutencc.png
Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

Indicator value on chart


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
IG_CFD_Trader @wnakhoul Participant
Summary

This topic contains 20 replies,
has 3 voices, and was last updated by robertogozzi
4 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/05/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...