INVITE-ONLY SCRIPT
Updated

[GYTS-Pro] Order Orchestrator

140
๐ŸŽผ Order Orchestrator (Pro) ๐ŸŽผ
๐ŸŒธ Part of GoemonYae Trading System (GYTS) ๐ŸŒธ


๐ŸŒธ --------- INTRODUCTION --------- ๐ŸŒธ

๐Ÿ’ฎ What is the Order Orchestrator?
The Order Orchestrator is a exhaustive trading strategy framework that acts as the central command center for your automated trading operations. It coordinates entries, exits, and position management based on signals from other GYTS and third party indicators, while offering flexibility in trade setup and risk management. Unlike traditional strategies that apply a one-size-fits-all approach, the ๐ŸŽผ Order Orchestrator lets you build sophisticated, multi-layered trading systems that adapt to specific market conditions.

๐Ÿ’ฎ Key Features at a Glance
โ€ข Signal integration - Connect up to 5 independent signal sources with customisable mapping
โ€ข Multi-level take profits - Deploy up to 5 dynamic take profit levels with percentage allocation
โ€ข Adaptive position sizing - Implement anti/martingale position sizing based on win/loss streaks
โ€ข Market regime filtering - Trade selectively in trending or cyclic market conditions
โ€ข SuperTrend exit system - Utilise dynamic trailing stops that activate after specific TP levels
โ€ข Numerous entry/exit methods - Utilise percentage, ATR, higher-high-lower-low-based entries and exits
โ€ข Risk/reward-based TPs - Automatically place take profits based on risk-to-reward ratios
โ€ข Third-party integration - Compatibility with PineConnector and custom API webhooks
โ€ข Advanced signal consolidation - Require multiple signals within a window for trade confirmation
โ€ข Visualisation options - Comprehensive visual feedback system for all aspect of your trades


๐ŸŒธ --------- TRADE ORCHESTRATION SYSTEM --------- ๐ŸŒธ

๐Ÿ’ฎ The Multi-Signal Engine
At its core, the Order Orchestrator processes signals from multiple sources and integrates them to make intelligent trading decisions:

โ€ข Signal sources - Connect up to 5 independent signal generators, including GYTS indicators like ๐Ÿงฌ Flux Composer or a ๐Ÿ“ก Signal Provider like WaveTrend 4D directly
โ€ข Signal Mapping - Flexibly map integer values from signal streams to specific actions (entry long, exit short, etc.)
โ€ข Signal Consolidation - As an alternative to using GYTS Flux Composer, you can set to require multiple confirmations within a specified bar window for stronger trade conviction.
โ€ข Market Regime Filtering - Selectively enable signals based on the current market regime (trending or cyclic). Works with the GYTS Market Regime Detector out-of-the-box.

This multi-layered approach drastically reduces false signals while ensuring you don't miss genuine trading opportunities.

snapshot


๐Ÿ’ฎ Dynamic Entry System
The Order Orchestrator provides flexible entry methods to suit different trading styles:

โ€ข Percentage-based - Enter at a fixed percentage away from the close price
โ€ข ATR-based - Scale your entry distance based on current market volatility
โ€ข HHLL-based - Enter at recent swing highs/lows for breakout or pullback trading
โ€ข Limit or market orders - Choose between immediate execution or better price entries
โ€ข Auto-cancellation - Automatically cancel pending limit orders after a specified number of bars
โ€ข Cooldown period - Add a cooldown period between trades to limit persistent signals

snapshot


๐Ÿ’ฎ Adaptive Position Sizing
The Order Orchestrator includes a sophisticated position sizing system that can adapt to your recent trading results:

โ€ข Win streak scaling - Increase position size during favourable market conditions (anti-martingale)
โ€ข Loss streak management - Apply classic martingale strategy to recover from drawdowns
โ€ข Customisable progression - Set minimum streak threshold and maximum multiplier to control risk
โ€ข Multiplicative scaling - Position size grows geometrically with each consecutive win or loss

This approach allows you to capitalise on "hot streaks" while implementing a systematic recovery strategy during challenging periods.

snapshot


๐Ÿ’ฎ Multi-Level Exit Strategy
Take full control of your exit strategy with a sophisticated multi-tiered approach:

