Time based info

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #69337 quote
    cummish
    Participant
    Junior

    Hi

    I am trying to update my indicator value only at a specific time of the day and then have that value carried until the next update same time next day – I have read the user manual but can’t workout why the below updates every bar instead of the time of 10am

    —-

    timestart = (Time = 100000)
    lowprice = lowest[20]
    highprice = highest[20]
    
    Return timestart, lowprice as “lowprice”, highprice as “highprice”

     

    ——-

    Any thoughts on where I am going wrong?

     

    Thanks

    #69338 quote
    robertogozzi
    Moderator
    Master

    To write code, please use the <> “insert PRT code” button to make your code easier to read. Thank you.

    #69339 quote
    robertogozzi
    Moderator
    Master

    Line 1 will hold a logical value (either 0 or 1, False or True), not the time, you should write

    timestart = 100000

    to assign TIMESTART a constant (in this case you could even write the keyword ONCE before the name, but it’s not mandatory).

    Since RETURN is executed at each bar, it will ALWAYS update your chart.

    Lines 2 and 3 miss WHAT data the two functions should return, I assume you wanted to write

    lowprice = lowest[20](low)
    highprice = highest[20](high)

    to have the lowest LOW and highest HIGH of the last 20 bars.

    I think what you want is to draw a line at both the highest and lowest price at 10:00am and keep it till next day.

    I’ll write something in a few minutes.

    #69340 quote
    robertogozzi
    Moderator
    Master

    There you go

    DEFPARAM DrawOnLastBarOnly = true
    IF Time = 100000 THEN
       lowprice  = lowest[20](low)
       highprice = highest[20](high)
       MyBar     = BarIndex
    ENDIF
    DRAWsegment(MyBar-20,highprice,barindex,highprice) coloured(0,0,255,255) //Blue segment
    DRAWsegment(MyBar-20,lowprice,barindex,lowprice) coloured(255,0,0,255)   //Red segment
    RETURN

    is that what you needeed?

    Roberto

    #69342 quote
    cummish
    Participant
    Junior

    Hi Roberto

    thanks so much – the draw segment wasn’t but the rest was – so modified to :

    Much appreciated!!

    IF Time= 100000 THEN
    lowprice = lowest[20](low)
    highprice = highest[20](high)
    ENDIF
    Return lowprice as "lowprice" , highprice as "highprice"
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Time based info


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
cummish @cummish Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by cummish
7 years, 9 months ago.

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