public void ComparisionTestWithNull()
        {
            var trailingStop = new TrailingStop
            {
                InitiateAtGainPercentage = 7
            };

            Assert.False(trailingStop.Equals(null));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            AlsiUtils.Data_Objects.GlobalObjects.CustomConnectionString = @"Data Source=ALSI-PC\;Initial Catalog=AlsiTrade;Integrated Security=True";
            var algo = new TrailingStop();


            algo.SetTriggers(int.Parse(args[0].Split(',')[0]), int.Parse(args[0].Split(',')[1]), int.Parse(args[0].Split(',')[2]), int.Parse(args[0].Split(',')[3]));
            //  algo.SetTriggers();


            Console.ReadLine();
        }
        public void ComparisionTestWithDifferent()
        {
            var trailingStop1 = new TrailingStop
            {
                InitiateAtGainPercentage = 7
            };
            var trailingStop2 = new TrailingStop
            {
                InitiateAtGainPercentage = 6
            };

            Assert.NotEqual(trailingStop1, trailingStop2);
        }
    public override int GetHashCode()
    {
        int hash = 1;

        if (lots_ != null)
        {
            hash ^= Lots.GetHashCode();
        }
        if (takeProfit_ != null)
        {
            hash ^= TakeProfit.GetHashCode();
        }
        if (trailingStop_ != null)
        {
            hash ^= TrailingStop.GetHashCode();
        }
        if (mACDOpenLevel_ != null)
        {
            hash ^= MACDOpenLevel.GetHashCode();
        }
        if (mATTrendPeriod_ != null)
        {
            hash ^= MATTrendPeriod.GetHashCode();
        }
        if (maximumRisk_ != null)
        {
            hash ^= MaximumRisk.GetHashCode();
        }
        if (decreaseFactor_ != null)
        {
            hash ^= DecreaseFactor.GetHashCode();
        }
        if (movingPeriod_ != null)
        {
            hash ^= MovingPeriod.GetHashCode();
        }
        if (movingShift_ != null)
        {
            hash ^= MovingShift.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }
        public void BothValuesSet()
        {
            var trailingStop = new TrailingStop
            {
                InitiateAtGainPercentage = 7
            };

            var standardStop = new StandardStop
            {
                InitiateAtGainPercentage = 10
            };

            var stops = new StopCollection
            {
                standardStop,
                trailingStop
            };

            stops.Sort();

            Assert.Equal(trailingStop, stops[0]);
            Assert.Equal(standardStop, stops[1]);
        }
 public void MergeFrom(AlgorithmParameters other)
 {
     if (other == null)
     {
         return;
     }
     if (other.lots_ != null)
     {
         if (lots_ == null)
         {
             Lots = new global::Lots();
         }
         Lots.MergeFrom(other.Lots);
     }
     if (other.takeProfit_ != null)
     {
         if (takeProfit_ == null)
         {
             TakeProfit = new global::TakeProfit();
         }
         TakeProfit.MergeFrom(other.TakeProfit);
     }
     if (other.trailingStop_ != null)
     {
         if (trailingStop_ == null)
         {
             TrailingStop = new global::TrailingStop();
         }
         TrailingStop.MergeFrom(other.TrailingStop);
     }
     if (other.mACDOpenLevel_ != null)
     {
         if (mACDOpenLevel_ == null)
         {
             MACDOpenLevel = new global::MACDOpenLevel();
         }
         MACDOpenLevel.MergeFrom(other.MACDOpenLevel);
     }
     if (other.mATTrendPeriod_ != null)
     {
         if (mATTrendPeriod_ == null)
         {
             MATTrendPeriod = new global::MATrendPeriod();
         }
         MATTrendPeriod.MergeFrom(other.MATTrendPeriod);
     }
     if (other.maximumRisk_ != null)
     {
         if (maximumRisk_ == null)
         {
             MaximumRisk = new global::MaximumRisk();
         }
         MaximumRisk.MergeFrom(other.MaximumRisk);
     }
     if (other.decreaseFactor_ != null)
     {
         if (decreaseFactor_ == null)
         {
             DecreaseFactor = new global::DecreaseFactor();
         }
         DecreaseFactor.MergeFrom(other.DecreaseFactor);
     }
     if (other.movingPeriod_ != null)
     {
         if (movingPeriod_ == null)
         {
             MovingPeriod = new global::MovingPeriod();
         }
         MovingPeriod.MergeFrom(other.MovingPeriod);
     }
     if (other.movingShift_ != null)
     {
         if (movingShift_ == null)
         {
             MovingShift = new global::MovingShift();
         }
         MovingShift.MergeFrom(other.MovingShift);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
 public ActionResult <TrailingStop> Create([FromBody] TrailingStop trailingStop)
 {
     trailingStop = TrailingStopService.Create(trailingStop);
     return(CreatedAtAction("GetById", new { id = trailingStop.Id }, trailingStop));
 }
Exemple #8
0
 /// <summary>
 /// Creates a TrailingStop for a Position.
 /// </summary>
 /// <param name="trailingStop">TrailingStop object to create.</param>
 /// <returns>Newly created TrailingStop object.</returns>
 public TrailingStop Create(TrailingStop trailingStop)
 {
     TrowooDbContext.Add(trailingStop);
     TrowooDbContext.SaveChanges();
     return(trailingStop);
 }
Exemple #9
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            FastLine.Set(Instrument.MasterInstrument.Round2TickSize(DonchianChannel(LengthFast)[0]));
            SlowLine.Set(Instrument.MasterInstrument.Round2TickSize(DonchianChannel(LengthSlow)[0]));
            TrailingStop.Set(EMA(eMA1Len)[0]);
            //TrendFilter.Set(EMA(eMA2Len)[0]);

            if (CrossAbove(FastLine, SlowLine, 1) &&
                crossedAboveBarNumber <= crossedBelowBarNumber)
            {
                crossedAboveBarNumber = CurrentBar;
                lookingLong           = true;
                lookingShort          = false;
            }
            else if (CrossBelow(FastLine, SlowLine, 1) &&
                     crossedAboveBarNumber >= crossedBelowBarNumber)
            {
                crossedBelowBarNumber = CurrentBar;
                lookingLong           = false;
                lookingShort          = true;
            }

            // Cancel trade under these conditions
            if (lookingLong && High[0] + entryOffsetTicks * TickSize < TrailingStop[0])
            {
                lookingLong = false;
            }
            if (lookingShort && Low[0] - entryOffsetTicks * TickSize > TrailingStop[0])
            {
                lookingShort = false;
            }

            //Print(Time + " " + CurrentBar + " " + crossedAboveBarNumber + " " + crossedBelowBarNumber);

            double barHeight = Range()[0];             //High[0] - Low[0];

            PlotColors[0][0] = Color.DarkBlue;
            PlotColors[1][0] = Color.DarkBlue;
            PlotColors[2][0] = Color.DarkBlue;
            PlotColors[3][0] = Color.DarkBlue;
            PlotColors[4][0] = Color.DarkBlue;
            PlotColors[5][0] = Color.DarkBlue;
            PlotColors[6][0] = Color.DarkBlue;
            PlotColors[7][0] = Color.DarkBlue;
            PlotColors[8][0] = Color.DarkBlue;
            PlotColors[9][0] = Color.DarkBlue;

            if (isLongSignal())
            {
                LongEntry.Set(High[0] + entryOffsetTicks * TickSize);
                LongStop.Set(Low[0] - stopOffsetTicks * TickSize);
                LongTgt1.Set(High[0] + Instrument.MasterInstrument.Round2TickSize(tgt1X * barHeight));
                LongTgt2.Set(High[0] + Instrument.MasterInstrument.Round2TickSize(tgt2X * barHeight));
                LongTgt3.Set(High[0] + Instrument.MasterInstrument.Round2TickSize(tgt3X * barHeight));
            }
            if (isShortSignal())
            {
                ShortEntry.Set(Low[0] - entryOffsetTicks * TickSize);
                ShortStop.Set(High[0] + stopOffsetTicks * TickSize);
                ShortTgt1.Set(Low[0] - Instrument.MasterInstrument.Round2TickSize(tgt1X * barHeight));
                ShortTgt2.Set(Low[0] - Instrument.MasterInstrument.Round2TickSize(tgt2X * barHeight));
                ShortTgt3.Set(Low[0] - Instrument.MasterInstrument.Round2TickSize(tgt3X * barHeight));
            }
        }