Horizontal daytrade lines

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #159741 quote
    Nichart
    Participant
    New

    Hi, I want to make an day trade indicator that plot 8 (or more) colored horizontal lines. The formula for every line has to be:  (but are not final)

    (openings price divide by 2 + 0.25) multiplied by 2  = 1st horizontal line blue

    (openings price /2 + 0.50) x2  = 2de horizontal line green

    (openings price /2 + 0.75) x2  = 3de horizontal line blue

    (openings price /2 + 1 ) x2  = 4th horizontal line yellow

    Then the same in minus

    (openings price /2 – 0.25) x2  = 1st horizontal line blue

    (openings price /2 – 0.50) x2  = 2de horizontal line green

    (openings price /2 – 0.75) x2  = 3de horizontal line blue

    (openings price /2 – 1 ) x2  = 4th horizontal line yellow

    The lines may run over whole chart with the price stated at the end right side. If possible, can I add in the program a small text on every line?

    Can someone help me starting so I can adjust it further? Thanks!

    #159832 quote
    Nicolas
    Keymaster
    Master

    Sample code for your first line:

    line1 = (dopen(0)/ 2 + 0.25) *2
    return line1 coloured(0,0,255)
    #159883 quote
    Nichart
    Participant
    New

    Thank you for this first line.

    Sorry this are my first steps into programming but it looks easy to further make the other lines myself.

    Thanks for get me starting.

    #160253 quote
    Nichart
    Participant
    New

    I have already come this far, but I like to have the price displayed on each horizontal line. So the result of line1 on the horizontal line, result of line2 on line2 etc…..

    Maybe also thicker lines.

    Is this possible, I have not found this immediately here in the forum.

    Thanks

    line1 = (dopen(0)/ 2 + 0.25) *2
    line2 = (dopen(0)/ 2 + 0.50) *2
    
    //vertical offset to draw text correctly over horizontal lines
    Voffset = 1*pipsize
    
    //text on line
    DRAWTEXT("text",barindex+10,line1+Voffset,SansSerif,Bold,12)coloured(0,0,255)
    DRAWTEXT("text",barindex+10,line2+Voffset,SansSerif,Bold,12)coloured(0,180,25)
    
    //horizontal lines
    DRAWLINE(barindex-1,line1,barindex,line1)coloured(0,0,255)
    DRAWLINE(barindex-1,line2,barindex,line2)coloured(0,180,25)
    
    RETURN
    
    #160257 quote
    Nicolas
    Keymaster
    Master

    To use a variable value with DRAWTEXT add # before and after the variable name:

    //text on line
    DRAWTEXT("#line1#",barindex+10,line1+Voffset,SansSerif,Bold,12)coloured(0,0,255)
    DRAWTEXT("#line2#",barindex+10,line2+Voffset,SansSerif,Bold,12)coloured(0,180,25)
    #160265 quote
    Nichart
    Participant
    New

    Thank you very much!

    Works like a charm.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Horizontal daytrade lines


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Nichart @nichart Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Nichart
5 years, 1 month ago.

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