Copy function from pinescript

how would I / is it possible to recreate the valuewhen function from pinescript?

Screen Shot 2020-07-22 at 20.41.12

Specifically, the lines i want to replicate:

fractal_top = high[2] > high[3] and high[2] > high[4] and high[2] > high[1] and high[2] > high[0]
fractal_price = valuewhen(fractal_top, price, 1)

1 Like

Seems like there isn’t a way to implement this in QuantScript, currently. We are thinking of ways to amend the language in order for this kind of logic to be possible.

1 Like

We’re adding some features to the language to make this possible. They should be released in a couple of days. Here’s a preview of the implementation:

function ValueWhen(source, condition, occurence):
  series holder:
    if condition: source

  holder[occurence]
1 Like