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
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
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
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
Wow… OK! 🙂
But T can be dynamic right?
/Pat
What do you mean by “DYNAMIC” ?
…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
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/.