コード例 #1
0
        /// <summary>
        /// Updates the journal data from the backtester
        /// </summary>
        void UpdateJournalData()
        {
            if (!Data.IsResult)
            {
                return;
            }

            asJournalData   = new string[positions, columns];
            aiPositionIcons = new Image[shownPos];

            for (int pos = firstPos; pos < firstPos + shownPos; pos++)
            {
                int row = pos - firstPos;

                asJournalData[row, 0] = (Backtester.PosNumb(selectedBar, pos) + 1).ToString();
                asJournalData[row, 1] = Language.T(Backtester.PosTransaction(selectedBar, pos).ToString());
                asJournalData[row, 2] = Language.T(Backtester.PosDir(selectedBar, pos).ToString());
                string sOrdAmount;
                if (Configs.AccountInMoney)
                {
                    sOrdAmount = (Backtester.PosDir(selectedBar, pos) == PosDirection.Short ? "-" : "") +
                                 (Backtester.PosLots(selectedBar, pos) * Data.InstrProperties.LotSize).ToString();
                }
                else
                {
                    sOrdAmount = Backtester.PosLots(selectedBar, pos).ToString();
                }
                asJournalData[row, 3] = sOrdAmount;
                asJournalData[row, 4] = (Backtester.PosOrdNumb(selectedBar, pos) + 1).ToString();
                asJournalData[row, 5] = Backtester.PosOrdPrice(selectedBar, pos).ToString(Data.FF);
                asJournalData[row, 6] = Backtester.PosPrice(selectedBar, pos).ToString(Data.FF);

                // Profit Loss
                if (Backtester.PosTransaction(selectedBar, pos) == Transaction.Close ||
                    Backtester.PosTransaction(selectedBar, pos) == Transaction.Reduce ||
                    Backtester.PosTransaction(selectedBar, pos) == Transaction.Reverse)
                {
                    string sProfitLoss;
                    if (Configs.AccountInMoney)
                    {
                        sProfitLoss = Backtester.PosMoneyProfitLoss(selectedBar, pos).ToString("F2");
                    }
                    else
                    {
                        sProfitLoss = Math.Round(Backtester.PosProfitLoss(selectedBar, pos)).ToString();
                    }
                    asJournalData[row, 7] = sProfitLoss;
                }
                else
                {
                    asJournalData[row, 7] = "-";
                }

                // Floating Profit Loss
                if (pos == positions - 1 && Backtester.PosTransaction(selectedBar, pos) != Transaction.Close)
                { // Last bar position only
                    string sFloatingPL;
                    if (Configs.AccountInMoney)
                    {
                        sFloatingPL = Backtester.PosMoneyFloatingPL(selectedBar, pos).ToString("F2");
                    }
                    else
                    {
                        sFloatingPL = Math.Round(Backtester.PosFloatingPL(selectedBar, pos)).ToString();
                    }
                    asJournalData[row, 8] = sFloatingPL;
                }
                else
                {
                    asJournalData[row, 8] = "-";
                }

                // Icons
                aiPositionIcons[row] = Backtester.PosIcon(selectedBar, pos);
            }

            return;
        }