Пример #1
0
        public MultyExtremumStrategy(int stopLoss, int pegTopSize, int minExtremumStep)
        {
            this.minExtremumStep = minExtremumStep;

            extremumsFinder = new ExtremumsFinder(pegTopSize);
            stopLossManager = new StopLossManager(stopLoss, 0.15);
        }
Пример #2
0
 //Report closing position trade
 override protected void Execute(Position position)
 {
     if (BotState.IsThisBotId(position.Label))
     {
         BotState.ClosedPositionsCount++;
         Reporter.ReportTrade(position, StopLossManager.GetStopLossStatus());
     }
 }
 //After CLose time set hard stop losses at last position entry price with Buffer
 override protected bool ExcuteRuleLogic()
 {
     if (BotState.IsAfterCloseTime)
     {
         StopLossManager.SetSLWithBufferForAllPositions(BotState.LastPositionEntryPrice);
         ExecuteOnceOnly();
         return(true);
     }
     return(false);
 }
 //If BreakEven SL is active set breakeven SL + Buffer
 override protected void Execute(Position position)
 {
     if (BotState.IsThisBotId(position.Label))
     {
         if (StopLossManager.IsBreakEvenStopLossActive)
         {
             StopLossManager.SetBreakEvenSLForAllPositions(BotState.LastProfitPositionEntryPrice, true);
         }
     }
 }
        public MonotoneExtremumsStrategy(int monotoneCount, int baseStopLoss, int invertCount, double breakevenPercent,
                                         TimeSpan?lastTradeTime = null, double breakevenInitializerPercent = 1)
        {
            this.monotoneCount = monotoneCount;
            this.invertCount   = invertCount;
            this.lastTradeTime = lastTradeTime ?? new TimeSpan(23, 59, 59);

            finder          = new ExtremumsFinder(0);
            stopLossManager = new StopLossManager(baseStopLoss, breakevenPercent, breakevenInitializerPercent);
        }
 //If BreakEven SL is Active then set BreakEven Stop Losses for all orders if the current price is past the entry point of the Last position to close with profit
 override protected bool ExcuteRuleLogic()
 {
     if (BotState.OrdersPlaced && BotState.PositionsRemainOpen())
     {
         if (StopLossManager.IsBreakEvenStopLossActive)
         {
             StopLossManager.SetBreakEvenSLForAllPositions(BotState.LastProfitPositionEntryPrice, true);
             return(true);
         }
     }
     return(false);
 }
 //If after reduce risk time then set hard stop losses to Last Profit Positions Entry Price with buffer
 override protected bool ExcuteRuleLogic()
 {
     if (BotState.IsAfterReducedRiskTime)
     {
         if (BotState.OrdersPlaced && BotState.PositionsRemainOpen())
         {
             //If Hard SL has not been set yet
             if (BotState.LastProfitPositionClosePrice > 0)
             {
                 StopLossManager.SetSLWithBufferForAllPositions(BotState.LastProfitPositionClosePrice);
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #8
0
        // If it is after CloseTime and remaining pending orders have not been closed then close all pending orders
        override protected bool ExcuteRuleLogic()
        {
            if (BotState.OrdersPlaced && BotState.PositionsRemainOpen())
            {
                //Calculate spike retrace factor
                SpikeManager.CalculateRetraceFactor();

                if (SpikeManager.IsRetraceGreaterThanLevel3())
                {
                    if (BotState.LastProfitPositionClosePrice > 0)
                    {
                        StopLossManager.SetSLWithBufferForAllPositions(BotState.LastProfitPositionClosePrice);
                        return(true);
                    }
                }
            }
            return(false);
        }
        // If it is after CloseTime and remaining pending orders have not been closed then close all pending orders
        override protected bool ExcuteRuleLogic()
        {
            if (BotState.OrdersPlaced && BotState.PositionsRemainOpen())
            {
                //Calculate spike retrace factor
                SpikeManager.CalculateRetraceFactor();

                if (SpikeManager.IsRetraceGreaterThanLevel3())
                {
                    if (BotState.LastProfitPositionClosePrice > 0)
                    {
                        StopLossManager.ReduceHardSLBufferBy50Percent();
                        ExecuteOnceOnly();
                        return(true);
                    }
                }
            }
            return(false);
        }
        //If Spike retrace is greater than Level 1 but less than Level 2 set SL to last profit position entry price plus buffer
        override protected bool ExcuteRuleLogic()
        {
            if (BotState.OrdersPlaced && BotState.PositionsRemainOpen())
            {
                //Calculate spike retrace factor
                SpikeManager.CalculateRetraceFactor();

                //Set hard stop losses and activate Trail if Spike has retraced between than retraceLevel1 and retraceLevel2
                if (SpikeManager.IsRetraceBetweenLevel1AndLevel2())
                {
                    //If Hard SL has not been set yet
                    if (BotState.LastProfitPositionEntryPrice > 0)
                    {
                        StopLossManager.SetSLWithBufferForAllPositions(BotState.LastProfitPositionEntryPrice);
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #11
0
 public StopLossTests()
 {
     bus             = new FakeMessageBus();
     stopLossManager = new StopLossManager(bus);
 }
Пример #12
0
 public void SetUp()
 {
     bus = new FakeMessageBus();
     stopLossManager = new StopLossManager(bus);   
 }
Пример #13
0
 public CorrectedExtremumStrategy(int baseStopLoss, int pegTopSize, double breakevenPercent, int trailingStopSize, int maxDistFromOpen = int.MaxValue)
 {
     extremumsFinder      = new ExtremumsFinder(pegTopSize);
     stopLossManager      = new StopLossManager(baseStopLoss, trailingStopSize, breakevenPercent);
     this.maxDistFromOpen = maxDistFromOpen;
 }
Пример #14
0
 public void SetUp()
 {
     bus             = new FakeMessageBus();
     stopLossManager = new StopLossManager(bus);
 }