can't get the break even with extra pips working..

16 May 2018, 12:58can't get the break even with extra pips working..#1
jelle2500posts: 14since: 25 Nov 2017

       hello, 

can someone help me to get my breakeven working?

(without my other closing signals getting ignored)

 

 

        [Parameter("Include Break-Even", DefaultValue = false)]
        public bool IncludeBreakEven { get; set; }

        [Parameter("Break-Even Trigger", DefaultValue = 10.0, MinValue = 1.0)]
        public double breakEvenTrigger { get; set; }

        [Parameter("Break-Even Extra pips", DefaultValue = 2.0, MinValue = 0.0)]
        public double ExtraPips { get; set; }

 

         protected override void OnBar()

                  //   if (IncludeBreakEven == true)                                 ????
                    //    BreakEven();                                                          ????

                         if (AllowBuy1() || AllowBuy2())
                        {
                            if (CloseBuy())
                                ClosePosition(longPosition);
                            ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, StopLossInPips, TakeProfitInPips);
                        }

                        else if (AllowSell1() || AllowSell2() )
                        {
                            if (CloseSell())
                                ClosePosition(shortPosition);
                            ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, StopLossInPips, TakeProfitInPips);

 

         private void BreakEven()
        {
            var position = Positions.Find(label, Symbol);
            if (position != null)
            {
                var entryPrice = position.EntryPrice;
                var distance = 0.0;
                var adjEntryPrice = position.TradeType == TradeType.Buy ? entryPrice + ExtraPips * Symbol.PipSize : entryPrice - ExtraPips * Symbol.PipSize;
                if (position.TradeType == TradeType.Buy)
                    distance = Symbol.Bid - entryPrice;
                else
                    distance = entryPrice - Symbol.Ask;

                if (distance >= breakEvenTrigger * Symbol.PipSize && position.StopLoss != adjEntryPrice)

                    ModifyPosition(position, adjEntryPrice, position.TakeProfit);
            }