Three black crows with some refactors
This commit is contained in:
parent
2a07769ba2
commit
37743d7349
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ public static class CoinsList{
|
|||
public static List<string> symbols= [
|
||||
"BTCUSDT",
|
||||
"ADAUSDT",
|
||||
"AIXBTUSDT",
|
||||
"XRPUSDT",
|
||||
"XLMUSDT",
|
||||
"SOLUSDT",
|
||||
|
|
|
|||
60
Confirmations.cs
Normal file
60
Confirmations.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
35
Patterns.cs
35
Patterns.cs
|
|
@ -84,6 +84,41 @@ public static class Patterns{
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static int GetThreeBlackCrows(List<KlineCandleStickResponse> 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<KlineCandleStickResponse> responses, float tolerance= 0.5f){
|
||||
float totalHeight = 0;
|
||||
|
|
|
|||
53
Picasso.cs
53
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");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user