Universal Arbitration
Version: v.1.1.0.1

Description
This strategy monitors the spread between two correlated instruments, opening a long position on one and a short on the other when the spread widens, then closing both legs as the spread reverts to its mean. It includes automatic state recovery after connection loss, multi-tier ROI/time-based exits, and unified P&L risk controls across both legs.
Properties
General Parameters
- Backtest Mode [default: false] — When enabled, the strategy runs in backtest mode.
- Debug Mode [default: false] — When enabled, the strategy outputs additional debug information.
- Number of contracts 1 ticker [default: 1, range: 1–∞] — Number of contracts to trade for the first ticker.
- Number of contracts 2 ticker [default: 2, range: 1–∞] — Number of contracts to trade for the second ticker.
- Use Exit Mean Reversion [default: true] — Exit positions based on mean reversion criteria.
TimeFrame Second Ticker
- Bars Period Value Second Ticker [default: 1, range: 1–∞] — Bars period value for the second ticker.
- Bars Period Type Second Ticker [default: Minute] — Bars period type for the second ticker.
Spread Parameters
- Spread calculation mode [default: Clean] — Chooses whether the spread is calculated as a direct price difference or normalized using an SMA-based coefficient.
- Period SMA [default: 14, range: 1–∞] — Number of bars used to calculate the Simple Moving Average for spread analysis.
- Second ticker [default: 6E SEP25] — Symbol of the second financial instrument that correlates with the first instrument for spread trading.
- Use custom ratio [default: false] — Ratio to align the second instrument with the first one. Leave it 1 if you want the spread to be calculated from the net prices of two instruments.
- Ratio [default: 1, range: 1–∞] — Used to align a second instrument that has a lower price than the first.
- Std ratio [default: 2, range: 0–∞] — Multiplier for standard deviation used in spread analysis calculations.
Roi Parameters
- Use Roi [default: false] — Enables ROI-based exit rules.
- Roi 1 [default: false] — Enables the first ROI level.
- Period 1 [default: 15, range: 0–∞] — Bars to look back for the first ROI level.
- Roi value 1 (%) [default: 0.2, range: 0–∞] — Target ROI percentage for the first level.
- Roi 2 [default: false] — Enables the second ROI level.
- Period 2 [default: 30, range: 1–∞] — Bars to look back for the second ROI level.
- Roi value 2 (%) [default: 0.1, range: 0–∞] — Target ROI percentage for the second level.
- Roi 3 [default: false] — Enables the third ROI level.
- Period 3 [default: 45, range: 1–∞] — Bars to look back for the third ROI level.
- Roi value 3 (%) [default: 0.05, range: 0–∞] — Target ROI percentage for the third level.
Money Management
- Daily Profit [default: 500, range: 1–∞] — Daily profit target for the strategy.
- Daily DrawDown [default: 500, range: 1–∞] — Maximum daily drawdown limit for the strategy.
Trading Time
- Enable Sesion 1 times? (optional) [default: false] — Enable first trading session.
- Session 1 start time [default: 09:30] — Session first start time.
- Session 1 end time [default: 12:00] — Session first end time.
- Enable Sesion 2 times? (optional) [default: false] — Enable second trading session.
- Session 2 start time [default: 09:30] — Session second start time.
- Session 2 end time [default: 12:00] — Session second end time.
- Enable Sesion 3 times? (optional) [default: false] — Enable third trading session.
- Session 3 start time [default: 13:00] — Session third start time.
- Session 3 end time [default: 14:00] — Session third end time.
- Enable Exit on sesion Close [default: true] — Exit at session close.
- Session close time [default: 16:50] — Session close time.
- Exit on sesion close minutes [default: 1, range: 1–∞] — Minutes before session close to exit.
Day of Week
- Sunday [default: true] — Enable trading on Sunday.
- Monday [default: true] — Enable trading on Monday.
- Tuesday [default: true] — Enable trading on Tuesday.
- Wednesday [default: true] — Enable trading on Wednesday.
- Thursday [default: true] — Enable trading on Thursday.
- Friday [default: true] — Enable trading on Friday.
- Saturday [default: true] — Enable trading on Saturday.
Note:
If all days are disabled, the strategy will trade without any restrictions on days.
If all trading session clocks are turned off, the auto strategy will trade without time restrictions.
Version Change History
v.1.0.0.1 (Sep 6, 2023)
1) Improved architecture.
2) Added additional setting for specifying the trading session.
3) Added functions to raise position after connection loss.
4) Daily profit and drawdown functions can be used in backtest.
5) Added option to specify trading on specific days of the week.
v.1.0.0.2 (Sep 29, 2023)
1) Added a debug mode parameter that allows you to output useful code information for the developer.
2) Improved the function of raising the position after connection loss.
v.1.0.0.3 (Nov 12, 2023)
1) Improved trading session time.
2) Improved the function of raising the position after connection loss.
v.1.0.0.4 (Dec 1, 2023)
1) Improved conditions for partial fulfillment of orders.
2) Improved the function of raising the position after connection loss.
3) Added functions for order execution log.
v.1.0.0.5 (Dec 24, 2023)
1) Improved conditions for partial fulfillment of orders.
v.1.0.0.6 (Mar 14, 2024)
1) Improved conditions for closing a position when the daily loss or profit is reached.
2) Fixed a problem with system variables resetting after the completion of a trade.
3) Changed parameter determining the priority of strategy position or account position.
4) Fixed the problem of strategy transition to the next state while placing an entry order.
5) Fixed an issue with clearing all trade variables after each execution.
v.1.0.0.7 (Aug 6, 2024)
1) Created a class that stores trade variables with thread locking; thread race problem solution.
2) Improved functions to raise position after connection loss.
3) Use of order state functions in OnExecutionUpdate methods.
4) Changed order names and name verification during order execution in the OnExecutionUpdate method.
5) Created a new property group to set the bar period type and value for the second ticker.
v.1.1.0.0 (May 29, 2025)
1) Added detailed code comments for better understanding.
2) Improved OnBarUpdate method execution conditions.
3) Updated strategy state names for more accurate representation of strategy operation.
4) Added ROI function for trade exit.
5) Added session end position closing function.
6) Added descriptive names to exit orders for better understanding of position closure conditions.
7) Sorted properties.
8) Improved position recovery.
9) Added property to enable/disable mean reversion exit.
10) Added property StdRatio to set the standard deviation ratio for the spread.
11) Updated entry conditions.
v.1.1.0.1 (Oct 26, 2025) (Current)
1) Trading hours and days logic updated — if all sessions are disabled, the strategy now runs without time restrictions instead of stopping trading.