Long Beach, CA USA
Posts: 9 since Jul 2014
Thanks Given: 3
Thanks Received: 0
|
Could someone please help me translate the following Pine Script line into ThinkScript:
hlv = valuewhen(hld != 0, hld, 1)
Here's the Pine Script manual's explanation for "valuewhen":valuewhen (Built-in function) Source series value when the condition was true on the n-th most recent occurrence. Syntax valuewhen(condition, source, occurrence) Arguments condition (series) source (series) occurrence (integer) Examples slow = sma(close, 7) fast = sma(close, 14) // get value of close on second cross occurrence valuewhen(cross(slow, fast), close, 1) So, I think I need the value of hld for the most recent occurrence when it wasn't 0. What is the best way to code that?
Thanks,
Drew
|