예제 #1
0
    public Operation GetOperationDetail(double[] arrayPriceOpen, double[] arrayPriceClose, double[] arrayPriceLow, double[] arrayPriceHigh, double[] arrayVolume)
    {
        try
        {
            int      atr1 = 0;
            int      atr2 = 0;
            double[] atr3 = new double[arrayPriceClose.Length];
            TicTacTec.TA.Library.Core.Atr(0, arrayPriceClose.Length - 1, arrayPriceHigh, arrayPriceLow, arrayPriceClose, 14, out atr1, out atr2, atr3);
            double atrVal = atr3[atr2 - 1];

            IndicatorMACD macd          = new IndicatorMACD();
            Operation     operationMACD = macd.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            IndicatorCCI cci          = new IndicatorCCI();
            Operation    operationCCI = cci.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            IndicatorRSI rsi          = new IndicatorRSI();
            Operation    operationRSI = rsi.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            //TicTacTec.TA.Library.Core.Atr();

            MainClass.log("CCI: " + cci.result);
            MainClass.log("CCI Tendency: " + cci.getTendency());
            MainClass.log("RSI: " + rsi.result);
            MainClass.log("RSI Tendency: " + rsi.getTendency());
            MainClass.log("MACD: " + macd.result);
            if (MainClass.carolatr)
            {
                MainClass.log("ATR: " + atrVal);
            }

            if (cci.result > 0 && operationMACD == Operation.buy && rsi.result > 50 && cci.getTendency() == Tendency.high && rsi.getTendency() == Tendency.high && ((MainClass.carolatr && atrVal < MainClass.atrvalue) || !MainClass.carolatr))
            //if (operationMACD == Operation.buy)
            {
                double[] arrayresultMA = new double[arrayPriceClose.Length];
                int      outBegidx, outNbElement;
                TicTacTec.TA.Library.Core.MovingAverage(0, arrayPriceClose.Length - 1, arrayPriceClose, 100, TicTacTec.TA.Library.Core.MAType.Ema, out outBegidx, out outNbElement, arrayresultMA);
                if (arrayPriceClose[arrayPriceClose.Length - 1] > arrayresultMA[outNbElement - 1])
                {
                    return(Operation.buy);
                }
            }
            if (cci.result < 0 && operationMACD == Operation.sell && rsi.result < 50 && cci.getTendency() == Tendency.low && rsi.getTendency() == Tendency.low && ((MainClass.carolatr && atrVal < MainClass.atrvalue) || !MainClass.carolatr))
            //if (operationMACD == Operation.sell)
            {
                double[] arrayresultMA = new double[arrayPriceClose.Length];
                int      outBegidx, outNbElement;
                TicTacTec.TA.Library.Core.MovingAverage(0, arrayPriceClose.Length - 1, arrayPriceClose, 100, TicTacTec.TA.Library.Core.MAType.Ema, out outBegidx, out outNbElement, arrayresultMA);
                if (arrayPriceClose[arrayPriceClose.Length - 1] < arrayresultMA[outNbElement - 1])
                {
                    return(Operation.sell);
                }
            }
            return(Operation.nothing);
        }
        catch
        {
            return(Operation.nothing);
        }
    }
