# How we calculate bi-weekly close and high?

Is this correct?

``````dow = DayOfWeek();
lastDayofWeek = dow > Ref( dow, 1 );

startpoint = lastDayofWeek  AND Cum( lastDayofWeek ) % 2 == 0;

// Two week(bi-weekly)closing price
twoWeekClosingPricecomp = SparseCompress( startpoint, Close );
twoWeekClosingPriceEx = SparseExpand( startpoint, comp );

//Two week(bi-weekly) Highest Price
twoWeekHighestHigh = HighestSince( startpoint, High );
twoWeekHighestHighPricecomp = SparseCompress( startpoint, twoWeekHighestHigh );
twoWeekHighestHighPriceEx = SparseExpand( startpoint, twoWeekHighestHighPricecomp );
``````

This might be correct, but you could get it easier using `TimeFrameGetPrice()` function.

As a side note, when you are posting for the very first time, it is not bad idea to introduce yourself. Also 3 word question like βis this correct?β in a very first post is considered rude. If you want someone to help you, be polite. Something like βHi I am new here. Could anybody tell me if the code I got is correct. I am not sure because β¦β.

1 Like