Added EvaluateStopOnUpTrend. The default is FALSE. This worked out well in backtests.

This commit is contained in:
2025-02-22 22:17:03 -05:00
parent e50ac03b33
commit eda09a7f4f
2 changed files with 53 additions and 12 deletions

View File

@@ -1,9 +1,6 @@
using MarketData.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MarketData.Generator.CMTrend
{
@@ -16,14 +13,14 @@ namespace MarketData.Generator.CMTrend
UsePriceSlopeIndicatorDays=252; // The number of pricing days to use for the slope.
BetaMonths=6; // The number of months to use for Beta
AnalysisDate=DateTime.Now.Date; // The analysis date of the run
MarketCapLowerLimit=500000000; // MarketCap lower limit 1,000,000,000
MarketCapLowerLimit=500000000; // MarketCap lower limit 50,0000,000
TradeDate=DateTime.Now; // The current trade date
SidewaysDetection=false; // Detect stock that are going nowhere. If we've held the stock for SidewaysAfterDays AND we've never adjusted the stop AND we can break even THEN we sell.
SidewaysAfterDays=30; // Sideways detection days.
MaxDailyPositions=3; // This is the maximum number of positions to pick up per analysis date. The default is 3
MaxOpenPositions=6; // This is the maximum number of open positions. The default is 6. -1=No Max
MaxDailyPositions=3; // This is the maximum number of positions to pick up per analysis date. The default is 3
MaxOpenPositions=3; // This is the maximum number of open positions. I have tested this with 3 and had good results.
NoTradeSymbols="CLCT,PRSC,CMD,STAY,GBTC,YOKU,PNY,RFMD,ASAZY,USMO,VNR,STB,XIV,SYNT"; // ASAZY came up as candidate during 3/30 run but not available on Robinhood
OnlyTradeSymbols=""; // This should be a comma separated list of symbols which would serve as the universe of symbols to trade. If null or empty then we trade everything in security master
OnlyTradeSymbols=""; // This should be a comma separated list of symbols which would serve as the universe of symbols to trade. If null or empty then we trade everything in security master
InitialCash=10000; // The initial cash
TotalRiskPercentDecimal=.05; // Total Risk of Initial Cash. The default is .02. I've been testing with .05
PositionRiskPercentDecimal=.12; // Risk per position - This will determine where the stop is placed. The default is .12
@@ -52,6 +49,7 @@ namespace MarketData.Generator.CMTrend
UseStopLimitScaling=true; // When set to true this will scale (tighten) the stop limit as time progresses based upon an anticipated holding period of StopLimitScalingDays.
StopLimitScalingType="AverageTrueRange"; // Acceptable types are "AverageTrueRange".
StopLimitScalingVolatilityDays=30; // StopLimitScalingVolatilityDays=5 The StopLimitScaling takes volatility into account. This parameter specifies how many days of pricing to use for the volatility calculation.
EvaluateStopOnUpTrend=false; // If set to true then the stop limit is only evaluated if prices are trending up.
SellOnDMABreak=true; // If true then we look lok for breaks of all DMAs listed under DMABreak
DMABreakValues="200"; // The defaut value is 200. This can be a comma separated list. For instance 50,100,200
DMABreakForceBreak=false; // If this flag is set to true then we will sell a security on DMA break even if it means taking a loss on the position.
@@ -142,6 +140,7 @@ namespace MarketData.Generator.CMTrend
public string UseProfitMaximizationExpression{get;set;}
public bool UseTradeOnlySectors{get;set;}
public String UseTradeOnlySectorsSectors{get;set;}
public bool EvaluateStopOnUpTrend { get; set; }
public void DisplayHeader()
{
@@ -213,6 +212,7 @@ namespace MarketData.Generator.CMTrend
nvpCollection.Add(new NVP("UseProfitMaximizationExpression",UseProfitMaximizationExpression.ToString()));
nvpCollection.Add(new NVP("UseTradeOnlySectors",UseTradeOnlySectors.ToString()));
nvpCollection.Add(new NVP("UseTradeOnlySectorsSectors",UseTradeOnlySectorsSectors.ToString()));
nvpCollection.Add(new NVP("EvaluateStopOnUpTrend",EvaluateStopOnUpTrend.ToString()));
return nvpCollection;
}
public static CMTParams FromNVPCollection(NVPCollection nvpCollection)
@@ -298,6 +298,10 @@ namespace MarketData.Generator.CMTrend
cmtParams.UseTradeOnlySectors=nvpDictionary["UseTradeOnlySectors"].Get<bool>();
cmtParams.UseTradeOnlySectorsSectors=nvpDictionary["UseTradeOnlySectorsSectors"].Get<String>();
}
if(nvpDictionary.ContainsKey("EvaluateStopOnUpTrend"))
{
cmtParams.EvaluateStopOnUpTrend=nvpDictionary["EvaluateStopOnUpTrend"].Get<bool>();
}
return cmtParams;
}
public void DisplayConfiguration()
@@ -365,6 +369,7 @@ namespace MarketData.Generator.CMTrend
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseProfitMaximizationExpression,{0}",UseProfitMaximizationExpression.ToString()));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseTradeOnlySectors,{0}",UseTradeOnlySectors.ToString()));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseTradeOnlySectorsSectors,{0}",UseTradeOnlySectorsSectors.ToString()));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("EvaluateStopOnUpTrend,{0}",EvaluateStopOnUpTrend.ToString()));
}
}
}