/// <summary> /// The default constructor. /// </summary> static Data() { IndicatorsForBacktestOnly = new[] { "Random Filter", "Date Filter", "Data Bars Filter", "Lot Limiter" }; PositionOpenTime = DateTime.MinValue; PositionType = -1; BalanceData = new BalanceChartUnit[BalanceLenght]; LibraryVersion = "unknown"; ExpertVersion = "unknown"; TerminalName = "MetaTrader"; PointChar = '.'; DFS = "dd.MM"; DF = "dd.MM.yy"; AutoUsePrvBarValue = true; SourceFolder = @"Custom Indicators\"; LoadedSavedStrategy = ""; FirstBar = 40; StrategyName = "New.xml"; StrategyDir = @"Strategies\"; DefaultStrategyDir = @"Strategies\"; ColorDir = @"Colors\"; LanguageDir = @"Languages\"; SystemDir = @"System\"; ProgramDir = @""; IsProgramBeta = false; IsStrategyChanged = false; Debug = false; IsData = false; IsConnected = false; IsAutoStart = false; StartAutotradeWhenConnected = false; ConnectionID = 0; PositionComment = ""; PositionProfit = 0; PositionTakeProfit = 0; PositionStopLoss = 0; PositionOpenPrice = 0; PositionLots = 0; PositionTicket = 0; WrongStopsRetry = 0; WrongTakeProf = 0; WrongStopLoss = 0; SecondsLiveTrading = 0; SavedStrategies = 0; SecondsDemoTrading = 0; LiveTradeStartTime = DateTime.Now; DemoTradeStartTime = DateTime.Now; ProgramName = "Forex Strategy Trader"; ProgramVersion = Application.ProductVersion; string[] asVersion = ProgramVersion.Split('.'); ProgramID = 1000000 * int.Parse(asVersion[0]) + 10000 * int.Parse(asVersion[1]) + 100 * int.Parse(asVersion[2]) + int.Parse(asVersion[3]); Strategy.GenerateNew(); StackStrategy = new Stack <Strategy>(); }
/// <summary> /// The default constructor. /// </summary> static Data() { programName = "Forex Strategy Trader"; programVersion = Application.ProductVersion; string[] asVersion = programVersion.Split('.'); programID = 1000000 * int.Parse(asVersion[0]) + 10000 * int.Parse(asVersion[1]) + 100 * int.Parse(asVersion[2]) + int.Parse(asVersion[3]); Strategy.GenerateNew(); stckStrategy = new Stack <Strategy>(); return; }
/// <summary> /// Reads the strategy from a file. /// </summary> /// <param name="strategyName">The strategy name.</param> /// <returns>0 - success.</returns> private int OpenStrategy(string strategyName) { try { if (File.Exists(strategyName) && Strategy.Load(strategyName)) { // Successfully opened Data.Strategy.StrategyName = Path.GetFileNameWithoutExtension(strategyName); Data.StrategyDir = Path.GetDirectoryName(strategyName); Data.StrategyName = Path.GetFileName(strategyName); } else { Strategy.GenerateNew(); string sMessageText = Language.T("The strategy could not be loaded correctly!") + Environment.NewLine + Language.T("A new strategy has been generated!"); MessageBox.Show(sMessageText, Language.T("Strategy Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Data.LoadedSavedStrategy = ""; } Data.SetStrategyIndicators(); RebuildStrategyLayout(); SetSrategyOverview(); SetFormText(); Data.IsStrategyChanged = false; Data.LoadedSavedStrategy = Data.StrategyPath; Data.StackStrategy.Clear(); } catch { Strategy.GenerateNew(); string sMessageText = Language.T("The strategy could not be loaded correctly!") + Environment.NewLine + Language.T("A new strategy has been generated!"); MessageBox.Show(sMessageText, Language.T("Strategy Loading"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Data.LoadedSavedStrategy = ""; SetFormText(); RebuildStrategyLayout(); return(1); } return(0); }