using SignalsTest; public static class Confirmations { public static float GetTWSConfirmation(List 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 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 GetSupportiveLevels(List reports, float tolerance = 0.1f, int steps = 5, string SMA="SMA20"){ List allSups = new List(); decimal highest = 0; decimal lowest = 1000000000000000; int lastMACross = 0; for(int k =0; k < reports.Count; k++){ if(highest < reports[k].candle.High){ highest = reports[k].candle.High; } if(lowest > reports[k].candle.Low){ lowest = reports[k].candle.Low; } if(k reports[k].candle.High; bool MATopBefore = decimal.Parse(Utils.GetPropByName(reports[k-1], SMA).ToString() ?? "0") > reports[k-1].candle.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=lastMACross; i < k; i++ ){ if(reports[i].candle.Low < lowestInPeriod){ decimal candleBot = reports[i].candle.Open < reports[i].candle.Close ? reports[i].candle.Open : reports[i].candle.Close; lowestInPeriod=candleBot; } } allSups.Add(lowestInPeriod); } List formattedSups = new List(); decimal range = highest-lowest; foreach(decimal sup in allSups){ formattedSups.Add(sup); } return formattedSups; } public static List GetResistanceLevels(List reports, float tolerance = 0.1f, int steps = 5, string SMA="SMA20"){ List allResistances = new List(); decimal highest = 0; decimal lowest = 1000000000000000; int lastMACross = 0; for(int k =0; k < reports.Count; k++){ if(highest < reports[k].candle.High){ highest = reports[k].candle.High; } if(lowest > reports[k].candle.Low){ lowest = reports[k].candle.Low; } if(k reports[k].candle.High; bool MATopBefore = decimal.Parse(Utils.GetPropByName(reports[k-1], SMA).ToString() ?? "0") > reports[k-1].candle.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 highestInPeriod = 0; for(int i=lastMACross; i < k; i++ ){ if(reports[i].candle.High > highestInPeriod){ decimal candleTop = reports[i].candle.Open > reports[i].candle.Close ? reports[i].candle.Open : reports[i].candle.Close; highestInPeriod=candleTop; } } allResistances.Add(highestInPeriod); } List formattedResistances = new List(); decimal range = highest-lowest; foreach(decimal resistance in allResistances){ formattedResistances.Add(resistance); } return formattedResistances; } }