PROTECTED SOURCE SCRIPT

Money Flow Index 1D — last-10m live EXIT

22
Money Flow Index 1D Algo — Last-10m Live Exit (Single-Alert Ready)

What it does
This strategy buys daily oversold dips using MFI and manages exits with simple, execution-friendly rules:

Entry (Long-only): Go long when daily MFI < threshold (optional “operate on close” confirmation).

Exits:

Breakout exit: Close if price closes above the previous day’s high.

Time exit: Close after N bars in trade.

Optional SL: Percentage stop from entry.

Live EOD exit window: During the last N minutes before 16:00 New York, close early if price strength persists (configurable buffer).

Next-open execution: When an exit is marked at the daily close, the strategy sends the close at the next session open (live alert) while still backtesting with strategy.close.

Anti-PDT safeguard: Optional rule to avoid same-day exits after entry.

Single-alert mode: Optional, sends entry JSON from the script so you can run the entire flow with one alert.

Visuals: Entry/exit markers and “pending exit” badge.

Notes: Alert-based exits run on live bars; historical backtests use strategy orders so results remain visible. The EOD window uses your time zone input (default: America/New_York) and only applies in real-time.

Inputs (high-level)

MFI period & level: Default 2 bars; enter when MFI < level.

Operate on close: Confirm signals at bar close.

Max bars in trade: Time stop.

Stop-Loss %: Optional percent SL.

EOD live exit window: Last N minutes before 16:00 NY (+ optional price buffer).

Anti-PDT: Block same-day exits.

Single-alert mode: If enabled, the script emits entry alerts too; otherwise only exits send alerts.

Connect to SignalStack (no custom server needed)
Option A — One alert (recommended): “Any alert() function call”

This script generates JSON via alert() on entries (when Single-alert is ON) and on all exits. Create one alert and let the script supply the message.

Create a SignalStack webhook (Brokers & Webhooks → pick your broker → Create Webhook → copy URL).
SignalStack

In TradingView Create Alert:

Condition: select this strategy → Any alert() function call.
TradingView

Webhook URL: paste your SignalStack webhook URL.
SignalStack

Message: leave empty — the script’s alert() provides full JSON (the Create-Alert “Message” box is not used by alert() and doesn’t process placeholders).
TradingView

In the strategy settings:

Turn ON “Use a single alert (alert() also on ENTRIES)”.

Set Entry Qty (this becomes the quantity value in the entry JSON).

What SignalStack expects (stocks/ETFs): symbol, action, quantity. Docs show lowercase examples ("buy", "sell"). If your broker enforces lowercase, ensure actions are lowercase in the payload.
SignalStack

Typical live JSON (sent by the script):

Entry: {"symbol":"QQQ","action":"BUY","quantity":10,"class":"equity","intent":"open",...}

Exit: {"symbol":"QQQ","action":"SELL","quantity":<pos size>,"class":"equity","intent":"close",...}

SignalStack’s stock router only requires symbol/action/quantity; extra fields like class, intent, source, nonce are simply ignored by the router.
SignalStack

Option B — Strategy “Order fills only” (alternative)

If you prefer TradingView to send alerts on strategy fills, create a Strategy Alert with Order fills only and put JSON with placeholders in the Message box (TradingView replaces them at runtime):
TradingView
+1

Message:

{
"symbol": "{{ticker}}",
"action": "{{strategy.order.action}}",
"quantity": "{{strategy.order.contracts}}"
}


Placeholders like {{strategy.order.action}} and {{strategy.order.contracts}} are officially supported in strategy alerts.
TradingView

For stocks/ETFs on Tastytrade, those three fields are sufficient per SignalStack docs.
SignalStack

Why the single-alert option is ideal here

The script already builds the JSON and handles special cases (last-10m exit, next-open exit).

Using “Any alert() function call” means you only maintain one alert; the code drives entries/exits.
TradingView

Disclaimers
Backtests are simulations; live fills differ. Verify your broker permissions and symbol formats in SignalStack before going live. SignalStack examples show lowercase action values; align to your broker’s requirement if needed.
SignalStack

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。