Strategy · Pine Script v6 · Own pane

PineForge — Waypoint Weekday MACD

by pineforge-4pass· code credited to PineForge

This strategy computes the MACD with user-defined fast, slow, and signal lengths, then plots the MACD line, signal line, and histogram in a separate pane.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code50
Settings7inputs
LicenceApache-2.0
Last update5 days ago23 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

50 lines of Pine Script v6 from validation/calendar-waypoint-weekday-macd-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
//@version=6
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 PineForge
// PineForge Corporate Strategy: Waypoint Weekday MACD
// Calendar gating is explicit so weekday behavior remains reproducible.
strategy("PineForge — Waypoint Weekday MACD", overlay=false,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity, default_qty_value=6,
     pyramiding=0, commission_type=strategy.commission.percent,
     commission_value=0.05, slippage=1,
     margin_long=100, margin_short=100,
     process_orders_on_close=false, calc_on_order_fills=false)

fastLength = input.int(12, "MACD Fast", minval=2, group="Signal")
slowLength = input.int(26, "MACD Slow", minval=3, group="Signal")
signalLength = input.int(9, "MACD Signal", minval=2, group="Signal")
tradeWeekends = input.bool(false, "Trade Weekends", group="Calendar")
allowShort = input.bool(true, "Allow Short", group="Execution")
atrLength = input.int(14, "ATR Length", minval=2, group="Risk")
stopAtr = input.float(2.1, "Stop ATR", minval=0.5, step=0.1, group="Risk")

[macdLine, signalLine, macdHistogram] = ta.macd(close, fastLength, slowLength, signalLength)
atrValue = ta.atr(atrLength)

weekday = dayofweek >= dayofweek.monday and dayofweek <= dayofweek.friday
calendarAllowed = tradeWeekends or weekday
calendarClosed = not calendarAllowed and calendarAllowed[1]

if calendarAllowed and ta.crossover(macdLine, signalLine)
    strategy.entry("Waypoint Long", strategy.long)

if calendarAllowed and allowShort and ta.crossunder(macdLine, signalLine)
    strategy.entry("Waypoint Short", strategy.short)

if calendarClosed
    strategy.close("Waypoint Long", comment="Weekday window closed")
    strategy.close("Waypoint Short", comment="Weekday window closed")

if strategy.position_size > 0
    strategy.exit("Waypoint Long Guard", from_entry="Waypoint Long",
         stop=strategy.position_avg_price - atrValue * stopAtr)

if strategy.position_size < 0
    strategy.exit("Waypoint Short Guard", from_entry="Waypoint Short",
         stop=strategy.position_avg_price + atrValue * stopAtr)

plot(macdLine, "MACD", color=color.blue)
plot(signalLine, "Signal", color=color.orange)
plot(macdHistogram, "Histogram", color=macdHistogram >= 0 ? color.green : color.red,
     style=plot.style_columns)

Overview

PineForge — Waypoint Weekday MACD generates long entries on MACD crossover and short entries on MACD crossunder, but restricts signals to weekdays (Monday-Friday) unless weekend trading is enabled. Calendar gating automatically closes open positions if the daily trading window ends. An ATR-based stop loss exits positions at 2.1 times ATR from the average entry price. Key settings let traders adjust MACD lengths, ATR period, stop multiplier, and execution options including shorts.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Sessions & time, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
MACD Fastint12fastLength
MACD Slowint26slowLength
MACD Signalint9signalLength
Trade WeekendsboolfalsetradeWeekends
Allow ShortbooltrueallowShort
ATR Lengthint14atrLength
Stop ATRfloat2.1stopAtr
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

This strategy enters long positions during a specified trading session when multiple technical indicators align. It executes a buy order when the low drops below the lower Bollinger Band while RSI and ADX exceed configurable threshold values, price closes abov

Strategy v4 Volatility & bandsOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of Bollinger Band + RSI + ADX + MACD

Turtle MACD Time-Zone Filter

by skywalker0803r
42 stars

This strategy enters long when price closes above the prior Donchian high and short when it closes below the prior Donchian low, only while flat and inside a Taipei-hour window. It exits on a MACD histogram reversal or through an ATR stop and a percentage take

Strategy v5 BreakoutOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Turtle MACD Time-Zone Filter
13 stars

This strategy overlays the price chart to trade DAX futures during European market hours. It calculates exponential and simple moving averages, RSI, MACD, Bollinger Bands, ATR, and realized volatility to simulate VIX levels. Trades execute when session time fi

Strategy v5 Sessions & timeOscillators & momentum
Updated 8 months ago · Custom licence GitHub repository of ClaudeHedge - DAX Session Strategy

This strategy calculates double-smoothed Heikin Ashi candles and plots them directly on the price chart alongside a smoothed Relative Strength Index. It evaluates market conditions against external volatility data from an inverse symbol, generating long and sh

Strategy v5 Candlestick patternsOscillators & momentum
Updated 5 months ago · None stated GitHub repository of Heikin Ashi with Session Wicks Strategy

RSI Mean Reversion

by GifariKemal
3 stars

This strategy plots entry signals, stop loss, take profit levels, and an information panel directly on the price chart. It combines a relative strength index mean reversion model with ATR percentile thresholds to filter trades based on volatility conditions. T

Strategy v5 Oscillators & momentumVolatility & bands
Updated 3 days ago · MIT GitHub repository of RSI Mean Reversion

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers