From 61ab01db835afa1345ceb2e4232d40dffd002e59 Mon Sep 17 00:00:00 2001 From: Sean Date: Tue, 11 Feb 2025 19:17:54 -0500 Subject: [PATCH] Fix bug in initial stop limit adjustment where it is possible for a stop limit to be adjusted downwards. --- MarketDataLib/Generator/CMTrend/CMTTrendModel..cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MarketDataLib/Generator/CMTrend/CMTTrendModel..cs b/MarketDataLib/Generator/CMTrend/CMTTrendModel..cs index 0b5b415..a02a1d3 100644 --- a/MarketDataLib/Generator/CMTrend/CMTTrendModel..cs +++ b/MarketDataLib/Generator/CMTrend/CMTTrendModel..cs @@ -1323,9 +1323,9 @@ namespace MarketData.Generator.CMTrend MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The calculated trailing stop for {0} of {1} would be higher than the Low/Close of {2}.",position.Symbol,Utility.FormatCurrency(trailingStop),Utility.FormatCurrency(currentPrice.Low))); return; } - if(Numerics.Round(trailingStop).Equals(Numerics.Round(position.TrailingStopLimit))) + if(Numerics.Round(trailingStop) <= (Numerics.Round(position.TrailingStopLimit))) { - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The calculated trailing stop for {0} of {1} would be the same as the existing stop limit of {2}.",position.Symbol,Utility.FormatCurrency(trailingStop),Utility.FormatCurrency(position.TrailingStopLimit))); + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The calculated trailing stop for {0} of {1} would be less than or equal to the existing stop limit of {2}.",position.Symbol,Utility.FormatCurrency(trailingStop),Utility.FormatCurrency(position.TrailingStopLimit))); return; } MDTrace.WriteLine(LogLevel.DEBUG,String.Format("****************************** A D J U S T S T O P L I M I T ************************")); @@ -1366,7 +1366,7 @@ namespace MarketData.Generator.CMTrend MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The calculated trailing stop for {0} of {1} would be higher than the Low/Close of {2}.",position.Symbol,Utility.FormatCurrency(trailingStop),Utility.FormatCurrency(currentPrice.Low))); return; } - if(Numerics.Round(position.TrailingStopLimit)