public static double GetAccumulatedProfit(this IPosition position, int barNum) { var result = position.EntryBarNum > barNum ? 0 : position.IsActiveForBar(barNum) ? position.GetAccumulatedProfit(barNum) : position.Profit(); return(result); }