Hello
What is best practice to show or not to show an indicator value with return?
I would like to have a check box, where I can chose to show the 26 week line or not to show the 26 week line in the following indicator:
//
// Highest High 20 days or 26 week according to Larry Williams
//
hh20 = highest[20](high)
hl20 = lowest[20](low)
//hh26w = highest[128](high)
//hl26w = lowest[128](low)
if show26 = 1 then
hh26w = highest[128](high)
hl26w = lowest[128](low)
endif
return hh20 coloured (0,128,255) as "Hishest High 20 Days", hl20 coloured (0,128,255) as "Hishest Low 20 Days",hh26w coloured (0,255,255) as "Hishest High 26 Week", hl26w coloured (0,255,255) as "Hishest Low 26 Week"
Add a 4th (optional) parameter with colour, it’s called Transparency or Fade and has a rang from 0 (invisible) to 255 (max visibility):
coloured (0,128,255,255)
you can use a variable and set it to 0 when you don’t want that line to be visible or any greater number to make it more or less visible:
t = 255
IF DontShow = 1 THEN
t = 0
ENDIF
RETURN xyz coloured (0,128,255,t) AS "xyz"
Or set it as UNDEFINED. The trouble with setting it as zero is that even when transparent a zero value line is drawn and the scaling of the chart is messed up.
//
// Highest High 20 days or 26 week according to Larry Williams
//
hh20 = highest[20](high)
hl20 = lowest[20](low)
if show26 then
hh26w = highest[128](high)
hl26w = lowest[128](low)
else
hh26w = undefined
hl26w = undefined
endif
return hh20 coloured (0,128,255) as "Hishest High 20 Days", hl20 coloured (0,128,255) as "Hishest Low 20 Days",hh26w coloured (0,255,255) as "Hishest High 26 Week", hl26w coloured (0,255,255) as "Hishest Low 26 Week"
Useful tip: the scaling is not messed up if you define your price option to adapt the scale to price only (setting available in the price menu).
Thanks for your effort. This solution is working very good.
Or go to the indicator window top left corner, then click on the spanner to open its properties window, and there on the left side click on your 26 week line and on the right side you can set its “style” where the last option after the type of line, or point etc… is: “invisible”
invisible
This works fine if you supply an ITF file and have fixed the settings before exporting it but if someone cuts and pastes code then the UNDEFINED option is a little more idiot proof.