예제 #2
0
    public Operation GetOperationDetail(double[] arrayPriceOpen, double[] arrayPriceClose, double[] arrayPriceLow, double[] arrayPriceHigh, double[] arrayVolume)
    {
        try
        {
            int      atr1 = 0;
            int      atr2 = 0;
            double[] atr3 = new double[arrayPriceClose.Length];
            TicTacTec.TA.Library.Core.Atr(0, arrayPriceClose.Length - 1, arrayPriceHigh, arrayPriceLow, arrayPriceClose, 14, out atr1, out atr2, atr3);
            double atrVal = atr3[atr2 - 1];

            IndicatorMACD macd          = new IndicatorMACD();
            Operation     operationMACD = macd.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            IndicatorCCI cci          = new IndicatorCCI();
            Operation    operationCCI = cci.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            IndicatorRSI rsi          = new IndicatorRSI();
            Operation    operationRSI = rsi.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            if (this.maTimegraph != MainClass.timeGraph)
            {
                MainClass.log("Download candles " + maTimegraph + " para processar MA");
                MainClass.getCandles(maTimegraph);
            }

            IndicatorMA ma = new IndicatorMA();
            ma.setLong(this.ilong);
            ma.setShort(this.ishort);
            Operation operationMA = ma.GetOperation(MainClass.arrayPriceOpen[maTimegraph], MainClass.arrayPriceClose[maTimegraph], MainClass.arrayPriceLow[maTimegraph], MainClass.arrayPriceHigh[maTimegraph], MainClass.arrayPriceVolume[maTimegraph]);


            //TicTacTec.TA.Library.Core.Atr();

            MainClass.log("CCI: " + cci.result);
            MainClass.log("CCI Tendency: " + cci.getTendency());
            MainClass.log("RSI: " + rsi.result);
            MainClass.log("RSI Tendency: " + rsi.getTendency());
            MainClass.log("MACD: " + macd.result);
            MainClass.log("MACD Sig: " + macd.result2);
            MainClass.log("MACD OP: " + operationMACD.ToString());
            MainClass.log("EMA Long 5m: " + ma.getResult());
            MainClass.log("EMA Short 5m: " + ma.getResult2());


            if (MainClass.carolatr)
            {
                MainClass.log("ATR: " + atrVal);
            }
            //return Operation.buy;
            if (cci.result > 0 && operationMACD == Operation.buy && rsi.result > 50 /*&& cci.getTendency() == Tendency.high && rsi.getTendency() == Tendency.high*/ && ((MainClass.carolatr && atrVal < MainClass.atrvalue) || !MainClass.carolatr))
            //if (operationMACD == Operation.buy)
            {
                /*double[] arrayresultMAHigh = new double[arrayPriceClose.Length];
                 * int outBegidxHigh, outNbElementHigh;
                 * TicTacTec.TA.Library.Core.MovingAverage(0, arrayPriceClose.Length - 1, arrayPriceClose, Convert.ToInt32(this.high), TicTacTec.TA.Library.Core.MAType.Ema, out outBegidxHigh, out outNbElementHigh, arrayresultMA);
                 * if (arrayPriceClose[arrayPriceClose.Length - 1] > arrayresultMAHigh[outNbElementHigh - 1])
                 *  return Operation.buy;*/

                if (ma.getResult2() > ma.getResult())
                {
                    return(Operation.buy);
                }
            }
            if (cci.result < 0 && operationMACD == Operation.sell && rsi.result < 50 /*&& cci.getTendency() == Tendency.low && rsi.getTendency() == Tendency.low */ && ((MainClass.carolatr && atrVal < MainClass.atrvalue) || !MainClass.carolatr))
            //if (operationMACD == Operation.sell)
            {
                /*double[] arrayresultMA = new double[arrayPriceClose.Length];
                 * int outBegidx, outNbElement;
                 * TicTacTec.TA.Library.Core.MovingAverage(0, arrayPriceClose.Length - 1, arrayPriceClose, 100, TicTacTec.TA.Library.Core.MAType.Ema, out outBegidx, out outNbElement, arrayresultMA);
                 * if (arrayPriceClose[arrayPriceClose.Length - 1] < arrayresultMA[outNbElement - 1])
                 *  return Operation.sell;*/
                if (ma.getResult2() < ma.getResult())
                {
                    return(Operation.sell);
                }
            }
            return(Operation.nothing);
        }
        catch
        {
            return(Operation.nothing);
        }
    }
    public Operation GetOperationDetail(double[] arrayPriceOpen, double[] arrayPriceClose, double[] arrayPriceLow, double[] arrayPriceHigh, double[] arrayVolume)
    {
        try
        {
            IndicatorMACD macd          = new IndicatorMACD();
            Operation     operationMACD = macd.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            IndicatorCCI cci          = new IndicatorCCI();
            Operation    operationCCI = cci.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            IndicatorRSI rsi          = new IndicatorRSI();
            Operation    operationRSI = rsi.GetOperation(arrayPriceOpen, arrayPriceClose, arrayPriceLow, arrayPriceHigh, arrayVolume);

            MainClass.log("CCI " + cci.result);
            MainClass.log("RSI " + rsi.result);

            if (cci.result > 0 && operationMACD == Operation.buy && rsi.result > 50 && cci.getTendency() == Tendency.high && rsi.getTendency() == Tendency.high)
            //if (operationMACD == Operation.buy)
            {
                double[] arrayresultMA = new double[arrayPriceClose.Length];
                int      outBegidx, outNbElement;
                TicTacTec.TA.Library.Core.MovingAverage(0, arrayPriceClose.Length - 1, arrayPriceClose, 100, TicTacTec.TA.Library.Core.MAType.Ema, out outBegidx, out outNbElement, arrayresultMA);
                if (arrayPriceClose[arrayPriceClose.Length - 1] > arrayresultMA[outNbElement - 1])
                {
                    return(Operation.buy);
                }
            }
            if (cci.result < 0 && operationMACD == Operation.sell && rsi.result < 50 && cci.getTendency() == Tendency.low && rsi.getTendency() == Tendency.low)
            //if (operationMACD == Operation.sell)
            {
                double[] arrayresultMA = new double[arrayPriceClose.Length];
                int      outBegidx, outNbElement;
                TicTacTec.TA.Library.Core.MovingAverage(0, arrayPriceClose.Length - 1, arrayPriceClose, 100, TicTacTec.TA.Library.Core.MAType.Ema, out outBegidx, out outNbElement, arrayresultMA);
                if (arrayPriceClose[arrayPriceClose.Length - 1] < arrayresultMA[outNbElement - 1])
                {
                    return(Operation.sell);
                }
            }

            return(Operation.nothing);
        }
        catch
        {
            return(Operation.nothing);
        }
    }