init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using MarketData.MarketDataModel;
|
||||
using MarketData.Numerical;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// Richard Donchian Channel Breakout. Donchian used 20 days.
|
||||
|
||||
namespace MarketData.Generator.Indicators
|
||||
{
|
||||
public class ChannelBreakoutIndicator
|
||||
{
|
||||
private ChannelBreakoutIndicator()
|
||||
{
|
||||
}
|
||||
public static bool IsChannelBreakOut(DateTime tradeDate,Prices prices,int dayCount)
|
||||
{
|
||||
if(null==prices||prices.Count<dayCount||0==dayCount||prices[0].Date!=tradeDate) return false;
|
||||
return IsChannelBreakOut(prices[0],prices,dayCount);
|
||||
}
|
||||
public static bool IsChannelBreakOut(Price currentPrice,Prices prices,int dayCount)
|
||||
{
|
||||
if(null==prices||prices.Count<dayCount||null==currentPrice) return false;
|
||||
prices=new Prices(prices.Take(dayCount).ToList()); // use the dayCount range provided
|
||||
prices=new Prices(prices.Where(x => !(x.Date.Date.Equals(currentPrice.Date.Date))).ToList()); // make sure currentPrice is not in the list of prices
|
||||
int count=prices.Count(x => x.Close>=currentPrice.Close); // count how many closing prices are above or equal to our closing price
|
||||
return 0==count?true:false; // if no records then currentPrice is the max over the period so return true, otherwise return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user