Initial Commit
This commit is contained in:
103
MarketData/MarketDataLib/MarketDataModel/ResistanceSupport.cs
Executable file
103
MarketData/MarketDataLib/MarketDataModel/ResistanceSupport.cs
Executable file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using MarketData.Utils;
|
||||
|
||||
namespace MarketData.MarketDataModel
|
||||
{
|
||||
public class ResistanceSupport
|
||||
{
|
||||
private Price price;
|
||||
private double resistance1;
|
||||
private double support1;
|
||||
private double resistance2;
|
||||
private double support2;
|
||||
private double resistance3;
|
||||
private double support3;
|
||||
|
||||
public ResistanceSupport(Price price)
|
||||
{ // calculate pivot points
|
||||
this.price = price;
|
||||
double pivot=(price.Low+price.Close+price.High)/3.00;
|
||||
resistance1=(2.00*pivot)-price.Low;
|
||||
support1=(2.00*pivot)-price.High;
|
||||
resistance2 = pivot + (price.High - price.Low);
|
||||
support2 = pivot - (price.High - price.Low);
|
||||
resistance3 = price.High + 2.00*(pivot-price.Low);
|
||||
support3 = price.Low - 2.00*(price.High - pivot);
|
||||
}
|
||||
public double Resistance1
|
||||
{
|
||||
get { return resistance1; }
|
||||
}
|
||||
public double Support1
|
||||
{
|
||||
get { return support1; }
|
||||
}
|
||||
public double Resistance2
|
||||
{
|
||||
get { return resistance2; }
|
||||
}
|
||||
public double Support2
|
||||
{
|
||||
get { return support2; }
|
||||
}
|
||||
public double Resistance3
|
||||
{
|
||||
get { return resistance3; }
|
||||
}
|
||||
public double Support3
|
||||
{
|
||||
get { return support3; }
|
||||
}
|
||||
public double High
|
||||
{
|
||||
get { return price.High; }
|
||||
}
|
||||
public double Low
|
||||
{
|
||||
get { return price.Low; }
|
||||
}
|
||||
public double Close
|
||||
{
|
||||
get { return price.Close; }
|
||||
}
|
||||
public DateTime Date
|
||||
{
|
||||
get { return price.Date; }
|
||||
}
|
||||
public static string Header
|
||||
{
|
||||
get { return "Symbol,Date,R1,S1,R2,S2,R3,S3,High,Low,Close"; }
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(price.Symbol).Append(",");
|
||||
sb.Append(Utility.DateTimeToStringMMHDDHYYYY(price.Date)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(resistance1)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(support1)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(resistance2)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(support2)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(resistance3)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(support3)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(price.High)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(price.Low)).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(price.Close));
|
||||
return sb.ToString();
|
||||
}
|
||||
public string ToStringLong()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("******** R E S I S T A N C E A N D S U P P O R T ****").Append("\n");
|
||||
sb.Append("R3:").Append(Utility.FormatCurrency(resistance3)).Append("\n");
|
||||
sb.Append("R2:").Append(Utility.FormatCurrency(resistance2)).Append("\n");
|
||||
sb.Append("R1:").Append(Utility.FormatCurrency(resistance1)).Append("\n");
|
||||
sb.Append("***************************************").Append("\n");
|
||||
sb.Append("S1:").Append(Utility.FormatCurrency(support1)).Append("\n");
|
||||
sb.Append("S2:").Append(Utility.FormatCurrency(support2)).Append("\n");
|
||||
sb.Append("S3:").Append(Utility.FormatCurrency(support3)).Append("\n");
|
||||
sb.Append("*************************************************************");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user