101 lines
2.9 KiB
C#
101 lines
2.9 KiB
C#
using SignalsTest;
|
|
|
|
public static class Confirmations
|
|
{
|
|
public static float GetTWSConfirmation(List<TAReport> reports, int i)
|
|
{
|
|
float TWSHeightIncrement = 0;
|
|
|
|
if (i > 22)
|
|
{
|
|
bool hasCrossedST = false;
|
|
bool hasCrossedMA = false;
|
|
for (int z = 0; z < 20; z++)
|
|
{
|
|
if (!reports[i - z].STUp && reports[i].STUp)
|
|
{
|
|
hasCrossedST = true;
|
|
}
|
|
|
|
if (reports[i - z].SMA20 < reports[i - z].Open && reports[i].SMA20 > reports[i].Open)
|
|
{
|
|
hasCrossedMA = true;
|
|
}
|
|
}
|
|
|
|
if (hasCrossedMA) TWSHeightIncrement += 15;
|
|
if (hasCrossedST) TWSHeightIncrement += 15;
|
|
}
|
|
|
|
return TWSHeightIncrement;
|
|
}
|
|
|
|
public static float GetTBCConfirmation(List<TAReport> reports, int i)
|
|
{
|
|
float HeightIncrement = 0;
|
|
|
|
if (i > 22)
|
|
{
|
|
bool hasCrossedST = false;
|
|
bool hasCrossedMA = false;
|
|
for (int z = 0; z < 20; z++)
|
|
{
|
|
if (reports[i - z].STUp && !reports[i].STUp)
|
|
{
|
|
hasCrossedST = true;
|
|
}
|
|
|
|
if (reports[i - z].SMA20 > reports[i - z].Open && reports[i].SMA20 < reports[i].Open)
|
|
{
|
|
hasCrossedMA = true;
|
|
}
|
|
}
|
|
|
|
if (hasCrossedMA) HeightIncrement += 15;
|
|
if (hasCrossedST) HeightIncrement += 15;
|
|
}
|
|
|
|
return HeightIncrement;
|
|
}
|
|
|
|
public static List<decimal> GetResistanceLeevls(List<TAReport> reports, float tolerance = 0.1f, int steps = 5){
|
|
List<decimal> allResistances = new List<decimal>();
|
|
|
|
decimal highest = 0;
|
|
decimal lowest = 1000000000000000;
|
|
|
|
int lastMACross = 0;
|
|
for(int k =0; k < reports.Count; k++){
|
|
if(highest < reports[k].High){
|
|
highest = reports[k].High;
|
|
}
|
|
|
|
if(lowest > reports[k].Low){
|
|
lowest = reports[k].Low;
|
|
}
|
|
|
|
if(k <steps * 3){continue;} //not enough history
|
|
|
|
bool MATopNow = reports[k].SMA20 > reports[k].High;
|
|
bool MATopBefore = reports[k-1].SMA20 > reports[k-1].High;
|
|
|
|
bool MACrossed = MATopBefore!=MATopNow;
|
|
if(!MACrossed){continue;}//No cross
|
|
if(lastMACross == 0){
|
|
lastMACross = k;
|
|
continue; //First Cross
|
|
}
|
|
|
|
//Get lowest point between this and last cross
|
|
decimal lowestInPeriod = 1000000;
|
|
for(int i=k; i < lastMACross; i++ ){
|
|
if(reports[i].Low < lowestInPeriod){
|
|
lowestInPeriod=reports[i].Low;
|
|
}
|
|
}
|
|
allResistances.Add(lowestInPeriod);
|
|
}
|
|
|
|
return allResistances;
|
|
}
|
|
} |