I want to return a value (variable) undefined before and after a given date

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #208002 quote
    calpa02
    Participant
    New

    Hey there…

    Here’s a challenge for you:-) Or maybe there is a simple solution to this?

    I want to return a value (variable) which is undefined before and after a given date that i set my self. Basically, I want to set the start date of when the variable should start returning values and I want to set the end date of when the same variable should stop returning values.

    How can this be coded? Probably quite simple huu?

    Let me know

    #208048 quote
    robertogozzi
    Moderator
    Master

    You can use UNDEFINED just for the first time, any subsequent assignement cannot be overwritten. So the solution is to reset the variable to 0, not to UNDEFINED:

    ONCE x = undefined
    IF (Time >= 100000) AND (Time <= 120000) THEN
       x = 1
    ELSE
       x = 0 //undefined won't work here
    ENDIF
    RETURN x
    #208068 quote
    calpa02
    Participant
    New

    Thanks for your answer! That means that UNDEFINED is probably not the right way to achieve what I want to achieve. Maybe it’s not possible at all.

    I want to return a value from an indicator that I coded my self, but I don’t want any value to be returned before and after the STARTTIME and ENDTIME.

    If I return a “zero” the visualization in the chart get messed up and it returns the wrong values for other parameters.

    Maybe it’s not possible? What’s your thoughts?

    Thanks Patrik

    #208083 quote
    robertogozzi
    Moderator
    Master

    This always plots the same variable, but makes it invisible outside the selected time interval:

    t = 0
    x = close
    IF  (Time >= 100000) AND (Time <= 110000) THEN
       t = 255
    ENDIF
    DrawText("#x#",BarIndex,high + average[20,0](range)) coloured("Green",t)
    RETURN
    #208085 quote
    calpa02
    Participant
    New

    Wow… OK! 🙂

    But T can be dynamic right?

    /Pat

    #208095 quote
    robertogozzi
    Moderator
    Master

    What do you mean by “DYNAMIC” ?

    #208104 quote
    calpa02
    Participant
    New

    …well, basically “t” will be the result of a changing parameter calculation/indicator in my code. In your example it’s set to t=255, but I guess that “t” can represent any given result/value from another calculation/indicator.

    Right?

    /Pat

    #208149 quote
    robertogozzi
    Moderator
    Master

    t is just the Alpha, or Transparency, attribute to be used with colours to make them fully visible or not, it can range from 0 to 255, 255=fully visible and 0=invisible  (an example about COLOURED at https://www.prorealcode.com/documentation/drawarrow/.

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

I want to return a value (variable) undefined before and after a given date


ProBuilder support

New Reply
Author
author-avatar
calpa02 @calpa02 Participant
Summary

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

Topic Details
Forum: ProBuilder support
Language: English
Started: 01/23/2023
Status: Active
Attachments: No files
Logo Logo
Loading...