Using Both Text and Lines

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • #195366 quote
    Wolf
    Participant
    New

    Hi Roberto,

     

    I better explain what I am trying to achieve. Using a code that shows me higher time frame bars, I would like to display a text showing me the time frame of those bars..

    I found the way to display the text but it is static (I write here). I would like this text to be variable, depending on what time frame I am using so the text is updated automatically.

    for example

    ******

    if timeframe(6 minutes, updateonclose) then

    DEFPARAM DrawOnlastBarOnly = true
    Rge = averagetruerange[2](close)
    ShiftText = 1
    DRAWTEXT(“6 min”, BarIndex,High+Rge/0.4 / ShiftText / 1,SansSerif,Standard,18) COLOURED(20,150,150,255)
    RETURN

    *****

    and so that if I change the time frame parameters to 10 minutes for example, the resulting text will be 10 min. Is there a way to do this?

    #195553 quote
    robertogozzi
    Moderator
    Master

    Add this ON your chart:

    /*           GetTimeFrame
    
       returns the number of seconds in the selected Timeframe:
     
             60 = 1 minute
            300 = 5 minutes
           3600 = 1 hour
          14400 = 4 hours
          86400 = 1 day      (24 hours)
         604800 = 1 week    (7  days)
        2592000 = 1 month  (30 days)
       31536000 = 1 year  (365 days)
              -1 = default TF (or non time based TF)
    
    
     this indicator returns two values (commented out as it plots text)
    
       TF = 0 seconds
       TF = 1 minutes
       TF = 2 hours
       TF = 3 days
       TF = 4 weeks
       TF = 5 months
       TF = 6 years
    
       N  = number of units
    */
    
    DEFPARAM DrawOnlastBarOnly = true
    ShiftText = 1
    Rge       = high  + averagetruerange[2](close) / 0.4 / ShiftText / 1
    //
    x = GetTimeFrame
    IF (x MOD 60) <> 0 THEN
    TF = 0                         //TF = seconds
    N  = x                         //N  = number of seconds
    DRAWTEXT("#N# Sec", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ELSE
    IF x >= 31536000 THEN
    TF = 6                      //TF = years
    N  = floor(x / 31536000,0)  //N  = number of years
    DRAWTEXT("#N# Yrs", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ELSIF x >= 2592000 THEN
    TF = 5                      //TF = months
    N  = floor(x / 2592000,0)   //N  = number of months
    DRAWTEXT("#N# Mth", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ELSIF x >= 604800 THEN
    TF = 4                      //TF = weeks
    N  = floor(x / 604800,0)    //N  = number of weeks
    DRAWTEXT("#N# wks", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ELSIF x >= 86400 THEN
    TF = 3                      //TF = days
    N  = floor(x / 86400,0)     //N  = number of days
    DRAWTEXT("#N# Day", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ELSIF x >= 3600 THEN
    TF = 2                      //TF = hours
    N  = floor(x / 3600,0)      //N  = number of hours
    DRAWTEXT("#N# hrs", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ELSE
    TF = 1                      //TF = minutes
    N  = floor(x / 60,0)        //N  = number of minutes
    DRAWTEXT("#N# Min", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
    ENDIF
    ENDIF
    RETURN// TF AS "TF",N AS "Units"
Viewing 2 posts - 16 through 17 (of 17 total)
  • You must be logged in to reply to this topic.

Using Both Text and Lines


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
juanj @juanj Participant
Summary

This topic contains 16 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/22/2018
Status: Active
Attachments: 3 files
Logo Logo
Loading...