Initial Commit
This commit is contained in:
52
MarketData/MarketDataLib/MarketDataModel/SignalHolder.cs
Executable file
52
MarketData/MarketDataLib/MarketDataModel/SignalHolder.cs
Executable file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MarketData.MarketDataModel
|
||||
{
|
||||
public class SignHolder
|
||||
{
|
||||
public enum SignValue { Positive, Negative, Undefined };
|
||||
private double currentValue;
|
||||
private double previousValue;
|
||||
|
||||
public SignHolder()
|
||||
{
|
||||
currentValue = previousValue = 0.00;
|
||||
}
|
||||
public void SetValue(double value)
|
||||
{
|
||||
if (value == 0.00)
|
||||
{
|
||||
previousValue = currentValue;
|
||||
return;
|
||||
}
|
||||
previousValue = currentValue;
|
||||
currentValue = value;
|
||||
}
|
||||
public bool SignChange
|
||||
{
|
||||
get
|
||||
{
|
||||
if (previousValue < 0.00 && currentValue > 0.00) return true;
|
||||
if (previousValue > 0.00 && currentValue < 0.00) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public double PreviousValue
|
||||
{
|
||||
get { return previousValue; }
|
||||
}
|
||||
public double CurrentValue
|
||||
{
|
||||
get { return currentValue; }
|
||||
}
|
||||
public String GetValueString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("[").Append(previousValue).Append("->").Append(currentValue).Append("]");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user