โ€ข Percentage Allocation - Divide your position across up to 5 take profit levels with precise allocation control
โ€ข Dynamic Take Profits - Set TPs using percentage, ATR, or HHLL-based methods
โ€ข Risk/Reward Ratios - Automatically calculate TPs based on your desired risk-to-reward profile
โ€ข Sequential SL Movement - Automatically move your stop loss when earlier TPs are hit
โ€ข SuperTrend Exit Integration - Activate trailing stops after specific TPs are reached
โ€ข Signal-Based Exits - Configure whether exit signals close positions or move stops to breakeven

This granular exit control allows you to lock in profits early while letting winners run with appropriate protection.

snapshot



๐ŸŒธ --------- CONFIGURATION GUIDE --------- ๐ŸŒธ

๐Ÿ’ฎ Time Settings
Control when your strategy is active:

โ€ข Training Period Filter - Restrict strategy operation to specific date ranges for testing or scheduled trading

๐Ÿ’ฎ Entry Settings
Configure how the strategy enters trades:

โ€ข Order type - Choose between market orders (immediate execution) or limit orders (better price)
โ€ข Limit order expiration - Set the number of bars after which pending limit orders are cancelled
โ€ข Global cooldown - Specify a waiting period after trade exit before allowing new entries
โ€ข Entry price calculation - Select from percentage-based, ATR-based, or HHLL-based methods

๐Ÿ’ฎ Martingale Settings
Configure position sizing based on consecutive wins or losses:

โ€ข Win/loss multipliers - Set the factor by which position size increases after wins or losses
โ€ข Min/max streak - Define the minimum streak required and maximum application of multipliers
โ€ข Example progression - With multiplier=2, min_streak=1, max_streak=4, sizes would follow: 1-2-4-8-16-16...

๐Ÿ’ฎ Stop Loss Settings
Configure the initial stop loss placement:

โ€ข Distance method - Choose from percentage-based, ATR-based, or HHLL-based methods
โ€ข Parameters - Customise value and lookback periods depending on the selected method

๐Ÿ’ฎ Take Profit Settings
Configure up to 5 take profit levels:

โ€ข Allocation - Set what percentage of your position closes at each level
โ€ข Distance method - Choose from percentage-based, ATR-based, HHLL-based, or R:R-based methods
โ€ข SL movement - Determine how stops move when each TP hits (none, breakeven, to a previous TP)
โ€ข SuperTrend activation - Enable trailing stops after specific TP levels are reached

๐Ÿ’ฎ Signal Generation Settings
Connect external indicators as signal sources:

โ€ข Signal sources - Connect up to 5 independent indicators, with automatic parsing of GYTS ๐Ÿงฌ Flux Composer & ๐Ÿ“ก Signal Providers. Also with a built-in EMA crossover for testing.
โ€ข Signal mapping - When using custom sources, define which values from data streams correspond to entry/exit signals
โ€ข Regime Activity - Specify whether signals are active in trending markets, cyclic markets, or both.

Note that the GYTS ๐Ÿงฌ Flux Composer already consolidates multiple ๐Ÿ“ก Signal Providers, and therefore should be the only source in the Order Orchestrator when following the GYTS methods. However, you could also configure two or three ๐Ÿงฌ Flux Composers, one for each regime.

๐Ÿ’ฎ Signal Consolidation Settings
Configure how multiple signals are processed:

โ€ข Window size - Set the number of bars over which to consolidate signals
โ€ข Minimum signals - Require a minimum number of signals within the window for entry/exit
โ€ข Exit strategy - Choose how exit signals are handled (market close, move SL, or reverse trade)

Note that the GYTS ๐Ÿงฌ Flux Composer does this in a more sophisticated manner, and this section is unnecessary when using the ๐Ÿงฌ Flux Composer.


๐ŸŒธ --------- AUTOMATED TRADING --------- ๐ŸŒธ

Configure alerts for external execution platforms:

โ€ข PineConnector - Format alerts compatible with MT4/MT5 through PineConnector
โ€ข Custom API - Create webhooks for platforms like 3Commas, Cornix, CryptoHopper, etc.

๐Ÿ’ฎ Automation with PineConnector

When using PineConnector, after having it set up following the official documentation, it is important to use the following settings:

(1) In TradingView, the Condition of the Alert should be "alert() function calls only". Also don't forget to use the correct webhook address and enable it.

(2) In this strategyโ€™s Properties tab: use โ€œ% of equityโ€ for the Order size as is also the metric that will be communicated with PineConnector/MetaTrader for each trade.

