OPEN-SOURCE SCRIPT
Actualizado

J12Matic Builder by galgoom

182
A flexible Renko/tick strategy that lets you choose between two entry engines (Multi-Source 3-way or QBand+Moneyball), with a unified trailing/TP exit engine, NY-time trading windows with auto-flatten, daily profit/loss and trade-count limits (HALT mode), and clean webhook routing using {{strategy.order.alert_message}}.

Highlights

Two entry engines

Multi-Source (3): up to three long/short sources with Single / Dual / Triple logic and optional lookback.

QBand + Moneyball: Gate → Trigger workflow with timing windows, OR/AND trigger modes, per-window caps, optional same-bar fire.

Unified exit engine: Trailing by Bricks or Ticks, plus optional static TP/SL.

Session control (NY time): Evening / Overnight / NY Session windows; auto-flatten at end of any enabled window.

Day controls: Profit/Loss (USD) and Trade-count limits. When hit, strategy HALTS new entries, shows an on-chart label/background.

Alert routing designed for webhooks: Every order sets alert_message= so you can run alerts with:

Condition: this strategy

Notify on: Order fills only

Message: {{strategy.order.alert_message}}

Default JSONs or Custom payloads: If a Custom field is blank, a sensible default JSON is sent. Fill a field to override.

How to set up alerts (the 15-second version)

Create a TradingView alert with this strategy as Condition.

Notify on: Order fills only.

Message: {{strategy.order.alert_message}} (exactly).

If you want your own payloads, paste them into Inputs → 08) Custom Alert Payloads.

Leave blank → the strategy sends a default JSON.

Fill in → your text is sent as-is.

Note: Anything you type into the alert dialog’s Message box is ignored except the {{strategy.order.alert_message}} token, which forwards the payload supplied by the strategy at order time.

Publishing notes / best practices

Renko users: Make sure “Renko Brick Size” in Inputs matches your chart’s brick size exactly.

Ticks vs Bricks: Exit distances switch instantly when you toggle Exit Units.

Same-bar flips: If enabled, a new opposite signal will first close the open trade (with its exit payload), then enter the new side.

HALT mode: When day profit/loss limit or trade-count limit triggers, new entries are blocked for the rest of the session day. You’ll see a label and a soft background tint.

Session end flatten: Auto-closes positions at window ends; these exits use the “End of Session Window Exit” payload.

Bar magnifier: Strategy is configured for on-close execution; you can enable Bar Magnifier in Properties if needed.

Default JSONs (used when a Custom field is empty)

Open: {"event":"open","side":"long|short","symbol":"<ticker>"}

Close: {"event":"close","side":"long|short|flat","reason":"tp|sl|flip|session|limit_profit|limit_loss","symbol":"<ticker>"}

You can paste any text/JSON into the Custom fields; it will be forwarded as-is when that event occurs.

Input sections — user guide
01) Entries & Signals

Entry Logic: Choose Multi-Source (3) or QBand + Moneyball (pick one).

Enable Long/Short Signals: Master on/off switches for entering long/short.

Flip on opposite signal: If enabled, a new opposite signal will close the current position first, then open the other side.

Signal Logic (Multi-Source):

Single: any 1 of the 3 sources > 0

Dual: Source1 AND Source2 > 0

Triple (default): 1 AND 2 AND 3 > 0

Long/Short Signal Sources 1–3: Provide up to three series (often indicators). A positive value (> 0) is treated as a “pulse”.

Use Lookback: Keeps a source “true” for N bars after it pulses (helps catch late triggers).

Long/Short Lookback (bars): How many bars to remember that pulse.

01b) QBands + Moneyball (Gate -> Trigger)

Allow same-bar Gate->Trigger: If ON, a trigger can fire on the same bar as the gate pulse.

Trigger must fire within N bars after Gate: Size of the gate window (in bars).

Max signals per window (0 = unlimited): Cap the number of entries allowed while a gate window is open.

Buy/Sell Source 1 – Gate: Gate pulse sources that open the buy/sell window (often a regime/zone, e.g., QBands bull/bear).

Trigger Pulse Mode (Buy/Sell): How to detect a trigger pulse from the trigger sources (Change / Appear / Rise>0 / Fall<0).

Trigger A/B sources + Extend Bars: Primary/secondary triggers plus optional extension to persist their pulse for N bars.

