OPEN-SOURCE SCRIPT
Two Bar ATR Flip

This strategy was generated entirely from a natural language prompt, without a single line of code written or edited by a human developer.
Using CodaPro’s AI engine, the logic, structure, syntax, and alerts were all fully constructed by ARiS — OpenAI’s trading code architect integrated into the CodaPro workflow.
The result is a regime-based trend strategy that uses ATR trailing bands to detect directional flips, confirmed with a two-bar hold filter, and automatically routes alerts to brokers for live execution.
It is engineered with clean logic flow, risk-calibrated sizing, and automated broker payloads — suitable for immediate deployment or as a modular base for advanced quant systems.
Core Components:
1. ATR Flip Engine (Regime Detection)
SuperTrend-style band logic with hl2 ± ATR * multiplier.
Directional regime flips are tracked and locked using persistent variables.
Flip triggers are validated only on strong crossovers.
2. 2-Bar Confirmation Filter
Ensures regime flips persist for 2 full bars before allowing entries.
Eliminates transient noise and early reversals.
3. Dynamic Risk-Based Position Sizing
Uses equity-based % risk to calculate size based on ATR-derived stop distance.
No static contracts — size adjusts dynamically per market volatility.
4. Entry/Exit Logic
Entry logic supports long/short with full reversal logic (strategy.close_all() on flip).
SL and TP are derived from current ATR and auto-adjust per entry bar.
5. Broker Integration Payloads
Alerts include JSON payloads for enter and exit-all, with multiplier precision.
Ready for webhook integration with brokers like Tradovate or IBKR.
6. Visual Aids
Flip and confirmation signals are plotted for visual debugging.
Regime background colors (lime/red) for rapid context.
Trailing stoplines plotted dynamically based on trend.
Automation Notes:
Alerts built using alert.freq_once_per_bar_close
Full compatibility with webhook delivery systems
Designed for deterministic behavior: process_orders_on_close = true
Original Prompt Used by the user and generated by CodaPro.ai - ARiS
"Build a Pine Script strategy that flips between long and short using an ATR trailing stop.
Add a 2-bar confirmation after each flip before entering a position.
Include dynamic position sizing based on risk % and ATR stop distance.
Add take profit and stop loss based on ATR.
Generate broker payloads for entry and exit as webhook alerts."
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Check out this strategy() built by our very own Pine Scripting AI - ARiS! No coding needed just your idea. Just describe it — we generate it. Backtest, refine, and route trades live to brokers like Tradovate or IBKR. codapro.ai/
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Check out this strategy() built by our very own Pine Scripting AI - ARiS! No coding needed just your idea. Just describe it — we generate it. Backtest, refine, and route trades live to brokers like Tradovate or IBKR. codapro.ai/
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.