Handle multiple stop limits in the stop limit table and display them properly.

This commit is contained in:
2026-02-18 18:57:00 -05:00
parent cddf7202b1
commit a510a63772
3 changed files with 5 additions and 34 deletions

View File

@@ -444,7 +444,7 @@ namespace TradeBlotter.ViewModels
}
else if(null!=internalStopLimits && null!=zeroPrice)
{
compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(zeroPrice.Date,stopLimits);
compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(zeroPrice.Date,internalStopLimits);
}
compositeDataSourceInsiderTransactionPointDisposedSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]),minClose);
@@ -786,6 +786,7 @@ namespace TradeBlotter.ViewModels
{
if (null == zeroPrice) return null;
if (null == internalStopLimits || null == zeroPrice || !showTradeLabels) return null;
Price latestPrice=prices[0];
for(int index=0;index<internalStopLimits.Count;index++)
{
StopLimit limit=internalStopLimits[index];
@@ -794,33 +795,14 @@ namespace TradeBlotter.ViewModels
StringBuilder sb=new StringBuilder();
sb.Append(limit.StopType).Append(" ");
sb.Append(Utility.FormatCurrency(limit.StopPrice));
if(index==internalStopLimits.Count-1)
{
Price latestPrice=prices[0]; // always use the most recent price when calculating the spread (in percent) from the active stop limit.
double percentOffsetFromLow=((latestPrice.Low-limit.StopPrice)/limit.StopPrice);
sb.Append(" (").Append(percentOffsetFromLow>0?"+":"").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
}
double percentOffsetFromLow=((latestPrice.Low-limit.StopPrice)/limit.StopPrice);
sb.Append(" (").Append(percentOffsetFromLow>0?"+":"").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
centerTextMarker.Text=sb.ToString();
if(0==index&&internalStopLimits.Count>1) centerTextMarker.VerticalShift="25";
else centerTextMarker.VerticalShift="40";
centerTextMarker.HorizontalShift="32";
centeredTextMarkers.Add(centerTextMarker);
}
//CenteredTextMarker centerTextMarker=new CenteredTextMarker();
//Price latestPrice=prices[0];
//double percentOffsetFromLow=((latestPrice.Low-stopLimit.StopPrice)/stopLimit.StopPrice);
//StringBuilder sb=new StringBuilder();
//sb.Append(stopLimit.StopType).Append(" ");
//sb.Append(Utility.FormatCurrency(stopLimit.StopPrice));
//sb.Append(" (").Append(percentOffsetFromLow>0?"+":"").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
//centerTextMarker.Text=sb.ToString();
//centeredTextMarkers.Add(centerTextMarker);
//centerTextMarker.VerticalShift="40";
//centerTextMarker.HorizontalShift="32";
}
return centeredTextMarkers.ToArray();
}