public double Execute(ISecurity source, int barNum) { if (barNum - m_lastBarNum == 1) { m_lastProfit = source.GetProfit(barNum); if (m_lastMaxProfit < m_lastProfit) { m_lastMaxProfit = m_lastProfit; } } else if (m_lastBarNum != barNum) { double profit = 0, maxProfit = double.NegativeInfinity; for (var i = 0; i <= barNum; i++) { profit = source.GetProfit(i); if (maxProfit < profit) { maxProfit = profit; } } m_lastProfit = profit; m_lastMaxProfit = maxProfit; } m_lastBarNum = barNum; return(m_lastMaxProfit - m_lastProfit); }
public override double Execute(ISecurity source, int barNum) { switch (ProfitKind) { case ProfitKind.Unfixed: return(source.GetProfit(barNum)); case ProfitKind.Fixed: return(source.GetAccumulatedProfit(barNum)); default: throw new InvalidEnumArgumentException(nameof(ProfitKind), (int)ProfitKind, ProfitKind.GetType()); } }
public double Execute(ISecurity source, int barNum) { var securityRt = source as ISecurityRt; return(securityRt?.EstimatedBalance ?? source.InitDeposit + source.GetProfit(barNum)); }