Commit Latest
This commit is contained in:
@@ -33,12 +33,15 @@ namespace PortfolioManager.Renderers
|
||||
|
||||
public class BollingerBandRenderer : ModelBase
|
||||
{
|
||||
private String selectedSymbol = default;
|
||||
private int selectedDayCount = int.MinValue;
|
||||
private Price latestPrice = default;
|
||||
private Price zeroPrice = default;
|
||||
private bool showLabels = true;
|
||||
private bool showMarkers = true;
|
||||
private bool showLegend = false;
|
||||
private bool showTradeLabels = true;
|
||||
private bool showInsiderTransactions = true;
|
||||
private bool syncTradeToBand = true;
|
||||
private StopLimit stopLimit = default;
|
||||
private StopLimits stopLimits = default;
|
||||
@@ -48,11 +51,14 @@ namespace PortfolioManager.Renderers
|
||||
private BollingerBands bollingerBands;
|
||||
private InsiderTransactionSummaries insiderTransactionSummaries = null;
|
||||
|
||||
double maxBollingerDate = 0.00;
|
||||
double minBollingerDate = 0.00;
|
||||
double spread = 0.00;
|
||||
double percentShift3PC = 0.00;
|
||||
double percentShift1PC = 0.00;
|
||||
// double maxBollingerDate = 0.00;
|
||||
// double minBollingerDate = 0.00;
|
||||
//double spread = 0.00;
|
||||
double percentShiftHorz3PC = 0.00;
|
||||
double percentShiftHorz1PC = 0.00;
|
||||
double percentShiftVert3PC = 0.00;
|
||||
double percentShiftVert1PC = 0.00;
|
||||
double percentShiftVert5PC = 0.00;
|
||||
|
||||
public BollingerBandRenderer(AvaPlot plotter)
|
||||
{
|
||||
@@ -73,6 +79,15 @@ namespace PortfolioManager.Renderers
|
||||
if (!ShowLegend) Plotter.Plot.HideLegend();
|
||||
else Plotter.Plot.ShowLegend();
|
||||
}
|
||||
else if (eventArgs.PropertyName.Equals("ShowLegend"))
|
||||
{
|
||||
if (!ShowLegend) Plotter.Plot.HideLegend();
|
||||
else Plotter.Plot.ShowLegend();
|
||||
}
|
||||
else if (eventArgs.PropertyName.Equals("ShowInsiderTransactions"))
|
||||
{
|
||||
SetData(selectedSymbol, selectedDayCount);
|
||||
}
|
||||
}
|
||||
|
||||
public void Render()
|
||||
@@ -84,6 +99,8 @@ namespace PortfolioManager.Renderers
|
||||
|
||||
public void SetData(String selectedSymbol, int selectedDayCount)
|
||||
{
|
||||
this.selectedSymbol = selectedSymbol;
|
||||
this.selectedDayCount = selectedDayCount;
|
||||
stopLimit = PortfolioDA.GetStopLimit(selectedSymbol);
|
||||
portfolioTrades = PortfolioDA.GetTradesSymbol(selectedSymbol);
|
||||
portfolioTradesLots = LotAggregator.CombineLots(portfolioTrades);
|
||||
@@ -129,11 +146,18 @@ namespace PortfolioManager.Renderers
|
||||
}
|
||||
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||
|
||||
maxBollingerDate = bollingerBands.Max(x=>x.Date).ToOADate();
|
||||
minBollingerDate = bollingerBands.Min(x=>x.Date).ToOADate();
|
||||
spread = (maxBollingerDate - minBollingerDate);
|
||||
percentShift3PC = spread * .03;
|
||||
percentShift1PC = spread * .01;
|
||||
double maxBollingerDate = bollingerBands.Max(x=>x.Date).ToOADate();
|
||||
double minBollingerDate = bollingerBands.Min(x=>x.Date).ToOADate();
|
||||
double maxBollingerValue = bollingerBands.Max(x=>x.K);
|
||||
double minBollingerValue = bollingerBands.Min(x=>x.L);
|
||||
|
||||
double spreadHorz = (maxBollingerDate - minBollingerDate);
|
||||
double spreadVert = (maxBollingerValue - minBollingerValue);
|
||||
percentShiftHorz3PC = spreadHorz * .03;
|
||||
percentShiftHorz1PC = spreadHorz * .01;
|
||||
percentShiftVert3PC = spreadVert * .03;
|
||||
percentShiftVert1PC = spreadVert * .01;
|
||||
percentShiftVert5PC = spreadVert * .05;
|
||||
|
||||
GenerateBollingerBands();
|
||||
GenerateZeroPoint(zeroPrice);
|
||||
@@ -233,7 +257,7 @@ namespace PortfolioManager.Renderers
|
||||
|
||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 155, 24, FontFactor.FontSize);
|
||||
// Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate()/(1+onePercent), stopLimit.StopPrice - 5.00);
|
||||
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate()-percentShift3PC, stopLimit.StopPrice - 5.00);
|
||||
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate()-percentShiftHorz3PC, stopLimit.StopPrice - 5.00);
|
||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||
}
|
||||
}
|
||||
@@ -245,7 +269,6 @@ namespace PortfolioManager.Renderers
|
||||
{
|
||||
if (null == portfolioTradesLots || 0 == portfolioTradesLots.Count || !showTradeLabels) return;
|
||||
// Here we add the image markers
|
||||
|
||||
Image tradePointMarker = TextMarkerImageGenerator.ToSPImage(ImageCache.GetInstance().GetImage(ImageCache.ImageType.YellowTriangleUp));
|
||||
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
||||
{
|
||||
@@ -265,7 +288,7 @@ namespace PortfolioManager.Renderers
|
||||
sb.Append(Utility.FormatCurrency(portfolioTrade.Price));
|
||||
|
||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 150, 24, FontFactor.FontSize);
|
||||
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(), portfolioTrade.Price - 5.00);
|
||||
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(), portfolioTrade.Price - percentShiftVert5PC);
|
||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||
}
|
||||
}
|
||||
@@ -275,7 +298,7 @@ namespace PortfolioManager.Renderers
|
||||
/// </summary>
|
||||
private void GenerateInsiderTransactions()
|
||||
{
|
||||
if (null == prices || 0 == prices.Count || !ShowMarkers) return;
|
||||
if (null == prices || 0 == prices.Count || !ShowInsiderTransactions) return;
|
||||
ImageMarker imageMarker = default;
|
||||
Coordinates coordinates = default;
|
||||
|
||||
@@ -512,6 +535,19 @@ namespace PortfolioManager.Renderers
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowInsiderTransactions
|
||||
{
|
||||
get
|
||||
{
|
||||
return showInsiderTransactions;
|
||||
}
|
||||
set
|
||||
{
|
||||
showInsiderTransactions = value;
|
||||
base.OnPropertyChanged("ShowInsiderTransactions");
|
||||
}
|
||||
}
|
||||
|
||||
public AvaPlot Plotter { get; private set; }
|
||||
|
||||
private CompositeDataSource InsiderTransactionPointDisposedSmall { get; set; } = Empty();
|
||||
|
||||
Reference in New Issue
Block a user