Trigger Mode: Pick S2 only, S3 only, S2 OR S3, or S2 AND S3. AND mode remembers both pulses inside the window before firing.

02) Exit Units (Trailing/TP)

Exit Units: Choose Bricks (Renko) or Ticks. All distances below switch accordingly.

03) Tick-based Trailing / Stops (active when Exit Units = Ticks)

Initial SL (ticks): Starting stop distance from entry.

Start Trailing After (ticks): Start trailing once price moves this far in your favor.

Trailing Distance (ticks): Offset of the trailing stop from peak/trough once trailing begins.

Take Profit (ticks): Optional static TP distance.

Stop Loss (ticks): Optional static SL distance (overrides trailing if enabled).

04) Brick-based Trailing / Stops (active when Exit Units = Bricks)

Renko Brick Size: Must match your chart’s brick size.

Initial SL / Start Trailing After / Trailing Distance (bricks): Same definitions as tick mode, measured in bricks.

Take Profit / Stop Loss (bricks): Optional static distances.

05) TP / SL Switch

Enable Static Take Profit: If ON, closes the trade at the fixed TP distance.

Enable Static Stop Loss (Overrides Trailing): If ON, trailing is disabled and a fixed SL is used.

06) Trading Windows (NY time)

Use Trading Windows: Master toggle for all windows.

Evening / Overnight / NY Session: Define each session in NY time.

Flatten at End of [Window]: Auto-close any open position when a window ends (sends the Session Exit payload).

07) Day Controls & Limits

Enable Profit Limits / Profit Limit (Dollars): When daily net PnL ≥ limit → auto-flatten and HALT.

Enable Loss Limits / Loss Limit (Dollars): When daily net PnL ≤ −limit → auto-flatten and HALT.

Enable Trade Count Limits / Number of Trades Allowed: After N entries, HALT new entries (does not auto-flatten).

On-chart HUD: A label and soft background tint appear when HALTED; a compact status table shows Day PnL, trade count, and mode.

08) Custom Alert Payloads (used as strategy.order.alert_message)

Long/Short Entry: Payload sent on entries (if blank, a default open JSON is sent).

Regular Long/Short Exit: Payload sent on closes from SL/TP/flip (if blank, a default close JSON is sent).

End of Session Window Exit: Payload sent when any enabled window ends and positions are flattened.

Profit/Loss/Trade Limit Close: Payload sent when daily profit/loss limit causes auto-flatten.

Tip: Any tokens you include here are forwarded “as is”. If your downstream expects variables, do the substitution on the receiver side.

Known limitations

No bracket orders from Pine: This strategy doesn’t create OCO/attached brackets on the broker; it simulates exits with strategy logic and forwards your payloads for external automation.

alert_message is per order only: Alerts fire on order events. General status pings aren’t sent unless you wire a separate indicator/alert.

Renko specifics: Backtests on synthetic Renko can differ from live execution. Always forward-test on your instrument and settings.

Quick checklist before you publish

✅ Brick size in Inputs matches your Renko chart

✅ Exit Units set to Bricks or Ticks as you intend

✅ Day limits/Windows toggled as you want

✅ Custom payloads filled (or leave blank to use defaults)

✅ Your alert uses Order fills only + {{strategy.order.alert_message}}

Notas de prensa
Fixed a bug
Notas de prensa
QBand + Moneyball — S2 & S3 Mode Update

“S2 AND S3” is now truly sequential.
A trade fires only when S2 (Trigger A) occurs first, then S3 (Trigger B) occurs after S2 within a set time.

Extend Bars (Trigger A) = max S2→S3 gap.
This value is a bar-based TTL for the sequence:

0 ⇒ S3 must arrive on the same bar as S2.

1 ⇒ Same bar or next bar.

N ⇒ Within N bars after S2.
(Also bounded by the active Gate window length.)

Auto-reset & repeatable.
If S3 doesn’t arrive before TTL expires, the sequence resets and waits for a fresh S2. After a fill, the sequence resets and can repeat within the same gate, allowing multiple S2→S3 trades per gate (subject to your Max signals per window cap).

Other trigger modes unchanged.
“S2 only”, “S3 only”, and “S2 OR S3” behave exactly as before.
In the sequential mode, the S2→S3 timing is governed by Extend Bars (Trigger A); the Extend Bars (Trigger B) setting still applies to non-sequential modes.

This change makes S2/S3 a clear confluence sequence instead of two independent triggers.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.