HomePine Script Snippets › Day of Week Filter

Pine Script Day of Week Filter

Five weekday toggles gate entries so your strategy skips the days you don’t want to trade.

//@version=6
strategy("Day of Week Filter", overlay=true, calc_on_every_tick=false)

// ── Inputs ──────────────────────────────────────────────
monOn = input.bool(true,  "Trade Monday")
tueOn = input.bool(true,  "Trade Tuesday")
wedOn = input.bool(true,  "Trade Wednesday")
thuOn = input.bool(true,  "Trade Thursday")
friOn = input.bool(false, "Trade Friday")

// ── Day check (NY clock) ─────────────────────────────────
dow = dayofweek(time, "America/New_York")
dayOK = (dow == dayofweek.monday and monOn) or
     (dow == dayofweek.tuesday and tueOn) or
     (dow == dayofweek.wednesday and wedOn) or
     (dow == dayofweek.thursday and thuOn) or
     (dow == dayofweek.friday and friOn)

// ── Entry logic (replace with your own conditions) ───────
longCondition  = ta.crossover(ta.ema(close, 9), ta.ema(close, 21)) and dayOK
shortCondition = ta.crossunder(ta.ema(close, 9), ta.ema(close, 21)) and dayOK

if longCondition
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", "Long", profit=20, loss=10)

if shortCondition
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", "Short", profit=20, loss=10)

// Visual
bgcolor(not dayOK ? color.new(color.gray, 92) : na, title="Day Disabled")

Settings

How to use

Frequently Asked Questions

How do I disable trading on Fridays in Pine Script?

Read dayofweek(time, "America/New_York"), compare it to dayofweek.friday, and require the result to be false in your entry conditions. This snippet wires that to an input.bool per weekday so you toggle days from the settings panel instead of editing code.

How does dayofweek work in Pine Script?

dayofweek(time, timezone) returns a constant you compare against dayofweek.monday through dayofweek.sunday. Always pass an explicit timezone — for US futures the trading day rolls at 6:00 PM ET, so an overnight bar can belong to a different weekday than your local clock suggests.

Related

Want a complete eval-ready strategy tested day by day?

This snippet is a building block. Our paid scripts are complete strategies — entries, filters, kill switch, and EOD flatten verified across every weekday on 3 years of MES/NQ data. Instant delivery from $50.

View Plans — From $50