Exemple #1
0
        public StopTarget(StrategyModel current, Idea stoplossidea)
        {
            int stoploss = stoplossidea.Stoploss;

            if (stoploss == 0)
            {
                this.StopLossRange = (current.High - current.Low) / 2.0;
                this.Stoploss      = (current.CandleType == "G") ? (current.Close - this.StopLossRange) : (current.Close + this.StopLossRange);
                this.BookProfit1   = (current.CandleType == "G") ? (current.Close + this.StopLossRange) : (current.Close - this.StopLossRange);
                this.BookProfit2   = (current.CandleType == "G") ? (current.Close + (2.0 * this.StopLossRange)) : (current.Close - (2.0 * this.StopLossRange));
            }
            else if (stoploss == 1)
            {
                this.StopLossRange = (current.Trade == Trade.BUY) ? (current.High - current.Low) : (current.High - current.Low);
                this.Stoploss      = (current.Trade == Trade.BUY) ? (current.Close - this.StopLossRange) : (current.Close + this.StopLossRange);
                this.BookProfit1   = (current.Trade == Trade.BUY) ? (current.Close + this.StopLossRange) : (current.Close - this.StopLossRange);
                this.BookProfit2   = (current.Trade == Trade.BUY) ? (current.Close + (2.0 * this.StopLossRange)) : (current.Close - (2.0 * this.StopLossRange));
            }
            else if (stoploss == 2)
            {
                Candle highLow = this.GetDayHighLow(current.CurrentCandle);
                this.StopLossRange = (highLow.High - highLow.Low);
                this.Stoploss      = (current.Trade == Trade.BUY) ? (highLow.Low) : (highLow.High);
                this.BookProfit1   = (current.Trade == Trade.BUY) ? (current.Close + this.StopLossRange) : (current.Close - this.StopLossRange);
                this.BookProfit2   = (current.Trade == Trade.BUY) ? (current.Close + (2.0 * this.StopLossRange)) : (current.Close - (2.0 * this.StopLossRange));
            }

            else if (stoploss != 5)
            {
                if (true)
                {
                    this.StopLossRange = (current.CandleType == "G") ?
                                         (current.Close - GetMin(current.CurrentCandle.AllIndicators.SuperTrend.SuperTrendValue))
                        :
                                         (GetMax(current.CurrentCandle.AllIndicators.SuperTrend.SuperTrendValue) - current.Close);
                }
                else
                {
                    this.StopLossRange = (current.CandleType == "G") ?
                                         (current.Close - GetMin(current.CurrentCandle.AllIndicators.SMA20, current.CurrentCandle.AllIndicators.SMA50, current.CurrentCandle.AllIndicators.SMA200, current.CurrentCandle.AllIndicators.SuperTrend.SuperTrendValue))
                                            :
                                         (GetMax(current.CurrentCandle.AllIndicators.SMA20, current.CurrentCandle.AllIndicators.SMA50, current.CurrentCandle.AllIndicators.SMA200, current.CurrentCandle.AllIndicators.SuperTrend.SuperTrendValue) - current.Close);
                }
                this.Stoploss    = (current.CandleType == "G") ? (current.Close - this.StopLossRange) : (current.Close + this.StopLossRange);
                this.BookProfit1 = (current.CandleType == "G") ? (current.Close + this.StopLossRange) : (current.Close - this.StopLossRange);
                this.BookProfit2 = (current.CandleType == "G") ? (current.Close + (2.0 * this.StopLossRange)) : (current.Close - (2.0 * this.StopLossRange));
            }

            else
            {
                Candle highLow = this.GetHighLow(current.CurrentCandle);
                this.StopLossRange = (current.CandleType == "G") ? (current.Close - highLow.Low) : (highLow.High - current.Close);
                this.Stoploss      = (current.CandleType == "G") ? (current.Close - this.StopLossRange) : (current.Close + this.StopLossRange);
                this.BookProfit1   = (current.CandleType == "G") ? (current.Close + this.StopLossRange) : (current.Close - this.StopLossRange);
                this.BookProfit2   = (current.CandleType == "G") ? (current.Close + (2.0 * this.StopLossRange)) : (current.Close - (2.0 * this.StopLossRange));
            }
            int interval = stoplossidea.Interval;

            if (interval <= 10)
            {
                if (interval == 5)
                {
                    this.FinalCandle = 73;
                }
                else if (interval == 10)
                {
                    this.FinalCandle = 0x24;
                }
            }
            else if (interval == 15)
            {
                this.FinalCandle = 0x17;
            }
            else if (interval == 30)
            {
                this.FinalCandle = 11;
            }
            else if (interval == 60)
            {
                this.FinalCandle = 5;
            }
        }