Work on Bollinger Bands.
This commit is contained in:
@@ -36,7 +36,7 @@ namespace TradeBlotter.ViewModels
|
||||
private static readonly String BAND_MESSAGE="Generating Bollinger Band...";
|
||||
private static readonly String DATA_MESSAGE="Loading Pricing Data...";
|
||||
private BollingerBands bollingerBands;
|
||||
private StopLimit stopLimit; // This is the stop limit that is looked up in the database and displayed (if there is one)
|
||||
private StopLimits internalStopLimits; // This is the stop limit that is looked up in the database and displayed (if there is one)
|
||||
private StopLimits stopLimits; // These stop limits might be passed in with the SaveParams. (i.e.) MMTRend model passes in StopLimits. If these are passsed in then they are displayed instead of stopLimit.
|
||||
private String symbol;
|
||||
private String companyName;
|
||||
@@ -220,7 +220,7 @@ namespace TradeBlotter.ViewModels
|
||||
prices=null;
|
||||
portfolioTrades=null;
|
||||
portfolioTradesLots=null;
|
||||
stopLimit=null;
|
||||
internalStopLimits=null;
|
||||
}
|
||||
|
||||
if (eventArgs.PropertyName.Equals("SyncTradeToBand")||
|
||||
@@ -238,7 +238,7 @@ namespace TradeBlotter.ViewModels
|
||||
BusyContent=DATA_MESSAGE;
|
||||
|
||||
// DEBUG
|
||||
stopLimit=StopLimitDA.GetStopLimit(symbol);
|
||||
internalStopLimits=StopLimitDA.GetStopLimits(symbol);
|
||||
portfolioTrades = PortfolioDA.GetTradesSymbol(symbol);
|
||||
portfolioTradesLots=LotAggregator.CombineLots(portfolioTrades);
|
||||
if (null != portfolioTrades && 0 != portfolioTrades.Count)
|
||||
@@ -442,9 +442,9 @@ namespace TradeBlotter.ViewModels
|
||||
{
|
||||
compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(stopLimits);
|
||||
}
|
||||
else if(null!=stopLimit && null!=zeroPrice)
|
||||
else if(null!=internalStopLimits && null!=zeroPrice)
|
||||
{
|
||||
compositeDataSourceStopLimit=GainLossModel.CreateCompositeDataSource(zeroPrice.Date,stopLimit.StopPrice);
|
||||
compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(zeroPrice.Date,stopLimits);
|
||||
}
|
||||
|
||||
compositeDataSourceInsiderTransactionPointDisposedSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]),minClose);
|
||||
@@ -784,19 +784,43 @@ namespace TradeBlotter.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
if(null==zeroPrice)return null;
|
||||
if(null==stopLimit||null==zeroPrice||!showTradeLabels) return null;
|
||||
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";
|
||||
if (null == zeroPrice) return null;
|
||||
if (null == internalStopLimits || null == zeroPrice || !showTradeLabels) return null;
|
||||
for(int index=0;index<internalStopLimits.Count;index++)
|
||||
{
|
||||
StopLimit limit=internalStopLimits[index];
|
||||
CenteredTextMarker centerTextMarker=new CenteredTextMarker();
|
||||
|
||||
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(")");
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user