Ejemplo n.º 1
0
        /// <summary>
        ///     Generates a HTML report about the trading sizes.
        /// </summary>
        private StringBuilder TradingSizeHTMLReport()
        {
            var sb = new StringBuilder();

            if (UseAccountPercentEntry)
            {
                sb.AppendLine("<p>" + Language.T("Trade percent of your account.") + "</p>");

                sb.AppendLine("<ul>");
                sb.AppendLine("<li>" + Language.T("Opening of a new position") + " - " + EntryLots +
                              Language.T("% of the account equity") + ".</li>");
                if (SameSignalAction == SameDirSignalAction.Winner)
                {
                    sb.AppendLine("<li>" + Language.T("Adding to a winning position") + " - " + AddingLots +
                                  Language.T("% of the account equity") + ". " + Language.T("Do not open more than") +
                                  " " + Plural("lot", MaxOpenLots) + ".</li>");
                }
                if (SameSignalAction == SameDirSignalAction.Add)
                {
                    sb.AppendLine("<li>" + Language.T("Adding to a position") + " - " + AddingLots +
                                  Language.T("% of the account equity") + ". " + Language.T("Do not open more than") +
                                  " " + Plural("lot", MaxOpenLots) + ".</li>");
                }
                if (OppSignalAction == OppositeDirSignalAction.Reduce)
                {
                    sb.AppendLine("<li>" + Language.T("Reducing a position") + " - " + ReducingLots +
                                  Language.T("% of the account equity") + ".</li>");
                }
                if (OppSignalAction == OppositeDirSignalAction.Reverse)
                {
                    sb.AppendLine("<li>" + Language.T("Reversing a position") + " - " + EntryLots +
                                  Language.T("% of the account equity") + " " + Language.T("in the opposite direction.") +
                                  "</li>");
                }
                sb.AppendLine("</ul>");
            }
            else
            {
                sb.AppendLine("<p>" + Language.T("Always trade a constant number of lots.") + "</p>");

                sb.AppendLine("<ul>");
                sb.AppendLine("<li>" + Language.T("Opening of a new position") + " - " + Plural("lot", EntryLots) +
                              ".</li>");
                if (SameSignalAction == SameDirSignalAction.Winner)
                {
                    sb.AppendLine("<li>" + Language.T("Adding to a winning position") + " - " +
                                  Plural("lot", AddingLots) + ". " + Language.T("Do not open more than") + " " +
                                  Plural("lot", MaxOpenLots) + ".</li>");
                }
                if (SameSignalAction == SameDirSignalAction.Add)
                {
                    sb.AppendLine("<li>" + Language.T("Adding to a position") + " - " + Plural("lot", AddingLots) + ". " +
                                  Language.T("Do not open more than") + " " + Plural("lot", MaxOpenLots) + ".</li>");
                }
                if (OppSignalAction == OppositeDirSignalAction.Reduce)
                {
                    sb.AppendLine("<li>" + Language.T("Reducing a position") + " - " + Plural("lot", ReducingLots) + " " +
                                  Language.T("from the current position.") + "</li>");
                }
                if (OppSignalAction == OppositeDirSignalAction.Reverse)
                {
                    sb.AppendLine("<li>" + Language.T("Reversing a position") + " - " + Plural("lot", EntryLots) + " " +
                                  Language.T("in the opposite direction.") + "</li>");
                }
                sb.AppendLine("</ul>");
            }

            if (UseMartingale)
            {
                sb.AppendLine("<p>" + Language.T("Apply Martingale money management system with multiplier of") + " " +
                              MartingaleMultiplier.ToString("F2") + "." + "</p>");
            }

            return(sb);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Saves the strategy in BBCode format.
        /// </summary>
        public string GenerateBBCode()
        {
            string stage = String.Empty;

            if (Data.IsProgramBeta)
            {
                stage = " " + Language.T("Beta");
            }

            string strBBCode = "";
            string nl        = Environment.NewLine;
            string nl2       = Environment.NewLine + Environment.NewLine;

            strBBCode += "Strategy name: [b]" + StrategyName + "[/b]" + nl;
            strBBCode += Data.ProgramName + " v" + Data.ProgramVersion + stage + nl;
            strBBCode += "Exported on: " + DateTime.Now + nl;
            strBBCode += nl;

            // Description
            strBBCode += "Description:" + nl;

            if (Description != "")
            {
                if (!Data.IsStrDescriptionRelevant())
                {
                    strBBCode += "(This description might be outdated!)" + nl2;
                }

                strBBCode += Description + nl2;
            }
            else
            {
                strBBCode += "   None." + nl2;
            }

            strBBCode += UseAccountPercentEntry ? "Use account % for margin round to whole lots" + nl : "";
            string tradingUnit = UseAccountPercentEntry ? "% of the account for margin" : "";

            strBBCode += "Maximum open lots: " + MaxOpenLots.ToString("F2") + nl;
            strBBCode += "Entry lots: " + EntryLots.ToString("F2") + tradingUnit + nl;
            if (SameSignalAction == SameDirSignalAction.Add || SameSignalAction == SameDirSignalAction.Winner)
            {
                strBBCode += "Adding lots: " + AddingLots.ToString("F2") + tradingUnit + nl;
            }
            if (OppSignalAction == OppositeDirSignalAction.Reduce)
            {
                strBBCode += "Reducing lots: " + ReducingLots.ToString("F2") + tradingUnit + nl;
            }
            if (UseMartingale)
            {
                strBBCode += "Martingale money management multiplier: " + MartingaleMultiplier.ToString("F2") + nl;
            }

            strBBCode += "[b][color=#966][Strategy Properties][/color][/b]" + nl;
            if (SameSignalAction == SameDirSignalAction.Add)
            {
                strBBCode += "     A same direction signal - Adds to the position" + nl;
            }
            else if (SameSignalAction == SameDirSignalAction.Winner)
            {
                strBBCode += "     A same direction signal - Adds to a winning position" + nl;
            }
            else if (SameSignalAction == SameDirSignalAction.Nothing)
            {
                strBBCode += "     A same direction signal - Does nothing" + nl;
            }

            if (OppSignalAction == OppositeDirSignalAction.Close)
            {
                strBBCode += "     An opposite direction signal - Closes the position" + nl;
            }
            else if (OppSignalAction == OppositeDirSignalAction.Reduce)
            {
                strBBCode += "     An opposite direction signal - Reduces the position" + nl;
            }
            else if (OppSignalAction == OppositeDirSignalAction.Reverse)
            {
                strBBCode += "     An opposite direction signal - Reverses the position" + nl;
            }
            else
            {
                strBBCode += "     An opposite direction signal - Does nothing" + nl;
            }

            strBBCode += "     Permanent Stop Loss - " +
                         (Data.Strategy.UsePermanentSL
                              ? (Data.Strategy.PermanentSLType == PermanentProtectionType.Absolute ? "(Abs) " : "") +
                          Data.Strategy.PermanentSL.ToString(CultureInfo.InvariantCulture)
                              : "None") + "" + nl;
            strBBCode += "     Permanent Take Profit - " +
                         (Data.Strategy.UsePermanentTP
                              ? (Data.Strategy.PermanentTPType == PermanentProtectionType.Absolute ? "(Abs) " : "") +
                          Data.Strategy.PermanentTP.ToString(CultureInfo.InvariantCulture)
                              : "None") + "" + nl;
            strBBCode += "     Break Even - " +
                         (Data.Strategy.UseBreakEven
                              ? Data.Strategy.BreakEven.ToString(CultureInfo.InvariantCulture)
                              : "None") + "" + nl;
            strBBCode += nl;

            // Add the slots.
            foreach (IndicatorSlot indSlot in Slot)
            {
                string slotTypeName;
                string slotColor;
                switch (indSlot.SlotType)
                {
                case SlotTypes.Open:
                    slotTypeName = "Opening Point of the Position";
                    slotColor    = "#693";
                    break;

                case SlotTypes.OpenFilter:
                    slotTypeName = "Opening Logic Condition";
                    slotColor    = "#699";
                    break;

                case SlotTypes.Close:
                    slotTypeName = "Closing Point of the Position";
                    slotColor    = "#d63";
                    break;

                case SlotTypes.CloseFilter:
                    slotTypeName = "Closing Logic Condition";
                    slotColor    = "#d99";
                    break;

                default:
                    slotTypeName = "";
                    slotColor    = "#000";
                    break;
                }

                strBBCode += "[b][color=" + slotColor + "][" + slotTypeName + "][/color][/b]" + nl;
                strBBCode += "     [b][color=blue]" + indSlot.IndicatorName + "[/color][/b]" + nl;

                // Add the list params.
                foreach (ListParam listParam in indSlot.IndParam.ListParam)
                {
                    if (listParam.Enabled)
                    {
                        if (listParam.Caption == "Logic")
                        {
                            strBBCode += "     [b][color=#066]" +
                                         (Configs.UseLogicalGroups &&
                                          (indSlot.SlotType == SlotTypes.OpenFilter ||
                                           indSlot.SlotType == SlotTypes.CloseFilter)
                                              ? "[" +
                                          (indSlot.LogicalGroup.Length == 1
                                                     ? " " + indSlot.LogicalGroup + " "
                                                     : indSlot.LogicalGroup) + "]   "
                                              : "") + listParam.Text + "[/color][/b]" + nl;
                        }
                        else
                        {
                            strBBCode += "     " + listParam.Caption + "  -  " + listParam.Text + nl;
                        }
                    }
                }

                // Add the num params.
                foreach (NumericParam numParam in indSlot.IndParam.NumParam)
                {
                    if (numParam.Enabled)
                    {
                        strBBCode += "     " + numParam.Caption + "  -  " + numParam.ValueToString + nl;
                    }
                }

                // Add the check params.
                foreach (CheckParam checkParam in indSlot.IndParam.CheckParam)
                {
                    if (checkParam.Enabled)
                    {
                        strBBCode += "     " + checkParam.Caption + "  -  " + (checkParam.Checked ? "Yes" : "No") + nl;
                    }
                }

                strBBCode += nl;
            }

            return(strBBCode);
        }