Fixed threshold filters for minus and applied to off triggers as well
This commit is contained in:
parent
1b2908d8a8
commit
012ad0e8f2
|
@ -1626,14 +1626,45 @@ namespace Core.Main
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check for market trend triggers
|
// Check for market trend Off triggers
|
||||||
if (this.SingleMarketTrendChanges.ContainsKey(offTrigger.MarketTrendName))
|
if (this.SingleMarketTrendChanges.ContainsKey(offTrigger.MarketTrendName))
|
||||||
{
|
{
|
||||||
List<MarketTrendChange> marketTrendChanges = this.SingleMarketTrendChanges[offTrigger.MarketTrendName];
|
List<MarketTrendChange> marketTrendChanges = this.SingleMarketTrendChanges[offTrigger.MarketTrendName];
|
||||||
List<MarketTrend> marketTrends = this.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends;
|
List<MarketTrend> marketTrends = this.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends;
|
||||||
|
|
||||||
if (marketTrendChanges.Count > 0)
|
if (marketTrendChanges.Count > 0)
|
||||||
{
|
{
|
||||||
double averageMarketTrendChange = marketTrendChanges.Average(m => m.TrendChange);
|
double averageMarketTrendChange = 0;
|
||||||
|
var trendThreshold = (from mt in this.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends
|
||||||
|
where mt.Name == offTrigger.MarketTrendName
|
||||||
|
select new { mt.TrendThreshold }).Single();
|
||||||
|
|
||||||
|
// Calculate average market change, skip any that are outside the threshold if enabled
|
||||||
|
if (trendThreshold.TrendThreshold != 0)
|
||||||
|
{
|
||||||
|
// Exclude trends outside the threshhold.
|
||||||
|
var excludedMarkets = from m in marketTrendChanges
|
||||||
|
where m.TrendChange > trendThreshold.TrendThreshold || m.TrendChange < (trendThreshold.TrendThreshold * -1.0)
|
||||||
|
orderby m.Market
|
||||||
|
select m;
|
||||||
|
|
||||||
|
foreach (var marketTrend in excludedMarkets)
|
||||||
|
{
|
||||||
|
this.Log.DoLogInfo(String.Format("SMS Off Trigger for '{0}' is ignoring {1} for exceeding TrendThreshold {2}% with {3} on {4}", marketSetting.SettingName, marketTrend.Market, (double)trendThreshold.TrendThreshold, Math.Round(marketTrend.TrendChange, 3, MidpointRounding.ToEven), offTrigger.MarketTrendName));
|
||||||
|
}
|
||||||
|
|
||||||
|
var includedMarkets = from m in marketTrendChanges
|
||||||
|
where m.TrendChange <= trendThreshold.TrendThreshold && m.TrendChange >= (trendThreshold.TrendThreshold * -1.0)
|
||||||
|
orderby m.Market
|
||||||
|
select m;
|
||||||
|
|
||||||
|
averageMarketTrendChange = includedMarkets.Average(m => m.TrendChange);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Calculate for whole market
|
||||||
|
averageMarketTrendChange = marketTrendChanges.Average(m => m.TrendChange);
|
||||||
|
}
|
||||||
|
|
||||||
MarketTrendChange mtc = marketTrendChanges.Find(m => m.Market.Equals(marketPair, StringComparison.InvariantCultureIgnoreCase));
|
MarketTrendChange mtc = marketTrendChanges.Find(m => m.Market.Equals(marketPair, StringComparison.InvariantCultureIgnoreCase));
|
||||||
if (mtc != null)
|
if (mtc != null)
|
||||||
|
@ -1827,17 +1858,17 @@ namespace Core.Main
|
||||||
{
|
{
|
||||||
// Exclude trends outside the threshhold.
|
// Exclude trends outside the threshhold.
|
||||||
var excludedMarkets = from m in marketTrendChanges
|
var excludedMarkets = from m in marketTrendChanges
|
||||||
where m.TrendChange > trendThreshold.TrendThreshold
|
where m.TrendChange > trendThreshold.TrendThreshold || m.TrendChange < (trendThreshold.TrendThreshold * -1.0)
|
||||||
orderby m.Market
|
orderby m.Market
|
||||||
select m;
|
select m;
|
||||||
|
|
||||||
foreach (var marketTrend in excludedMarkets)
|
foreach (var marketTrend in excludedMarkets)
|
||||||
{
|
{
|
||||||
this.Log.DoLogInfo("SMS Trigger for '" + marketSetting.SettingName + "' is ignoring " + marketTrend.Market + " for exceeding TrendThreshold " + trendThreshold.TrendThreshold + " on " + trigger.MarketTrendName);
|
this.Log.DoLogInfo(String.Format("SMS Trigger for '{0}' is ignoring {1} for exceeding TrendThreshold {2}% with {3} on {4}", marketSetting.SettingName, marketTrend.Market, (double)trendThreshold.TrendThreshold, Math.Round(marketTrend.TrendChange, 3, MidpointRounding.ToEven), trigger.MarketTrendName));
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedMarkets = from m in marketTrendChanges
|
var includedMarkets = from m in marketTrendChanges
|
||||||
where m.TrendChange <= trendThreshold.TrendThreshold
|
where m.TrendChange <= trendThreshold.TrendThreshold && m.TrendChange >= (trendThreshold.TrendThreshold * -1.0)
|
||||||
orderby m.Market
|
orderby m.Market
|
||||||
select m;
|
select m;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue