/// <summary> ///Reloads the Custom Indicators. /// </summary> void ReloadCustomIndicators() { // Check if the strategy contains custom indicators bool strategyHasCustomIndicator = false; foreach (IndicatorSlot slot in Data.Strategy.Slot) { // Searching the strategy slots for a custom indicator if (Indicator_Store.CustomIndicatorNames.Contains(slot.IndicatorName)) { strategyHasCustomIndicator = true; break; } } if (strategyHasCustomIndicator) { // Save the current strategy DialogResult dialogResult = WhetherSaveChangedStrategy(); if (dialogResult == DialogResult.Yes) { SaveStrategy(); } else if (dialogResult == DialogResult.Cancel) { return; } } // Reload all the custom indicators Custom_Indicators.LoadCustomIndicators(); if (strategyHasCustomIndicator) { // Load and calculate a new strategy Data.StrategyDir = Path.Combine(Data.ProgramDir, Data.DefaultStrategyDir); if (OpenStrategy(Path.Combine(Data.StrategyDir, "New.xml")) == 0) { AfterStrategyOpening(false); Calculate(false); } } return; }
/// <summary> /// Tools menu /// </summary> protected override void MenuTools_OnClick(object sender, EventArgs e) { string name = ((ToolStripMenuItem)sender).Name; switch (name) { case "Comparator": ShowComparator(); break; case "Scanner": ShowScanner(); break; case "Generator": ShowGenerator(); break; case "Optimizer": ShowOptimizer(); break; case "Bar Explorer": ShowBarExplorer(); break; case "ProfitCalculator": ShowProfitCalculator(); break; case "PivotPoints": ShowPivotPoints(); break; case "FibonacciLevels": ShowFibonacciLevels(); break; case "Charges": EditTradingCharges(); break; case "miInstrumentEditor": ShowInstrumentEditor(); break; case "Reset settings": ResetSettings(); break; case "miNewTranslation": MakeNewTranslation(); break; case "miEditTranslation": EditTranslation(); break; case "miShowEnglishPhrases": Language.ShowPhrases(1); break; case "miShowAltPhrases": Language.ShowPhrases(2); break; case "miShowAllPhrases": Language.ShowPhrases(3); break; case "miOpenIndFolder": try { System.Diagnostics.Process.Start(Data.SourceFolder); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } break; case "miReloadInd": Cursor = Cursors.WaitCursor; ReloadCustomIndicators(); Cursor = Cursors.Default; break; case "miExportAsCI": Cursor = Cursors.WaitCursor; Strategy_to_Indicator.ExportStrategyToIndicator(); ReloadCustomIndicators(); Cursor = Cursors.Default; break; case "miCheckInd": Custom_Indicators.TestCustomIndicators(); break; case "Calculator": ShowCalculator(); break; case "miPlaySounds": Configs.PlaySounds = !Configs.PlaySounds; break; case "CommandConsole": ShowCommandConsole(); break; case "miJForexImport": JForexImport(); break; case "tsmiOverOptimization": // Analyzer ShowAnalyzer("tsmiOverOptimization"); break; case "tsmiCumulativeStrategy": // Analyzer ShowAnalyzer("tsmiCumulativeStrategy"); break; default: break; } }
/// <summary> /// The default constructor /// </summary> public Actions() { StartPosition = FormStartPosition.CenterScreen; Size = new Size(790, 590); MinimumSize = new Size(500, 375); Icon = Data.Icon; Text = Data.ProgramName; FormClosing += new FormClosingEventHandler(Actions_FormClosing); Application.Idle += new EventHandler(Application_Idle); // Load a data file UpdateStatusLabel("Loading historical data..."); if (LoadInstrument(false) != 0) { LoadInstrument(true); string messageText = Language.T("Forex Strategy Builder cannot load a historical data file and is going to use integrated data!"); MessageBox.Show(messageText, Language.T("Data File Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Prepare custom indicators if (Configs.LoadCustomIndicators) { UpdateStatusLabel("Loading custom indicators..."); Custom_Indicators.LoadCustomIndicators(); } else { Indicator_Store.CombineAllIndicators(); } // Load a strategy UpdateStatusLabel("Loading strategy..."); string sStrategyPath = Data.StrategyPath; if (Configs.RememberLastStr && Configs.LastStrategy != "") { string sLastStrategy = Path.GetDirectoryName(Configs.LastStrategy); if (sLastStrategy != "") { sLastStrategy = Configs.LastStrategy; } else { string sPath = Path.Combine(Data.ProgramDir, Data.DefaultStrategyDir); sLastStrategy = Path.Combine(sPath, Configs.LastStrategy); } if (File.Exists(sLastStrategy)) { sStrategyPath = sLastStrategy; } } if (OpenStrategy(sStrategyPath) == 0) { AfterStrategyOpening(false); } Calculate(false); Check_Update liveContent = new Check_Update(Data.SystemDir, miLiveContent, miForex); Registrar registrar = new Registrar(); registrar.Register(); // Starting tips if (Configs.ShowStartingTip) { Starting_Tips startingTips = new Starting_Tips(); startingTips.Show(); } UpdateStatusLabel("Loading user interface..."); return; }