(3) In PineConnectorโ€™s Input tab in Syntax section:
  • Target Type (sl= and tp=): "Pips"
  • Volume Type (risk=): "% of Balance, Margin" (or based on "Loss", but that is not how this strategy is calculating the order sizes)
  • Pending Order Entry (price=): "Pips from Current Market Price"


Note that due to the (current) limitations of PineConnector, (partial) take-profits (TPs) are triggered on bar close as market orders even though in TradingView they are limit-order TPs. Therefore, exit prices will vary. The only exception is when only using TP1 (with 100% allocation), then it is a limit order in PineConnector as well. Stoplosses are also always limit orders.

๐Ÿ’ฎ Automation with Custom API
Background how the custom API alerts are computed:
  • There are four alerts: long/short entry and long/short close. This means that positions are fully closed. Therefore, make sure to disable TP2 and if you wish to use TP1, set it to 100% allocation. There are also validation steps implemented to ensure correct usage.
  • We calculate whether limit orders โ€” i.e. entry (when "limit order" is selected), SL and TP1 โ€” are hit, by checking whether the price reached the value of these orders. If so, the alert is triggered. The moment of triggering depends on the settings in โ€œPropertiesโ€ > โ€œRecalculateโ€.



๐ŸŒธ --------- PRACTICAL USAGE GUIDE --------- ๐ŸŒธ

๐Ÿ’ฎ Setting Up Signal Sources
The Order Orchestrator is designed to work with external signal sources from the GYTS suite or custom indicators:

1. GYTS ๐Ÿงฌ Flux Composer & ๐Ÿ“ก Signal Providers:
โ€ข Set Signal Source to "๐Ÿ”— STREAM-int" of the relevant GYTS indicators
โ€ข In case of multiple outputs, e.g. with WaveTrend 4D (Pro), you should set two streams:
โ€ข Primary: "๐Ÿ”— STREAM-int WT4D ๐Ÿ“ก Gradient Divergence Measure"
โ€ข Secondary: "๐Ÿ”— STREAM-int WT4D ๐Ÿ“ก Quantile Median Cross"

2. Market Regime Detector Integration:
โ€ข Enable Market Regime filter
โ€ข Connect to "๐Ÿ”— STREAM-int - ๐ŸงŠ Market Regime"
โ€ข Note that this is a pretty straightforward filter -- "trade only longs", "only shorts", "both directions (cyclic)" and you could use other indicators for this as well.
โ€ข Configure which signals are active in trending vs. cyclic regimes

3. Testing with Built-in Signals:
โ€ข As a default, the test signal option (EMA crossover) is enabled
โ€ข This ensures that the indicator works out-of-the-box, but you should probably use more sophisticated signals
โ€ข You can also use this EMA strategy to validate your exit strategy, position sizing, and overall configuration


๐Ÿ’ฎ Crafting a Multi-Tier Take Profit Strategy
A well-designed take profit strategy is crucial for maximising profitability:

1. Conservative Approach:
โ€ข TP1: 50% allocation at 1:1 R:R ratio
โ€ข TP2: 30% allocation at 2:1 R:R ratio, move SL to breakeven
โ€ข TP3: 20% allocation at 3:1 R:R ratio, move SL to TP1
โ€ข Great for higher timeframe trades with considerable volatility

2. Aggressive Scaling:
โ€ข TP1: 30% allocation at 0.5:1 R:R ratio
โ€ข TP2: 30% allocation at 1:1 R:R ratio, move SL to breakeven
โ€ข TP3: 20% allocation at 2:1 R:R ratio, move SL to TP1
โ€ข TP4: 10% allocation at 3:1 R:R ratio, move SL to TP2
โ€ข TP5: 10% allocation at 5:1 R:R ratio, activate SuperTrend
โ€ข Perfect for trending markets with strong momentum (good combination with certain settings of the GYTS ๐ŸงŠ Market Regime Detector)

3. Activating SuperTrend Exit:
โ€ข Enable SuperTrend exit at later TPs (e.g., TP3 or TP5)
โ€ข This creates a trailing stop for the remaining position
โ€ข Connect a compatible SuperTrend indicator for dynamic stops


๐Ÿ’ฎ Optimising for Different Market Regimes
The ๐ŸŽผ Order Orchestrator truly shines when customised for specific market conditions:

