Filling Holes/Copying Values in Arrays

Here is a snapshot of an exploration of some code I am working on.

My question is how to fill in the blank cells of the PH and PL columns.

The PH (Pivot High) and PL (Pivot Low) values that are shown are chosen by a prescribed set of criteria and represents potential entries if the values are exceeded (Long or Short) by the closing price. I chose to use loops because of the criteria used to pick these points, however this naturally results in holes left in the PH and PL arrays.

I would like to know how to fill in the holes in the arrays. Because these are trigger points for future price action, the array should be filled with previously selected PH and PL until it is replaced with next selected value. Closing values would be compared to the PH value and trigger a long position if it is exceeded. To clarify, the PH values form 9/27/2010 through 10/15/2010 should all be filled with 10.53 and then replaced with 11.39 on 10/28/23 until it is replaced in the future.

Have a look at flip() function.

ph = ph*flip(ph,pl);
pl = pl*flip(pl,ph);

(not tested)

Correct answer is ValueWhen function AFL Function Reference - VALUEWHEN

keepit = ValueWhen( NOT IsNull( input ), input ); // keep non-null input
1 Like

That worked AWESOME Tomasz!

Thank you so much.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.