
using BinanceExchange.API.Models.Response;

public static class Patterns{
    public static bool GetTGOR(List<KlineCandleStickResponse> responses, int curIndex){
        if(curIndex < 10){
            return false;
        }
        

        int greenCount =0;
        
        for(int i=curIndex-4; i <= curIndex; i++){
            
            if(responses[i].Close < responses[i].Open){
                if(greenCount > 2){
                    //Red after 3 greens
                    int bullRunFlag = 0;
                    //This is an abomniation
                    if(responses[i-1].Close > responses[i-2].Close){
                        bullRunFlag++;
                    }
                    if(responses[i-2].Close > responses[i-3].Close){
                        bullRunFlag++;
                    }
                    if(responses[i-3].Close > responses[i-4].Close){
                        bullRunFlag++;
                    }
                    if(responses[i-4].Close > responses[i-5].Close){
                        bullRunFlag++;
                    }

                    if(responses[i-5].Close > responses[i-6].Close){
                        bullRunFlag++;
                    }

                    if(bullRunFlag > 2 && responses[i-1].Close < responses[i-1].Open){//It was a bull run
                        return true;
                    }

                    return true;
                }
                greenCount =0;
            }else{
                greenCount++;
            }
        }
        

        return false;
    }
}