/// <summary> /// Make a form /// </summary> public StrategyDescription() { PnlBase = new Panel(); PnlWarnBase = new FancyPanel(); LblWarning = new Label(); PnlTbxBase = new FancyPanel(Language.T("Strategy Description")); TxboxInfo = new TextBox(); BtnClose = new Button(); BtnAccept = new Button(); BtnClear = new Button(); AcceptButton = BtnClose; BackColor = LayoutColors.ColorFormBack; Icon = Data.Icon; MinimumSize = new Size(400, 400); Text = Language.T("Strategy Description"); FormClosing += ActionsFormClosing; Controls.Add(PnlBase); Controls.Add(BtnAccept); Controls.Add(BtnClose); Controls.Add(BtnClear); // PnlWarnBase PnlWarnBase.Parent = this; PnlWarnBase.Padding = new Padding(2, 4, 2, 2); // LblWarning LblWarning.Parent = PnlWarnBase; LblWarning.TextAlign = ContentAlignment.MiddleCenter; LblWarning.BackColor = Color.Transparent; LblWarning.ForeColor = LayoutColors.ColorControlText; LblWarning.AutoSize = false; LblWarning.Dock = DockStyle.Fill; if (Data.Strategy.Description != "") { if (!Data.IsStrDescriptionRelevant()) { LblWarning.Font = new Font(Font, FontStyle.Bold); LblWarning.Text = Language.T("This description might be outdated!"); } else { LblWarning.Text = Path.GetFileNameWithoutExtension(Data.StrategyName); } } else { LblWarning.Text = Language.T("You can write a description of the strategy!"); } PnlTbxBase.Parent = PnlBase; PnlTbxBase.Padding = new Padding(4, (int)PnlTbxBase.CaptionHeight + 1, 2, 3); PnlTbxBase.Dock = DockStyle.Fill; // TxboxInfo TxboxInfo.Parent = PnlTbxBase; TxboxInfo.Dock = DockStyle.Fill; TxboxInfo.BackColor = LayoutColors.ColorControlBack; TxboxInfo.ForeColor = LayoutColors.ColorControlText; TxboxInfo.BorderStyle = BorderStyle.None; TxboxInfo.Multiline = true; TxboxInfo.AcceptsReturn = true; TxboxInfo.AcceptsTab = true; TxboxInfo.ScrollBars = ScrollBars.Vertical; TxboxInfo.KeyDown += TxboxInfo_KeyDown; TxboxInfo.Text = Data.Strategy.Description; TxboxInfo.Select(0, 0); // BtnClose BtnClose.Text = Language.T("Close"); BtnClose.Click += BtnCloseClick; BtnClose.UseVisualStyleBackColor = true; // BtnAccept BtnAccept.Text = Language.T("Accept"); BtnAccept.Click += BtnAcceptClick; BtnAccept.UseVisualStyleBackColor = true; // BtnClear BtnClear.Text = Language.T("Clear"); BtnClear.Click += BtnClearClick; BtnClear.UseVisualStyleBackColor = true; _oldInfo = Data.Strategy.Description; }
/// <summary> /// Make a form /// </summary> public Strategy_Description() { pnlBase = new Panel(); pnlWarnBase = new Fancy_Panel(); lblWarning = new Label(); pnlTbxBase = new Fancy_Panel(Language.T("Strategy Description")); txboxInfo = new TextBox(); btnClose = new Button(); btnAccept = new Button(); btnClear = new Button(); // BBCode_viewer AcceptButton = btnClose; BackColor = LayoutColors.ColorFormBack; Icon = Data.Icon; MinimumSize = new System.Drawing.Size(400, 400); Text = Language.T("Strategy Description"); FormClosing += new FormClosingEventHandler(Actions_FormClosing); Controls.Add(pnlBase); Controls.Add(btnAccept); Controls.Add(btnClose); Controls.Add(btnClear); // pnlWarnBase pnlWarnBase.Parent = this; pnlWarnBase.Padding = new Padding(2, 4, 2, 2); // lblWarning lblWarning.Parent = pnlWarnBase; lblWarning.TextAlign = ContentAlignment.MiddleCenter; lblWarning.BackColor = Color.Transparent;; lblWarning.ForeColor = LayoutColors.ColorControlText; lblWarning.AutoSize = false; lblWarning.Dock = DockStyle.Fill; if (Data.Strategy.Description != "") { if (!Data.IsStrDescriptionRelevant()) { lblWarning.Font = new Font(Font, FontStyle.Bold); lblWarning.Text = Language.T("This description might be outdated!"); } else { lblWarning.Text = System.IO.Path.GetFileNameWithoutExtension(Data.StrategyName); } } else { lblWarning.Text = Language.T("You can write a description to the strategy!"); } pnlTbxBase.Parent = pnlBase; pnlTbxBase.Padding = new Padding(4, (int)pnlTbxBase.CaptionHeight + 1, 2, 3); pnlTbxBase.Dock = DockStyle.Fill; // txboxInfo txboxInfo.Parent = pnlTbxBase; txboxInfo.Dock = DockStyle.Fill; txboxInfo.BackColor = LayoutColors.ColorControlBack; txboxInfo.ForeColor = LayoutColors.ColorControlText; txboxInfo.BorderStyle = BorderStyle.None; txboxInfo.Multiline = true; txboxInfo.AcceptsReturn = true; txboxInfo.AcceptsTab = true; txboxInfo.ScrollBars = ScrollBars.Vertical; txboxInfo.KeyDown += new KeyEventHandler(TxboxInfo_KeyDown); txboxInfo.Text = Data.Strategy.Description; txboxInfo.Select(0, 0); oldInfo = Data.Strategy.Description; // btnClose btnClose.Text = Language.T("Close"); btnClose.Click += new System.EventHandler(BtnClose_Click); btnClose.UseVisualStyleBackColor = true; // btnAccept btnAccept.Text = Language.T("Accept"); btnAccept.Click += new System.EventHandler(BtnAccept_Click); btnAccept.UseVisualStyleBackColor = true; // btnClear btnClear.Text = Language.T("Clear"); btnClear.Click += new System.EventHandler(BtnClear_Click); btnClear.UseVisualStyleBackColor = true; }
/// <summary> /// Generate Overview in HTML code /// </summary> /// <returns>the HTML code</returns> public string GenerateHTMLOverview() { var sb = new StringBuilder(); // Header sb.AppendLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"); sb.AppendLine("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">"); sb.AppendLine("<head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />"); sb.AppendLine("<title>" + StrategyName + "</title>"); sb.AppendLine("<style type=\"text/css\">"); sb.AppendLine("body {padding: 0 10px 10px 10px; margin: 0px; background-color: #fff; color: #003; font-size: 16px}"); sb.AppendLine(".content h1 {font-size: 1.4em;}"); sb.AppendLine(".content h2 {font-size: 1.2em;}"); sb.AppendLine(".content h3 {font-size: 1em;}"); sb.AppendLine(".content p { }"); sb.AppendLine(".content p.fsb_go_top {text-align: center;}"); sb.AppendLine(".fsb_strategy_slot {font-family: sans-serif; width: 30em; margin: 2px auto; text-align: center; background-color: #f3ffff; }"); sb.AppendLine(".fsb_strategy_slot table tr td {text-align: left; color: #033; font-size: 75%;}"); sb.AppendLine(".fsb_properties_slot {color: #fff; padding: 2px 0px; background: #966; }"); sb.AppendLine(".fsb_open_slot {color: #fff; padding: 2px 0; background: #693; }"); sb.AppendLine(".fsb_close_slot {color: #fff; padding: 2px 0; background: #d63; }"); sb.AppendLine(".fsb_open_filter_slot {color: #fff; padding: 2px 0; background: #699;}"); sb.AppendLine(".fsb_close_filter_slot {color: #fff; padding: 2px 0; background: #d99;}"); sb.AppendLine(".fsb_str_indicator {padding: 5px 0; color: #6090c0;}"); sb.AppendLine(".fsb_str_logic {padding-bottom: 5px; color: #066;}"); sb.AppendLine(".fsb_table {margin: 0 auto; border: 2px solid #003; border-collapse: collapse;}"); sb.AppendLine(".fsb_table th {border: 1px solid #006; text-align: center; background: #ccf; border-bottom-width: 2px;}"); sb.AppendLine(".fsb_table td {border: 1px solid #006;}"); sb.AppendLine("</style>"); sb.AppendLine("</head>"); sb.AppendLine("<body>"); sb.AppendLine("<div class=\"content\" id=\"fsb_header\">"); // Description sb.AppendLine("<h2 id=\"description\">" + Language.T("Description") + "</h2>"); if (Description != String.Empty) { string strStrategyDescription = Description.Replace(Environment.NewLine, "<br />"); strStrategyDescription = strStrategyDescription.Replace("&", "&"); strStrategyDescription = strStrategyDescription.Replace("\"", """); if (!Data.IsStrDescriptionRelevant()) { sb.AppendLine("<p style=\"color: #a00\">" + "(" + Language.T("This description might be outdated!") + ")" + "</p>"); } sb.AppendLine("<p>" + strStrategyDescription + "</p>"); } else { sb.AppendLine("<p>" + Language.T("None") + ".</p>"); } // Strategy Logic sb.AppendLine(); sb.AppendLine("<h2 id=\"logic\">" + Language.T("Logic") + "</h2>"); // Opening sb.AppendLine("<h3>" + Language.T("Opening (Entry Signal)") + "</h3>"); sb.AppendLine(OpeningLogicHTMLReport().ToString()); // Closing sb.AppendLine("<h3>" + Language.T("Closing (Exit Signal)") + "</h3>"); sb.AppendLine(ClosingLogicHTMLReport().ToString()); // Averaging sb.AppendLine("<h3>" + Language.T("Handling of Additional Entry Signals") + "**</h3>"); sb.AppendLine(AveragingHTMLReport().ToString()); // Trading Sizes sb.AppendLine("<h3>" + Language.T("Trading Size") + "</h3>"); sb.AppendLine(TradingSizeHTMLReport().ToString()); // Protection sb.AppendLine("<h3>" + Language.T("Permanent Protection") + "</h3>"); if (!Data.Strategy.UsePermanentSL) { sb.AppendLine("<p>" + Language.T("The strategy does not provide a permanent loss limitation.") + "</p>"); } else { sb.AppendLine("<p>" + Language.T("The Permanent Stop Loss limits the loss of a position to") + (Data.Strategy.PermanentSLType == PermanentProtectionType.Absolute ? " (Abs) " : " ") + Data.Strategy.PermanentSL); sb.AppendLine(Language.T("pips per open lot (plus the charged spread and rollover).") + "</p>"); } if (!Data.Strategy.UsePermanentTP) { sb.AppendLine("<p>" + Language.T("The strategy does not use a Permanent Take Profit.") + "</p>"); } else { sb.AppendLine("<p>" + Language.T("The Permanent Take Profit closes a position at") + (Data.Strategy.PermanentTPType == PermanentProtectionType.Absolute ? " (Abs) " : " ") + Data.Strategy.PermanentTP); sb.AppendLine(Language.T("pips profit.") + "</p>"); } if (Data.Strategy.UseBreakEven) { sb.AppendLine("<p>" + Language.T("The position's Stop Loss will be set to Break Even price when the profit reaches") + " " + Data.Strategy.BreakEven); sb.AppendLine(Language.T("pips") + "." + "</p>"); } sb.AppendLine("<p>--------------<br />"); sb.AppendLine("* " + Language.T("Use the indicator value from the previous bar for all asterisk-marked indicators!") + "<br />"); sb.AppendLine("** " + Language.T("The averaging rules apply to the entry signals only. Exit signals close a position. They cannot open, add or reduce one.")); sb.AppendLine("</p>"); // Footer sb.AppendLine("</div></body></html>"); return(sb.ToString()); }
/// <summary> /// Saves the strategy in BBCode format. /// </summary> public string GenerateBBCode() { string strBBCode = ""; string nl = Environment.NewLine; string nl2 = Environment.NewLine + Environment.NewLine; strBBCode += "[b]" + Data.ProgramName + " v" + Data.ProgramVersion + (Data.IsProgramBeta ? " Beta" : "") + "[/b]" + nl; strBBCode += "Strategy name: [b]" + strategyName + "[/b]" + nl; strBBCode += "Exported on: " + DateTime.Now + nl; strBBCode += nl; // Description strBBCode += "[b]Description[/b]" + 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" + nl : ""; string sTradingUnit = UseAccountPercentEntry ? "% of the account for margin" : ""; strBBCode += "Maximum open lots: " + MaxOpenLots + nl; strBBCode += "Entry lots: " + EntryLots + sTradingUnit + nl; strBBCode += "Adding lots: " + AddingLots + sTradingUnit + nl; strBBCode += "Reducing lots: " + ReducingLots + sTradingUnit + nl; strBBCode += nl; if (SameSignalAction == SameDirSignalAction.Add) { strBBCode += "[b]A same direction signal[/b] - [i]Adds to the position[/i]" + nl; } else if (SameSignalAction == SameDirSignalAction.Winner) { strBBCode += "[b]A same direction signal[/b] - [i]Adds to a wining position[/i]" + nl; } else if (SameSignalAction == SameDirSignalAction.Nothing) { strBBCode += "[b]A same direction signal[/b] - [i]Does nothing[/i]" + nl; } if (OppSignalAction == OppositeDirSignalAction.Close) { strBBCode += "[b]An opposite direction signal[/b] - [i]Closes the position[/i]" + nl; } else if (OppSignalAction == OppositeDirSignalAction.Reduce) { strBBCode += "[b]An opposite direction signal[/b] - [i]Reduces the position[/i]" + nl; } else if (OppSignalAction == OppositeDirSignalAction.Reverse) { strBBCode += "[b]An opposite direction signal[/b] - [i]Reverses the position[/i]" + nl; } else { strBBCode += "[b]An opposite direction signal[/b] - [i]Does nothing[/i]" + nl; } strBBCode += "[b]Permanent Stop Loss[/b] - [i]" + (Data.Strategy.UsePermanentSL ? (Data.Strategy.PermanentSLType == PermanentProtectionType.Absolute ? "(Abs) " : "") + Data.Strategy.PermanentSL.ToString() : "None") + "[/i]" + nl; strBBCode += "[b]Permanent Take Profit[/b] - [i]" + (Data.Strategy.UsePermanentTP ? (Data.Strategy.PermanentTPType == PermanentProtectionType.Absolute ? "(Abs) " : "") + Data.Strategy.PermanentTP.ToString() : "None") + "[/i]" + nl; strBBCode += "[b]Break Even[/b] - [i]" + (Data.Strategy.UseBreakEven ? Data.Strategy.BreakEven.ToString() : "None") + "[/i]" + nl2; // Add the slots. foreach (IndicatorSlot indSlot in this.indicatorSlot) { string sSlotType; switch (indSlot.SlotType) { case SlotTypes.Open: sSlotType = "Opening Point of the Position"; break; case SlotTypes.OpenFilter: sSlotType = "Opening Logic Condition"; break; case SlotTypes.Close: sSlotType = "Closing Point of the Position"; break; case SlotTypes.CloseFilter: sSlotType = "Closing Logic Condition"; break; default: sSlotType = ""; break; } strBBCode += "[b][" + sSlotType + "][/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=teal]" + (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 += " [b]" + listParam.Caption + "[/b] - [i]" + listParam.Text + "[/i]" + nl; } } } // Add the num params. foreach (NumericParam numParam in indSlot.IndParam.NumParam) { if (numParam.Enabled) { strBBCode += " [b]" + numParam.Caption + "[/b] - [i]" + numParam.ValueToString + "[/i]" + nl; } } // Add the check params. foreach (CheckParam checkParam in indSlot.IndParam.CheckParam) { if (checkParam.Enabled) { strBBCode += " [b]" + checkParam.Caption + "[/b] - [i]" + (checkParam.Checked ? "Yes" : "No") + "[/i]" + nl; } } strBBCode += nl; } return(strBBCode); }
/// <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); }