using System; namespace NT8.Core.Execution { /// /// Configuration for multiple profit targets /// public class MultiLevelTargets { /// /// Ticks for first target (TP1) /// public int TP1Ticks { get; set; } /// /// Number of contracts to close at first target /// public int TP1Contracts { get; set; } /// /// Ticks for second target (TP2) - nullable /// public int? TP2Ticks { get; set; } /// /// Number of contracts to close at second target - nullable /// public int? TP2Contracts { get; set; } /// /// Ticks for third target (TP3) - nullable /// public int? TP3Ticks { get; set; } /// /// Number of contracts to close at third target - nullable /// public int? TP3Contracts { get; set; } /// /// Constructor for MultiLevelTargets /// /// Ticks for first target /// Contracts to close at first target /// Ticks for second target /// Contracts to close at second target /// Ticks for third target /// Contracts to close at third target public MultiLevelTargets( int tp1Ticks, int tp1Contracts, int? tp2Ticks = null, int? tp2Contracts = null, int? tp3Ticks = null, int? tp3Contracts = null) { if (tp1Ticks <= 0) throw new ArgumentException("TP1Ticks must be positive", "tp1Ticks"); if (tp1Contracts <= 0) throw new ArgumentException("TP1Contracts must be positive", "tp1Contracts"); TP1Ticks = tp1Ticks; TP1Contracts = tp1Contracts; TP2Ticks = tp2Ticks; TP2Contracts = tp2Contracts; TP3Ticks = tp3Ticks; TP3Contracts = tp3Contracts; } } /// /// Configuration for trailing stops /// public class TrailingStopConfig { /// /// Type of trailing stop /// public StopType Type { get; set; } /// /// Trailing amount in ticks /// public int TrailingAmountTicks { get; set; } /// /// Trailing amount as percentage (for percentage-based trailing) /// public decimal? TrailingPercentage { get; set; } /// /// ATR multiplier for ATR-based trailing /// public decimal AtrMultiplier { get; set; } /// /// Whether to trail by high/low (true) or close prices (false) /// public bool TrailByExtremes { get; set; } /// /// Constructor for TrailingStopConfig /// /// Type of trailing stop /// Trailing amount in ticks /// ATR multiplier /// Whether to trail by extremes public TrailingStopConfig( StopType type, int trailingAmountTicks, decimal atrMultiplier = 2m, bool trailByExtremes = true) { if (trailingAmountTicks <= 0) throw new ArgumentException("TrailingAmountTicks must be positive", "trailingAmountTicks"); if (atrMultiplier <= 0) throw new ArgumentException("AtrMultiplier must be positive", "atrMultiplier"); Type = type; TrailingAmountTicks = trailingAmountTicks; AtrMultiplier = atrMultiplier; TrailByExtremes = trailByExtremes; } /// /// Constructor for percentage-based trailing stop /// /// Trailing percentage /// Whether to trail by extremes public TrailingStopConfig(decimal trailingPercentage, bool trailByExtremes = true) { if (trailingPercentage <= 0 || trailingPercentage > 100) throw new ArgumentException("TrailingPercentage must be between 0 and 100", "trailingPercentage"); Type = StopType.PercentageTrailing; TrailingPercentage = trailingPercentage; TrailByExtremes = trailByExtremes; } } /// /// Configuration for automatic breakeven /// public class AutoBreakevenConfig { /// /// Number of ticks in profit before moving stop to breakeven /// public int TicksToBreakeven { get; set; } /// /// Whether to add a safety margin to breakeven stop /// public bool UseSafetyMargin { get; set; } /// /// Safety margin in ticks when moving to breakeven /// public int SafetyMarginTicks { get; set; } /// /// Whether to enable auto-breakeven /// public bool Enabled { get; set; } /// /// Constructor for AutoBreakevenConfig /// /// Ticks in profit before breakeven /// Whether to use safety margin /// Safety margin in ticks /// Whether enabled public AutoBreakevenConfig( int ticksToBreakeven, bool useSafetyMargin = true, int safetyMarginTicks = 1, bool enabled = true) { if (ticksToBreakeven <= 0) throw new ArgumentException("TicksToBreakeven must be positive", "ticksToBreakeven"); if (safetyMarginTicks < 0) throw new ArgumentException("SafetyMarginTicks cannot be negative", "safetyMarginTicks"); TicksToBreakeven = ticksToBreakeven; UseSafetyMargin = useSafetyMargin; SafetyMarginTicks = safetyMarginTicks; Enabled = enabled; } } /// /// Stop type enumeration /// public enum StopType { /// /// Fixed stop at specific price /// Fixed = 0, /// /// Trailing stop by fixed ticks /// FixedTrailing = 1, /// /// Trailing stop by ATR multiple /// ATRTrailing = 2, /// /// Chandelier-style trailing stop /// Chandelier = 3, /// /// Parabolic SAR trailing stop /// ParabolicSAR = 4, /// /// Percentage-based trailing stop /// PercentageTrailing = 5 } /// /// Target type enumeration /// public enum TargetType { /// /// Fixed target at specific price /// Fixed = 0, /// /// R-Multiple based target (based on risk amount) /// RMultiple = 1, /// /// Percentage-based target /// Percentage = 2, /// /// Tick-based target /// Tick = 3 } }