PA
    
        
            Closed Trades Info
            
                 30 Sep 2020, 20:54
            
                    
Hi all,
I need some help with coding a piece of a condition for opening a trade; the condition should check if the last 2 or 3 trades closed with a loss, and if so, not place any further trades. My programming skills are very limited so any examples would be greatly appreciated. Regards,
#region Order Processing Conditions
        protected override void OnTick()
        {
            if (Symbol.Spread / Symbol.PipSize <= MaxSpread)
            {              
                if (Symbol.Bid > _ma1.LastValue)
                    if (Positions.Count(x => x.TradeType == TradeType.Buy && x.SymbolName == SymbolName && x.Label == "PatTestBot") < MaxOpenPos)
                        ProcessBuy();
                if (Symbol.Ask < _ma1.LastValue)
                    if (Positions.Count(x => x.TradeType == TradeType.Sell && x.SymbolName == SymbolName && x.Label == "PatTestBot") < MaxOpenPos)
                        ProcessSell();
            }            
        }
        #endregion

PanagiotisCharalampous
02 Oct 2020, 08:24
Hi there,
You can try something like this to count the number of consecutive losses.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous