diff --git a/CoinWatch.cs b/CoinWatch.cs index fd7cba4..aee5504 100644 --- a/CoinWatch.cs +++ b/CoinWatch.cs @@ -120,9 +120,12 @@ namespace SignalsTest // triggers += "Price dropped\n"; // } - if(reports[reports.Count-2].TWS > 0){ + if(reports[reports.Count-2].TWS > 1){ triggers += $"Three White Soldiers appeared"; } + if(reports[reports.Count-2].TBC > 1){ + triggers += $"Three Black Crows appeared"; + } if(triggers!= ""){ Picasso.DrawChart(reports, max ,min, maxVol, symbol); diff --git a/CoinsList.cs b/CoinsList.cs index 93e812d..2905700 100644 --- a/CoinsList.cs +++ b/CoinsList.cs @@ -2,6 +2,7 @@ public static class CoinsList{ public static List symbols= [ "BTCUSDT", "ADAUSDT", + "AIXBTUSDT", "XRPUSDT", "XLMUSDT", "SOLUSDT", diff --git a/Confirmations.cs b/Confirmations.cs new file mode 100644 index 0000000..6369bc8 --- /dev/null +++ b/Confirmations.cs @@ -0,0 +1,60 @@ +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; + } +} \ No newline at end of file diff --git a/Patterns.cs b/Patterns.cs index 4c8d94b..a5e4963 100644 --- a/Patterns.cs +++ b/Patterns.cs @@ -84,6 +84,41 @@ public static class Patterns{ return 0; } + public static int GetThreeBlackCrows(List responses, int curIndex){ + if(curIndex < 10){ + return 0; + } + + KlineCandleStickResponse candle1 = responses[curIndex]; + KlineCandleStickResponse candle2 = responses[curIndex-1]; + KlineCandleStickResponse candle3 = responses[curIndex-2]; + + bool isAllRed = !candle1.isGreen() && !candle2.isGreen() && !candle3.isGreen(); + + //LP:using average shadow is a bad idea, check each shadow + // float averageShadowRatio = (candle1.getShadowRatio() + candle2.getShadowRatio() + candle3.getShadowRatio())/3f; + + + bool areSoldiers = AreAllSolid([candle1,candle2, candle3],0.6f); + bool areSoldiersThin = AreAllSolid([candle1,candle2, candle3], 0.4f); + + + bool areSameSize = AreSameCandleSizes([candle1,candle2,candle3]); + + if(isAllRed && areSoldiers && areSameSize){ + //Best + return 3; + }else if(isAllRed&& areSoldiersThin && areSameSize){ + //Not strong + return 2; + }else if(isAllRed){ + //Meh + return 1; + } + + return 0; + } + public static bool AreSameCandleSizes(List responses, float tolerance= 0.5f){ float totalHeight = 0; diff --git a/Picasso.cs b/Picasso.cs index e307fec..bb20fe4 100644 --- a/Picasso.cs +++ b/Picasso.cs @@ -53,12 +53,19 @@ public class Picasso{ ); #endregion - #region TWS + + float squareOffset = 2; + PointF[] bottomPoints = new PointF[2]; - bottomPoints[0] = new PointF(i * widthMultiplier, lowVal+ candlesOffset); + bottomPoints[0] = new PointF(i * widthMultiplier, lowVal-squareOffset+ candlesOffset); bottomPoints[1] = new PointF(i * widthMultiplier, lowVal- 15+ candlesOffset); - + + PointF[] topPoints = new PointF[2]; + topPoints[0] = new PointF(i * widthMultiplier, highVal+squareOffset+ candlesOffset); + topPoints[1] = new PointF(i * widthMultiplier, highVal+15+ candlesOffset); + + #region TWS if(reports[i].TWS > 1){ Color TWSColor = Color.Blue; if(reports[i].TWS == 2){ @@ -66,30 +73,28 @@ public class Picasso{ }else if(reports[i].TWS== 3){ TWSColor = Color.White; } - - float TWSHeight = 15; + float TWSHeightIncrement = Confirmations.GetTWSConfirmation(reports,i); - 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) TWSHeight+=15; - if(hasCrossedST) TWSHeight+=15; - } - - - img.Mutate(ctx=>ctx.DrawLine(TWSColor, TWSHeight, bottomPoints)); + PointF[] TWSPoints = bottomPoints; + TWSPoints[1]-= new PointF(0,TWSHeightIncrement); + img.Mutate(ctx=>ctx.DrawLine(TWSColor, 10, TWSPoints)); } #endregion +#region TBC + if(reports[i].TBC > 1){ + Color TBCColor = Color.Red; + if(reports[i].TBC == 2){ + TBCColor = Color.Cyan; + }else if(reports[i].TBC== 3){ + TBCColor = Color.White; + } + float TBCHeightIncremenet = Confirmations.GetTBCConfirmation(reports,i); + + PointF[] TBCPoints = topPoints; + TBCPoints[1]+= new PointF(0,TBCHeightIncremenet); + img.Mutate(ctx=>ctx.DrawLine(TBCColor, 10, TBCPoints)); + } +#endregion } // Console.WriteLine("Getting paths"); diff --git a/TAReport.cs b/TAReport.cs index 2c29fb0..af87bb8 100644 --- a/TAReport.cs +++ b/TAReport.cs @@ -40,6 +40,7 @@ namespace SignalsTest public decimal RSI = 0; public int TWS =0; + public int TBC = 0; public bool STUp = false; public bool TGOR=false; @@ -140,7 +141,7 @@ namespace SignalsTest report.TGOR= Patterns.GetTGOR(response, index); report.TWS = Patterns.GetThreeWhiteSoldiers(response,index); - + report.TBC = Patterns.GetThreeBlackCrows(response, index); return report;