public void addOperacao(Operacao oper) { addOperacao(oper.GetDif(), oper.getQtdPeriodosOper(), oper.stopado); }
internal void SelectMonteCarlo(int p) { DataGridViewRowCollection RowsG = frmPrincipal.GetRows("dataGridRuns"); MonteCarlo mc = RowsG[p].Cells[0].Value as MonteCarlo; if (mc == null) { return; } Carteira carteira = RowsG[p].Cells[1].Value as Carteira; Estatistica global = mc.getGlobal(); CandidatoData candData = new CandidatoData(carteira.tradeSystem, mc.getGlobal(), carteira.GetCapital()); Describe(candData); // global.getGeral().getAmbasPontas().todosTrades.o frmPrincipal.ClearRows("dataGridOperacoes"); IList <Posicao> posicoes = carteira.posicoesFechadas; float capital = config.capitalInicial; int contaOperacao = 0; DataGridViewRowCollection Rows = frmPrincipal.GetRows("dataGridOperacoes"); for (int i = 0; i < mc.operacoes.Count; i++) { Operacao oper = mc.operacoes[i]; Posicao posicao = oper.posicao; contaOperacao++; int rowLine = Rows.Count - 1; Rows.Add(); int colIndex = 0; Rows[rowLine].Cells[colIndex++].Value = oper; Rows[rowLine].Cells[colIndex++].Value = contaOperacao; Rows[rowLine].Cells[colIndex++].Value = posicao.idPosicao; string ativoName = posicao.ativo.name; if (ativoName.Contains("%5E")) { ativoName = ativoName.Substring(ativoName.IndexOf("%5E") + 3); } Rows[rowLine].Cells[colIndex++].Value = ativoName; Rows[rowLine].Cells[colIndex++].Value = oper.candleInicial.periodo; Rows[rowLine].Cells[colIndex++].Value = oper.candleFinal.periodo; Rows[rowLine].Cells[colIndex++].Value = posicao.direcao > 0 ? "Compra" : "Venda"; Rows[rowLine].Cells[colIndex++].Value = oper.qtd; Rows[rowLine].Cells[colIndex++].Value = Utils.FormatCurrency(oper.vlrEntrada); Rows[rowLine].Cells[colIndex++].Value = Utils.FormatCurrency(oper.vlrSaida); Rows[rowLine].Cells[colIndex++].Value = Utils.FormatCurrency(oper.vlrStopInicial); Rows[rowLine].Cells[colIndex++].Value = oper.stopado ? "Sim" : "Não"; Rows[rowLine].Cells[colIndex++].Value = oper.qtd * oper.vlrEntrada; Rows[rowLine].Cells[colIndex++].Value = oper.GetDif(); Rows[rowLine].DefaultCellStyle.ForeColor = Color.Black; if (oper.GetDif() > 0) { Rows[rowLine].DefaultCellStyle.BackColor = Color.Blue; Rows[rowLine].DefaultCellStyle.ForeColor = Color.White; } if (oper.GetDif() < 0) { Rows[rowLine].DefaultCellStyle.BackColor = Color.Red; Rows[rowLine].DefaultCellStyle.ForeColor = Color.White; } capital += oper.GetDif() - 2 * config.custoOperacao; Rows[rowLine].Cells[colIndex++].Value = capital; Rows[rowLine].Cells[colIndex++].Value = oper.capitalOnClose; // oper. } }