1. Trending Market Configuration:
โ€ข Connect to ๐ŸงŠ Market Regime Detector
โ€ข Enable trend-specific signals (e.g., WaveTrend 4D QMC)
โ€ข Use R:R-based take profits with trailing stops
โ€ข Consider anti-martingale position sizing to capitalise on momentum

2. Cyclic, Range-Bound Market Configuration:
โ€ข Enable cycle-specific signals (e.g., WaveTrend 4D GDM)
โ€ข Use percentage or ATR-based entries/exits
โ€ข Consider tighter take profits with smaller allocations
โ€ข Keep stop losses relatively tight

3. Hybrid Approach:
โ€ข Let Market Regime Detector automatically switch between configurations
โ€ข Use different signal sources for different regimes
โ€ข Adapt position sizing based on market predictability


๐ŸŒธ --------- CONCLUSION --------- ๐ŸŒธ

The ๐ŸŽผ Order Orchestrator represents the culmination of hundreds of hours of development, testing, and refinement. By providing an incredibly flexible framework for trade execution, it addresses the fundamental challenge: how to systematically enter and exit positions while managing risk effectively across different market conditions.

What sets the ๐ŸŽผ Order Orchestrator apart is its ability to act as the central nervous system of your trading operation, intelligently processing inputs from various signal sources and executing a sophisticated trading plan with precision. When combined with other components of the GYTS suite, it forms a complete trading ecosystem that can adapt to virtually any market condition.

โ€ข ๐ŸงŠ Market Regime Detector for environment analysis
โ€ข ๐Ÿงฌ Flux Composer(s), which consolidate ๐Ÿ“ก Signal Providers, for signal generation
โ€ข ๐ŸŽผ Order Orchestrator as the execution framework

We encourage you to start with conservative settings and gradually customize the configuration to match your trading style, risk tolerance, and objectives. The combination of robust entry methods, multi-level take profits, adaptive position sizing, and regime-specific behaviour provides almost limitless possibilities for optimisation.

Your feedback is very valuable in our ongoing quest to create the most effective trading tools possible. Note that this is pushing the limits of TradingView's runtime, a higher-tier TradingView plan may be helpful. As you discover new applications and configurations for the ๐ŸŽผ Order Orchestrator, please share your experiences to help the entire GYTS community grow and succeed.
Release Notes
  • Fixed bug where profit (and thus order sizing) was not calculated correctly due to TV's decimal precision
  • Disable PineConnector messages where risk=0.000
  • Changed SL messages/identifiers to be more descriptive
  • Some refactoring of order size calculation and more comments
  • Fixed bug where SuperTrend would still be drawn when it wasn't enabled
Release Notes
  • Improved UI with more and clearer grouping
  • Removed redundant settings and added more user input validation
  • Significantly altered storage of variables, especially of TPs
Release Notes
  • Updated tracking of consecutive trade statistics
  • Changed Martingale logic to reset when the maximum multiplier is reached, except when that trade ends on break-even
  • Solved bug when using testing strategy (EMA crosses)
  • Updated several calculations to be more efficient, so script should become slightly faster
Release Notes
  • Solved bug of not updating to correct initial entry size in some Martingale scenarios
Release Notes
  • Simplified and corrected martingale order sizing logic
  • Getting empty price from the open position rather than calculated price (solves potential issues with gaps)
  • Slightly more efficient order statistics calculations
  • Added drawdown & runup statistics in table
  • Refactored code for more consistency
Release Notes
  • Added tooltips for Signals section regarding the mapping
  • Fixed SuperTrend display bug
  • Increased trade ID from 3 numbers to 4, to account for strategies with more than 999 trades.
Release Notes
Major update
  • Migrated to Pine Script v6 + refactoring
  • SuperTrend implementation completely rewritten
  • Changed independent TP variables to arrays
  • Fixed small bugs
Release Notes

  • Major refactoring completed -- improved code, but managing almost 3000 lines in Pine Script is a hassle
  • Compatible with Market Regime Detector
  • Extended to 5 sets of external signals
  • Each signal can be traded during trending and/or cyclic markets
  • Lots of bug fixes
  • Better and more tooltip documentation
Release Notes

  • New: Flux Composer, WT4D, manual input signals
  • New: Cooldown period between trades
  • Better statistics tracking
  • Various bug fixes on different combinations of parameters

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.