# Hi/Lows Question from User

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.

1 Like

Maybe this code will help.

``````// 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;

// ================ 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);

Sell = Close > hhOfPreviousWeek;

// Delay trades to the next bar open.
SetTradeDelays( 1, 1, 0, 0 );

// Set buy and sell prices to the opening price.