Add PriceLow to MSHMomentumViewModel. Fix bug in CM EDit Position.

This commit is contained in:
2025-03-03 19:42:57 -05:00
parent 912471d94c
commit 508c0bee20
4 changed files with 29 additions and 5 deletions

View File

@@ -289,9 +289,15 @@ namespace TradeBlotter.Model
get
{
if(!IsActivePosition) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Blue);
if(currentPriceLow<=position.TrailingStopLimit)
{
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Red);
}
StopLimit stopLimit=PortfolioDA.GetStopLimit(position.Symbol);
if(null==stopLimit||!stopLimit.StopPrice.Equals(Math.Round(position.TrailingStopLimit,2))) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Purple);
if(currentPriceLow<=position.TrailingStopLimit)return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Red);
if(null==stopLimit || !stopLimit.StopPrice.Equals(Math.Round(position.TrailingStopLimit,2)))
{
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Purple);
}
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
}
}

View File

@@ -139,6 +139,20 @@ namespace TradeBlotter.Model
}
}
public double CurrentPriceLow
{
get{return currentPriceLow;}
set
{
if(currentPriceLow==value)return;
currentPriceLow=value;
base.OnPropertyChanged("CurrentPriceLow");
base.OnPropertyChanged("CurrentPriceLowAsString");
base.OnPropertyChanged("TrailingStopLimitColor");
base.OnPropertyChanged("InitialStopLimitColor");
}
}
private void UpdateProperties()
{
base.OnPropertyChanged("CurrentPrice");
@@ -559,9 +573,12 @@ namespace TradeBlotter.Model
get
{
if(!IsActivePosition) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Blue);
if(currentPriceLow <= position.TrailingStopLimit)
{
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Red);
}
StopLimit stopLimit=PortfolioDA.GetStopLimit(position.Symbol);
if(null==stopLimit||!stopLimit.StopPrice.Equals(Math.Round(position.TrailingStopLimit,2))) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Purple);
if(currentPriceLow<=position.TrailingStopLimit)return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Red);
if(null==stopLimit || !stopLimit.StopPrice.Equals(Math.Round(position.TrailingStopLimit,2))) return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Purple);
return BrushCollection.GetContextBrush(BrushCollection.BrushColor.Black);
}
}

View File

@@ -1063,7 +1063,7 @@ namespace TradeBlotter.ViewModels
MessageBox.Show("Failed to close the position, check log for details.", "Close Position");
return;
}
String strMessage = String.Format("Closed position for {0}, Purchase Date:{1}, Sell Date{2}, Current Price:{3}. Saved to {4}. A backup was created.",
String strMessage = String.Format("Closed position for {0}, Sell Date{1}, Current Price:{2}. Saved to {3}. A backup was created.",
changedPosition.Symbol,
changedPosition.SellDate.ToShortDateString(),
Utility.FormatCurrency(changedPosition.CurrentPrice),

View File

@@ -1300,6 +1300,7 @@ namespace TradeBlotter.ViewModels
Price price=PricingDA.GetPrice(symbol);
if(null==price)continue;
selectedPosition.CurrentPrice=price.Close;
selectedPosition.CurrentPriceLow=price.Low;
selectedPosition.Volume=price.Volume;
selectedPosition.LastUpdated=price.Date.Date<today.Date?price.Date:today;
}