NexusFi: Find Your Edge


Home Menu

 





Pine Script Translation Request: ValueWhen


Discussion in ThinkOrSwim

Updated
    1. trending_up 4,204 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

Pine Script Translation Request: ValueWhen

  #1 (permalink)
compupix
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

Reply With Quote





Last Updated on November 22, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts