- Trading Bot - Automated DayTime (webhook) - Robot Strategy -

1 407
OVERVIEW

The Automate DayTime strategy is a fully automated time-scheduled trading system designed from the ground up for bot execution. Unlike indicator-based strategies, it does not rely on any technical analysis signals. Instead, it opens a position at a precisely defined day and time (UTC) and closes it at another precisely defined day and time (UTC). This makes it a pure calendar-based strategy designed to exploit recurring temporal patterns in financial markets — such as weekly seasonality, session-based momentum, or day-of-week effects.

Every signal generated by this strategy is accompanied by a complete set of structured trading parameters transmitted through TradingView's alert system. The strategy uses invisible plot() outputs to expose the trading mode, quantity type, leverage, position amount, and stop-loss levels — enabling a webhook-based bot to receive everything it needs to autonomously execute orders without any separate configuration.

This approach is fundamentally different from the vast majority of scripts available on TradingView, which are all based on technical indicators. The DayTime strategy targets a completely separate edge: time-based market behavior.


BUILT FOR AUTOMATION — JSON WEBHOOK INTEGRATION

A core differentiator of this strategy is its complete automation-readiness. The script does not simply generate buy/sell alerts — it transmits a full set of structured trading parameters on every signal, designed to be consumed by a webhook-based trading bot.

The strategy uses Pine Script's plot() function with display=display.none to create invisible data channels. These plots do not appear on the chart but are accessible via TradingView's {{plot("PlotName")}} placeholder in alert messages. Combined with TradingView's built-in variables ({{ticker}}, {{strategy.order.comment}}, {{interval}}), this enables the construction of a complete JSON payload such as:

Pine Script®


What each field transmits:
  • comment: The order action — ENTER_LONG, EXIT_LONG, ENTER_SHORT, or EXIT_SHORT — telling the bot exactly what to do.
  • ticker: The asset symbol, so a single bot instance can manage multiple assets.
  • interval: The chart timeframe, allowing the bot to validate that the signal matches the expected configuration.
  • trading_mode: A numeric code indicating the active trading mode.
  • qty_type: A numeric code indicating the position sizing method (1=Percent Available, 2=Percent Total, 3=Cash).
  • leverage: The configured leverage multiplier, so the bot can place correctly sized orders on the exchange.
  • amount_pct: The configured amount (% or $) per entry.
  • stop_loss_long_pct / stop_loss_short_pct: The stop-loss percentages for each direction (100 = disabled).

This architecture means the bot does not need to be separately configured with position sizes or risk parameters — everything is defined once in the TradingView strategy settings and automatically transmitted with every alert. Changing a parameter in the strategy immediately updates what the bot receives, ensuring permanent synchronization between backtest settings and live execution.


WHAT MAKES THIS STRATEGY ORIGINAL
  • No technical indicators whatsoever: The strategy does not use any moving average, oscillator, volume analysis, or price pattern. Entry and exit decisions are determined exclusively by calendar time. This is an entirely different paradigm from standard TradingView scripts.
  • Precise UTC scheduling: The user selects the exact day of the week, hour, and minute (in UTC) for both entry and exit. This allows targeting specific market sessions (e.g., London open, New York close, weekend gaps) with minute-level precision.
  • Designed for weekly seasonality research: Many assets — particularly cryptocurrencies, forex pairs, and indices — exhibit statistically significant day-of-week or time-of-day effects. This strategy allows traders to systematically test and exploit these patterns through backtesting.
  • Full bot-automation architecture: The strategy generates structured alert messages (ENTER_LONG, EXIT_LONG, ENTER_SHORT, EXIT_SHORT) and includes invisible plot outputs for webhook-based automation. It is designed to run unattended with a compatible trading bot.
  • Built-in optional stop-loss: While the strategy is time-based, an optional percentage-based stop-loss provides risk management for unexpected adverse moves during the holding period.

No comparable time-only scheduling strategy with this level of configurability and bot-automation readiness exists in the TradingView public library.


HOW THE STRATEGY WORKS — DETAILED METHODOLOGY

1. Time Detection

On each bar, the strategy reads the current UTC time using Pine Script's dayofweek(), hour(), and minute() functions with explicit "UTC" timezone parameter. This ensures consistent behavior regardless of the user's local timezone or the exchange's timezone.

The entry condition is met when ALL three components match simultaneously: the current day-of-week equals the configured entry day, the current hour equals the configured entry hour, and the current minute equals the configured entry minute.

The exit condition follows the same three-component matching logic for the exit schedule.

2. Entry Logic

When the entry time condition is met and no position is currently open (strategy.position_size == 0), the strategy opens a single position in the selected direction (Long or Short). The strategy only processes one direction at a time to avoid signal conflicts when used with automated bots.

Position size is calculated based on the user's chosen quantity type:
  • Cash: A fixed USDT amount, converted to asset units by dividing by the current close price.
  • Percent (Available Balance): A percentage of the remaining available equity (strategy.equity * amount / 100).
  • Percent (Total Balance): A percentage of total equity calculated as a fixed proportion, enabling compound growth over successive trades.

The configured leverage multiplier is applied to the position size. Pyramiding is set to 1, so only one position is open at any time.

3. Exit Logic

When the exit time condition is met and a position is open in the active direction, the strategy closes the entire position using strategy.close(). An appropriate alert message is sent.

4. Stop-Loss (Optional)

An optional percentage-based stop-loss can be configured independently for long and short positions. The stop-loss price is calculated as a percentage deviation from the average entry price (not from margin). Setting it to 100% effectively disables the stop-loss (default). When the stop-loss is active (below 100%), a strategy.exit() order monitors the position continuously. If triggered, the exit alert message is sent.

5. Backtest Period Control

The user can optionally restrict the backtest to a specific date range using start and end dates. This is useful for isolating specific market regimes or focusing analysis on recent data. When disabled, the strategy processes all available historical data.


DEFAULT STRATEGY PROPERTIES
  • Initial Capital: $10,000
  • Pyramiding: 1 (one position at a time)
  • Commission: 0.20% per trade (applied on entry and exit)
  • calc_on_every_tick: false (no repainting)
  • Default Entry: Monday 10:00 UTC
  • Default Exit: Friday 15:30 UTC
  • Default Mode: Long Only
  • Quantity: 25% of available balance per entry
  • Leverage: 2x (for backtesting purposes only)
  • Stop-Loss: Disabled (set to 100%) by default for both directions


HOW TO USE THIS STRATEGY
  1. Select your trading direction: Long Only or Short Only. The strategy processes one direction at a time to ensure clean alert signals for bot automation.
  2. Configure your entry schedule: choose the day of the week, hour, and minute (UTC timezone). For example, to capture the Monday morning momentum on crypto markets, set Monday 08:00 UTC. To target the London session open on forex, try Monday 07:00 UTC.
  3. Configure your exit schedule: choose the exit day, hour, and minute. For a full-week hold, set Friday 15:30 UTC. For intra-day strategies, set the exit on the same day at a later time.
  4. Set your position size using the quantity type and amount. "Percent (Total Balance)" enables compounding over time.
  5. Optionally set a stop-loss percentage as a safety net for unexpected large moves during the holding period.
  6. Test multiple day/time combinations on your target asset. Cryptocurrency markets often show different behavior on weekends versus weekdays. Forex and equity indices show session-specific momentum patterns.
  7. Use the spread calculator to estimate your actual trading costs and adjust the commission field in Strategy Properties accordingly.
  8. Enable the on-chart information tables (full or minimal display) to monitor entry/exit schedule, position status, win rate, and accumulated profit.


CLOSED SOURCE

This strategy is publicly available — anyone can add it to their chart and use it freely. The source code is not open, for the following reasons:
  • Full integration with trading bot automation systems through structured alert messages and invisible plot outputs for JSON webhooks — enabling unattended scheduled execution. This automation architecture represents significant development effort.
  • Minute-level UTC scheduling with configurable day-of-week selection for both entry and exit — a level of temporal control not available in standard scripts.
  • Flexible position sizing with three quantity modes (Cash, Percent Available, Percent Total) and configurable leverage.
  • Comprehensive real-time information display system with position status, schedule overview, win/loss tracking, and parameter monitoring.
  • Built-in spread calculator for accurate commission estimation.
  • The strategy serves a unique purpose as part of a systematic trading toolkit — it allows traders to isolate and monetize pure time-based edges that indicator-based strategies cannot capture.

All features are fully accessible without viewing the source code. Every configurable parameter is exposed through the strategy settings panel.


LIMITATIONS AND IMPORTANT NOTES
  • Time-based strategies rely on the persistence of temporal patterns. Market regime changes, structural shifts, or unusual macro events can invalidate previously profitable time windows. Regular re-evaluation of entry/exit schedules is recommended.
  • This strategy does not adapt to current market conditions. It will enter at the scheduled time regardless of volatility, news events, or trend direction. Consider combining it with discretionary position management for high-impact events.
  • Past backtest results reflect historical seasonal patterns and do not guarantee future performance.
  • The effectiveness of specific time windows varies significantly between assets. Extensive testing on your target asset is essential before live deployment.
  • Ensure your chart timeframe is granular enough to detect the scheduled entry and exit times. For minute-level scheduling, use a 1-minute or 5-minute chart.
  • When automating, ensure your bot leverage settings and position sizing match the strategy configuration to avoid mismatches.
  • Non-standard chart types (Heikin Ashi, Renko, Kagi, Point and Figure, Range) should not be used for backtesting, as they produce unrealistic results.


DISCLAIMER

This script is provided for educational and informational purposes only. It does not constitute financial advice. Trading financial instruments involves substantial risk of loss. Past performance is not indicative of future results. Always conduct your own research and consult with a qualified financial advisor before making any investment decisions. Use this strategy at your own risk.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.