# Hi/Lows Question from User

**URL:** <https://forums.collective2.com/t/hi-lows-question-from-user/11523>\
**Category:** Seetu\
**Created:** [April 2, 2018, 1:34pm UTC](https://forums.collective2.com/t/hi-lows-question-from-user/11523 "2018-04-02T13:34:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![c2marc](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/c2marc/32/21451_2.png) [@c2marc](https://forums.collective2.com/u/c2marc)\
**Post date:** [April 2, 2018, 1:34pm UTC](https://forums.collective2.com/t/hi-lows-question-from-user/11523/1 "2018-04-02T13:34:37Z")

</div>

Hi, just a quick question about Seetu. I want to get know the best way to get the high/lows over a given period, like the previous week or month for example. What’s the best way to do that? I was thinking of using the HighestSince function.

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [April 2, 2018, 10:19pm UTC](https://forums.collective2.com/t/hi-lows-question-from-user/11523/2 "2018-04-02T22:19:11Z")

</div>

Maybe this code will help.

```auto
// Highest high of the previous week
// ========================

// This expression solves holidays on Monday or Friday. 
// In other words: we can't test for Monday or Friday because those bars may be missing in data due holidays.
startOfWeek = dayofweek() < Ref(dayofweek(),-1); 
// Get the highest high since start of the week
hhSinceStartOfWeek = GetHighestSinceEvent(startOfWeek, Close);
// Get highest high of the previous week which is the value before startOfWeek
hhOfPreviousWeek = ValueWhen(startOfWeek, Ref(hhSinceStartOfWeek,-1));

// Highest high of the previous month
// =========================
// This expression solves holidays on the first or last days of the month
startOfMonth = day() < Ref(day(),-1);
// Get the highest high since start of the month
hhSinceStartOfMonth = GetHighestSinceEvent(startOfMonth, Close);
// Get the highest high of the previous month which is the value before startOfMonth
hhOfPreviousMonth = ValueWhen(startOfMonth, Ref(hhSinceStartOfMonth,-1));

// Similarly for lowest lows
// =========================
// Get the lowest low since start of the week
llSinceStartOfWeek = GetLowestSinceEvent(startOfWeek, Close);
// Get the lowest low of the previous week which is the value before startOfWeek
llOfPreviousWeek = ValueWhen(startOfWeek, Ref(llSinceStartOfWeek,-1));

// ======= Check it in Exploration =======
filter = 1;
AddColumn(close,"Close");
AddColumn(dayofweek(),"Dow");
AddColumn(startOfWeek,"startOfWeek");
AddColumn(hhSinceStartOfWeek,"hhSinceStartOfWeek");
AddColumn(hhOfPreviousWeek,"HHOfPreviousWeek");
AddColumn(llOfPreviousWeek,"llOfPreviousWeek");
AddColumn(hhOfPreviousMonth,"HHOfPreviousMonth");

// ================ Usage in a trading strategy

// Not bad for some specific symbols and a specific time range :-)  
SetOption("ApplyFromTime", "2014-01-01");
SetOption("Symbols", "MSFT,IBM,AAPL,MA");

// Set initial capital 
SetOption("InitialEquity",50000);
      
// Positions sizes: use 25% of the current portfolio equity. (It means max. 4 open positions.)
SetPositionSize( 25, spsPercentOfEquity );
      
// Round a number of shares to 100. 
 SetOption("RoundLotSize",100);
      
Buy = Close < llOfPreviousWeek;
Sell = Close > hhOfPreviousWeek;
      
// Delay trades to the next bar open.
SetTradeDelays( 1, 1, 0, 0 );
      
// Set buy and sell prices to the opening price.
BuyPrice = Open;
SellPrice = Open; 

```

Not bad for some specific symbols and a specific time range 😉

SetOption(“ApplyFromTime”, “2014-01-01”);  
SetOption(“Symbols”, “MSFT,IBM,AAPL,MA”);

 ![weeklyHighs](https://canada1.discourse-cdn.com/flex028/uploads/collective2/original/2X/b/b9c44a32aa2c6a857c6ae2e023348b0a5bd66d19.png)
