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

Created at 16 May 2018, 12:58
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
JE

jelle2500

Joined 25.11.2017

can't get the break even with extra pips working..
16 May 2018, 12:58


       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);
            }


@jelle2500