// // The original code in this file was created by Quagensia® N Edition. // // Please visit www.quagensia.com and download the Quagensia N Edition free trial which will empower you to: // // 1. Create your own algorithmic trading strategies without code by simply // clicking choices on a screen as you would verbally describe your trading ideas. // // 2. Get no-code trading strategies that you can use as-is and customize without code. // // By using this code, you acknowledge that you have read and agree to the Quagensia, Inc. Terms of Service located at // https://www.quagensia.com/company/terms-of-service and the Quagensia Desktop Application End-User // License Agreement (EULA) located at https://www.quagensia.com/company/quagensia-desktop-application-eula. // // If you make changes to this code file outside of Quagensia N Edition and then regenerate and copy the code for this Quagensia N Edition Strategy // from Quagensia N Edition to this file's location on disk, be aware that your changes made outside of Quagensia N Edition will be lost. // // Quagensia® N Edition is a product of Quagensia, Inc., a company which has no affiliation with NinjaTrader, LLC. // Neither NinjaTrader, LLC nor have any of its affiliates endorsed, recommended, or approved Quagensia® N Edition. // // NinjaTrader® and NinjaScript® are registered trademarks of NinjaTrader, LLC. // // Under the terms of the Quagensia End-User License Agreement (EULA), neither this // sentence nor any part of the message above may be removed or altered in any way. // // Algo Type: NinjaTrader® Strategy // // Strategy Name: ▶ Import Your Third-Party Indicators Into Quagensia By Applying This Strategy to a Chart! // // Strategy Home Page: https://www.quagensia.com/help/import-your-third-party-indicators-into-quagensia-n-edition // // Description & Notes: // INTRODUCTION // // This strategy makes it easy to quickly import your NinjaTrader® // indicators into Quagensia N Edition. // // Quagensia N Edition is much more valuable once you've imported your // NinjaTrader® indicators into it. // // Please click the blue underlined link directly above and watch the // quick video on the web page that opens to see a visual representation // of all the instructions and important notes below. // // Note that the indicator import process works even for free trial users // in order to make it possible to test one's NinjaTrader® indicators in // Quagensia N Edition before deciding whether or not to purchase a // Quagensia N Edition subscription. // // QUICK SUMMARY OF THE INDICATOR IMPORT PROCESS // // To quickly import your third-party NinjaTrader® indicators, custom // NinjaTrader® indicators, and enhanced versions of the NinjaTrader® // indicators built into Quagensia N Edition, simply open NinjaTrader®, // then open the NinjaScript® Output window, then apply this strategy to // a chart in NinjaTrader® and enable it at a time when you are not using // NinjaTrader® for live trading and are not currently running a // back-test or optimization of a strategy, wait anywhere from 20 seconds // up to ten minutes for the indicator import process to finish and print // a success or failure message and other valuable information to the // NinjaScript® Output window, then close and reopen Quagensia N Edition // to start using your imported NinjaTrader® indicators in your no-code // Quagensia N Edition Strategies. Remember to close the NinjaTrader® // chart to which this strategy was applied to disable this strategy and // prevent yourself from unintentionally re-running the relatively // time-consuming indicator import process later. // // DETAILED INSTRUCTIONS AND IMPORTANT NOTES // // The following text is a more detailed set of instructions than the // instructions above, and it includes important notes. // // To quickly import your third-party NinjaTrader® indicators, custom // NinjaTrader® indicators, and enhanced versions of the NinjaTrader® // indicators built into Quagensia N Edition, follow these quick and easy // steps: // // 1. Wait until a time when you are not using NinjaTrader® for live // trading and are not currently running a back-test or optimization of a // strategy. // // 2. Watch the quick video on the web page that opens when you click the // link directly above this large text box. The following instructions // are also in the video: // // 3. Open NinjaTrader®, then open the NinjaScript® Editor from the "New" // main menu in NinjaTrader®. // // 5. With this strategy opened in a tab in Quagensia N Edition, press // the "Generate Code and Copy Code File to NinjaTrader® Strategy Code // Folder" button near the bottom of this window. If you have your sound // up you will hear the sound of success from NinjaTrader® that indicates // that the strategy was received by NinjaTrader® and "compiled" into a // format that allows you to use it in the ways that strategies are // normally used in NinjaTrader®. // // 6. Open the NinjaScript® Output window from the "New" main menu in // NinjaTrader®. As long as the NinjaScript® Output window is open when // you run this strategy in the next step, it will display very important // information about the successful or failed indicator import process. // // 7. To import your NinjaTrader® indicators into Quagensia N Edition, // apply this strategy to a chart in NinjaTrader® and enable it, or run a // back-test of the strategy in the NinjaTrader® Strategy Analyzer. Its // name in NinjaTrader® should be // Q_ImportYourThirdPartyIndicatorsIntoQuagensia or something similar. // Usually, under normal circumstances for most users, it will take // anywhere from less than 20 seconds up to several minutes for this // strategy to finish the indicator importing process depending on the // number of indicators you have and the specifications of your machine. // You will know that the indicator import process is finished when a // success message (or less likely, a failure message) is printed to the // NinjaScript® Output window. If the text in the NinjaScript® Output // window indicates that problems were encountered during the indicator // import process, please do not hesitate to request help in the official // Quagensia Discord community, which is located at // https://discord.gg/g8KMUDwpDE // // 8. Close and reopen Quagensia N Edition. At this point, you should be // able to use most of your third-party indicators, custom indicators, // and enhanced versions of the NinjaTrader® indicators built into // Quagensia N Edition in your no-code Quagensia N Edition Strategies // like you would use one of the built-in Quagensia N Edition indicator // functions, except with more features and an enhanced user interface. // You can access the imported indicators from the "Indicators Imported // from NinjaTrader®" subfolder of the context menu that opens when you // click on a location where an indicator can go. // // 9. If you applied this strategy to a chart in NinjaTrader® to import // your indicators, please remember to close the chart to disable this // strategy and prevent yourself from unintentionally re-running the // relatively time-consuming indicator import process later. // // 10. Limitations of Imported Indicators: As is the case with all other // no-code strategy builders that automatically import or load indicators // from NinjaTrader®, not all indicators can be imported and used in // Quagensia N Edition Strategies, and it is impossible for the Quagensia // N Edition indicator import process to determine with certainty whether // or not a particular indicator and its data series and plots can be // used in a NinjaTrader® strategy outputted by Quagensia N Edition or // even if a given indicator and its data series and plots can be used in // a NinjaTrader® strategy at all, since some indicators or some of their // data series or plots cannot be used in a NinjaTrader® strategy even if // the indicator was hand-coded in a NinjaTrader® strategy by a highly // experienced NinjaScript® programmer. Therefore just because an // imported indicator appears in Quagensia N Edition doesn't mean that // the particular indicator and all of its plots and data series can be // used in a NinjaTrader® strategy outputted by Quagensia N Edition. // Since it is impossible for Quagensia N Edition to determine which // indicators have such limitations, you will need to add an indicator of // interest to a Quagensia N Edition Strategy and plot it and/or use its // one or more data series to determine if that indicator is supported in // the NinjaTrader® strategies that are outputted by Quagensia N Edition. // // 11. As a bonus, the indicator import process also imports over 200 // "List of Choices" data types that you can use in your Quagensia N // Edition Strategies as (optimizable!) input parameters that appear as // drop-down lists in NinjaTrader®, drop-down list internal variables in // your strategies, or drop-down lists in your strategies' trading logic. // The "List of Choices" data types imported from your installation of // NinjaTrader® include the "List of Choices" data types of the drop-down // list input parameters of your third-party indicators, and many more. // The imported "List of Choices" data types can be found in same context // menu subfolder where the over 50 "List of Choices" data types that are // built into Quagensia N Edition can be found, and the location of this // context menu subfolder is context-sensitive based on where you click. // For instance, to add a drop-down list input parameter or drop-down // list internal variable to your Quagensia N Edition Strategy whose data // type is one of the over 200 imported "List of Choices" data types, // click on either the drop-down list below the "Add Parameter" header in // the "Input Parameters" section or the drop-down list below the "Add // Variable" header in the "Internal Variables" section and navigate to // "Advanced Data Types >> Lists of Choices >> Imported From // NinjaTrader®" to see a complete list of the imported drop-down lists // that you can choose from, or to add an imported or built-in drop-down // list directly to your trading logic click on a location where a // drop-down list can go, and in the context menu that appears navigate // to "Hard-Coded Value (True, 42, 'Hello', List of Choices) >> Select an // Item from a List of Choices" to see a complete list of both the // built-in and imported drop-down lists that you can add at the location // you clicked. // // 12. If you experience any issues importing your NinjaTrader® // indicators with this strategy or have any questions about the // indicator import process or imported indicators, please do not // hesitate to ask a question in the official Quagensia Discord // community, which is located at https://discord.gg/g8KMUDwpDE // // Copyright © 2024 Quagensia, Inc. All rights reserved. #region Using Declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.IO; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.Indicators; using NinjaTrader.NinjaScript.DrawingTools; using System.Reflection; using System.Globalization; #endregion // This namespace holds strategies in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Strategies { public class Q_ImportYourThirdPartyIndicatorsIntoQuagensia : Strategy { private bool QX_FunctionHasBeenCalledOnceAlready; private List QS_SessionIterators; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = "INTRODUCTION This strategy makes it easy to quickly import your NinjaTrader® indicators into Quagensia N Edition. Quagensia N Edition is much more valuable once you've imported your NinjaTrader® indicators into it. Please click the blue underlined link directly above and watch the quick video on the web page that opens to see a visual representation of all the instructions and important notes below. Note that the indicator import process works even for free trial users in order to make it possible to test one's NinjaTrader® indicators in Quagensia N Edition before deciding whether or not to purchase a Quagensia N Edition subscription. QUICK SUMMARY OF THE INDICATOR IMPORT PROCESS To quickly import your third-party NinjaTrader® indicators, custom NinjaTrader® indicators, and enhanced versions of the NinjaTrader® indicators built into Quagensia N Edition, simply open NinjaTrader®, then open the NinjaScript® Output window, then apply this strategy to a chart in NinjaTrader® and enable it at a time when you are not using NinjaTrader® for live trading and are not currently running a back-test or optimization of a strategy, wait anywhere from 20 seconds up to ten minutes for the indicator import process to finish and print a success or failure message and other valuable information to the NinjaScript® Output window, then close and reopen Quagensia N Edition to start using your imported NinjaTrader® indicators in your no-code Quagensia N Edition Strategies. Remember to close the NinjaTrader® chart to which this strategy was applied to disable this strategy and prevent yourself from unintentionally re-running the relatively time-consuming indicator import process later. DETAILED INSTRUCTIONS AND IMPORTANT NOTES The following text is a more detailed set of instructions than the instructions above, and it includes important notes. To quickly import your third-party NinjaTrader® indicators, custom NinjaTrader® indicators, and enhanced versions of the NinjaTrader® indicators built into Quagensia N Edition, follow these quick and easy steps: 1. Wait until a time when you are not using NinjaTrader® for live trading and are not currently running a back-test or optimization of a strategy. 2. Watch the quick video on the web page that opens when you click the link directly above this large text box. The following instructions are also in the video: 3. Open NinjaTrader®, then open the NinjaScript® Editor from the \"New\" main menu in NinjaTrader®. 5. With this strategy opened in a tab in Quagensia N Edition, press the \"Generate Code and Copy Code File to NinjaTrader® Strategy Code Folder\" button near the bottom of this window. If you have your sound up you will hear the sound of success from NinjaTrader® that indicates that the strategy was received by NinjaTrader® and \"compiled\" into a format that allows you to use it in the ways that strategies are normally used in NinjaTrader®. 6. Open the NinjaScript® Output window from the \"New\" main menu in NinjaTrader®. As long as the NinjaScript® Output window is open when you run this strategy in the next step, it will display very important information about the successful or failed indicator import process. 7. To import your NinjaTrader® indicators into Quagensia N Edition, apply this strategy to a chart in NinjaTrader® and enable it, or run a back-test of the strategy in the NinjaTrader® Strategy Analyzer. Its name in NinjaTrader® should be Q_ImportYourThirdPartyIndicatorsIntoQuagensia or something similar. Usually, under normal circumstances for most users, it will take anywhere from less than 20 seconds up to several minutes for this strategy to finish the indicator importing process depending on the number of indicators you have and the specifications of your machine. You will know that the indicator import process is finished when a success message (or less likely, a failure message) is printed to the NinjaScript® Output window. If the text in the NinjaScript® Output window indicates that problems were encountered during the indicator import process, please do not hesitate to request help in the official Quagensia Discord community, which is located at https://discord.gg/g8KMUDwpDE 8. Close and reopen Quagensia N Edition. At this point, you should be able to use most of your third-party indicators, custom indicators, and enhanced versions of the NinjaTrader® indicators built into Quagensia N Edition in your no-code Quagensia N Edition Strategies like you would use one of the built-in Quagensia N Edition indicator functions, except with more features and an enhanced user interface. You can access the imported indicators from the \"Indicators Imported from NinjaTrader®\" subfolder of the context menu that opens when you click on a location where an indicator can go. 9. If you applied this strategy to a chart in NinjaTrader® to import your indicators, please remember to close the chart to disable this strategy and prevent yourself from unintentionally re-running the relatively time-consuming indicator import process later. 10. Limitations of Imported Indicators: As is the case with all other no-code strategy builders that automatically import or load indicators from NinjaTrader®, not all indicators can be imported and used in Quagensia N Edition Strategies, and it is impossible for the Quagensia N Edition indicator import process to determine with certainty whether or not a particular indicator and its data series and plots can be used in a NinjaTrader® strategy outputted by Quagensia N Edition or even if a given indicator and its data series and plots can be used in a NinjaTrader® strategy at all, since some indicators or some of their data series or plots cannot be used in a NinjaTrader® strategy even if the indicator was hand-coded in a NinjaTrader® strategy by a highly experienced NinjaScript® programmer. Therefore just because an imported indicator appears in Quagensia N Edition doesn't mean that the particular indicator and all of its plots and data series can be used in a NinjaTrader® strategy outputted by Quagensia N Edition. Since it is impossible for Quagensia N Edition to determine which indicators have such limitations, you will need to add an indicator of interest to a Quagensia N Edition Strategy and plot it and/or use its one or more data series to determine if that indicator is supported in the NinjaTrader® strategies that are outputted by Quagensia N Edition. 11. As a bonus, the indicator import process also imports over 200 \"List of Choices\" data types that you can use in your Quagensia N Edition Strategies as (optimizable!) input parameters that appear as drop-down lists in NinjaTrader®, drop-down list internal variables in your strategies, or drop-down lists in your strategies' trading logic. The \"List of Choices\" data types imported from your installation of NinjaTrader® include the \"List of Choices\" data types of the drop-down list input parameters of your third-party indicators, and many more. The imported \"List of Choices\" data types can be found in same context menu subfolder where the over 50 \"List of Choices\" data types that are built into Quagensia N Edition can be found, and the location of this context menu subfolder is context-sensitive based on where you click. For instance, to add a drop-down list input parameter or drop-down list internal variable to your Quagensia N Edition Strategy whose data type is one of the over 200 imported \"List of Choices\" data types, click on either the drop-down list below the \"Add Parameter\" header in the \"Input Parameters\" section or the drop-down list below the \"Add Variable\" header in the \"Internal Variables\" section and navigate to \"Advanced Data Types >> Lists of Choices >> Imported From NinjaTrader®\" to see a complete list of the imported drop-down lists that you can choose from, or to add an imported or built-in drop-down list directly to your trading logic click on a location where a drop-down list can go, and in the context menu that appears navigate to \"Hard-Coded Value (True, 42, 'Hello', List of Choices) >> Select an Item from a List of Choices\" to see a complete list of both the built-in and imported drop-down lists that you can add at the location you clicked. 12. If you experience any issues importing your NinjaTrader® indicators with this strategy or have any questions about the indicator import process or imported indicators, please do not hesitate to ask a question in the official Quagensia Discord community, which is located at https://discord.gg/g8KMUDwpDE Copyright © 2024 Quagensia, Inc. All rights reserved."; Name = "Q_ImportYourThirdPartyIndicatorsIntoQuagensia"; Calculate = Calculate.OnBarClose; DefaultQuantity = 1; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 30; IsFillLimitOnTouch = false; MaximumBarsLookBack = MaximumBarsLookBack.Infinite; OrderFillResolution = OrderFillResolution.Standard; Slippage = 0.0; IncludeCommission = true; IsAdoptAccountPositionAware = false; StartBehavior = StartBehavior.WaitUntilFlat; TimeInForce = TimeInForce.Gtc; TraceOrders = false; RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose; StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 0; AllowRemovalOfDrawObjects = false; IsInstantiatedOnEachOptimizationIteration = !false; IncludeTradeHistoryInBacktest = !false; QX_WriteImportedIndicatorsandTypesFiletoDefaultLocationMyDocumentsQuagensiaQuagensia_NMy_AlgosA = true; QX_CustomFolderPathToWhichTheImportedIndicatorsandTypesFileShouldBeWrittenIfCheckBoxAboveisUnch = ""; QS_DoCustomDrawingAndPainting_UserPreference = true; QS_DoPrintToOutputWindow_UserPreference = true; } else if (State == State.Configure) { if (QS_Brushes_SolidColor_System == null) QS_Populate_Brushes_SolidColor_System(); QX_FunctionHasBeenCalledOnceAlready = false; } else if (State == State.DataLoaded) { QS_SessionIterators = new List(); for (int i = 0; i < BarsArray.Length; i++) QS_SessionIterators.Add(new SessionIterator(BarsArray[i])); } else if (State == State.Terminated) { QS_OnTerminated(); } } protected override void OnBarUpdate() { if (BarsInProgress != 0 || CurrentBars[0] < BarsRequiredToTrade) return; // Entry Point #region Entry Point if (QX_FunctionHasBeenCalledOnceAlready) return; QX_FunctionHasBeenCalledOnceAlready = true; ClearOutputWindow(); string QX_FilePath_62B0FC0CBBB24719B3A6FAFEB4D06A93 = string.Empty; if (QX_WriteImportedIndicatorsandTypesFiletoDefaultLocationMyDocumentsQuagensiaQuagensia_NMy_AlgosA) { QX_FilePath_62B0FC0CBBB24719B3A6FAFEB4D06A93 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), HDynamicTypeDb.DynamicIndicatorsAndTypesHardcodedEndingFilePath); } else { QX_FilePath_62B0FC0CBBB24719B3A6FAFEB4D06A93 = Path.Combine(QX_CustomFolderPathToWhichTheImportedIndicatorsandTypesFileShouldBeWrittenIfCheckBoxAboveisUnch, HDynamicTypeDb.DynamicIndicatorsAndTypesFileName); } HDynamicTypeDb dynamicTypeDb = new HDynamicTypeDb(QX_FilePath_62B0FC0CBBB24719B3A6FAFEB4D06A93, 110, NinjaTrader.Resource.NinjaScriptParameters, NinjaTrader.Resource.PropertyCategoryDataSeries, "Misc", NinjaTrader.Resource.GuiGeneral, NinjaTrader.Resource.NinjaScriptInput, TradingHours.UseInstrumentSettingsInstance.Name, TradingHours.UseDataSeriesSettingsInstance.Name); QF_PopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb); bool QX_Success_62B0FC0CBBB24719B3A6FAFEB4D06A93 = QF_SerializeHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb); string QX_SuccessorFailureMessage_62B0FC0CBBB24719B3A6FAFEB4D06A93 = string.Empty; if (QX_Success_62B0FC0CBBB24719B3A6FAFEB4D06A93) { QX_SuccessorFailureMessage_62B0FC0CBBB24719B3A6FAFEB4D06A93 = QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + "Success!" + Environment.NewLine + Environment.NewLine + "The " + HDynamicTypeDb.Trans_DynamicIndicatorsAndTypesHumanReadableFileName + " was successfully written to the following file path:" + Environment.NewLine + Environment.NewLine + QX_FilePath_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + "Once you close and reopen Quagensia N Edition, you should be able to use all of your " + Environment.NewLine + "third-party indicators and custom indicators that are currently supported by Quagensia N Edition " + Environment.NewLine + "and use enhanced versions of the NinjaTrader® indicators built into Quagensia N Edition." + Environment.NewLine + Environment.NewLine + QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine; } else { QX_SuccessorFailureMessage_62B0FC0CBBB24719B3A6FAFEB4D06A93 = QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + "ERROR: Unable to create the " + HDynamicTypeDb.Trans_DynamicIndicatorsAndTypesHumanReadableFileName + " at the following file path:" + Environment.NewLine + Environment.NewLine + QX_FilePath_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + "Please see the NinjaScript® Output window for detailed information about the error that occurred." + Environment.NewLine + Environment.NewLine + QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine; } QS_DrawTextFixed(this, QX_SuccessorFailureMessage_62B0FC0CBBB24719B3A6FAFEB4D06A93, TextPosition.Center, (QX_Success_62B0FC0CBBB24719B3A6FAFEB4D06A93 ? Color.FromArgb(255, 0, 0, 255) : Color.FromArgb(255, 255, 0, 0))); if (QX_Success_62B0FC0CBBB24719B3A6FAFEB4D06A93) QS_Print(QX_SuccessorFailureMessage_62B0FC0CBBB24719B3A6FAFEB4D06A93); #endregion // The "}" below closes off the OnBarUpdate() function (also called a // "method") so that the code beneath it can be outside of the // OnBarUpdate() function. } // QF_PopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicTypeDb // dynamicTypeDb) private void QF_PopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicTypeDb dynamicTypeDb) { QF_DoPopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb); } // QF_DoPopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicTypeDb // dynamicTypeDb) #region QF_DoPopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93 private void QF_DoPopulateHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicTypeDb dynamicTypeDb) { string sAll = string.Empty; List derivedIndicatorTypes = new List(); Type[] derivedIndicatorTypesFromAssemblyRegistry = Globals.AssemblyRegistry.GetDerivedTypes(typeof(IndicatorBase)); HashSet indicatorClassesThatRepresentDrawingToolsOrOtherNonIndicators = new HashSet() { "NinjaTrader.NinjaScript.Indicators.DrawingToolTile", "NinjaTrader.NinjaScript.Indicators.FXTile", "NinjaTrader.NinjaScript.Indicators.OrderFlowVolumeProfile" }; HashSet indicatorClassesThatNTSupportIndicatedCannotBeUsedInANinjaScriptStrategy = new HashSet() { "NinjaTrader.NinjaScript.Indicators.OrderFlowMarketDepthMap", "NinjaTrader.NinjaScript.Indicators.OrderFlowTradeDetector", "NinjaTrader.NinjaScript.Indicators.OrderFlowVolumeProfile" }; HashSet indicatorClassesThatNTSupportIndicatedCanBeUsedInANinjaScriptStrategyButThatQuagensiaIncHasNotTestedAndSupportedYet = new HashSet() { "NinjaTrader.NinjaScript.Indicators.OrderFlowCumulativeDelta", "NinjaTrader.NinjaScript.Indicators.OrderFlowVWAP" }; derivedIndicatorTypes = derivedIndicatorTypesFromAssemblyRegistry .Where(dit => dit.FullName != "NinjaTrader.NinjaScript.Indicators.Indicator" && dit.FullName != "NinjaTrader.Gui.NinjaScript.IndicatorRenderBase" && dit.FullName != "NinjaTrader.NinjaScript.IndicatorSuperDomBase" && !indicatorClassesThatRepresentDrawingToolsOrOtherNonIndicators.Contains(dit.FullName) && !indicatorClassesThatNTSupportIndicatedCannotBeUsedInANinjaScriptStrategy.Contains(dit.FullName) && !indicatorClassesThatNTSupportIndicatedCanBeUsedInANinjaScriptStrategyButThatQuagensiaIncHasNotTestedAndSupportedYet.Contains(dit.FullName) && dit.IsPublic && !dit.IsNested && !dit.IsAbstract) .OrderBy(item => item.Name).ToList(); try { if (TradingHours != null && TradingHours.All != null && TradingHours.All.Count > 0) { string orderFlowPlusTypeNameSuffix = "_Choices_From_OrderFlowPlusTradingHoursDataConverter"; Type tradingHoursType = typeof(NinjaTrader.Data.TradingHours); string tradingHoursTypeName = tradingHoursType.Name; string tradingHoursTypeName_OrderFlowPlusTradingHours = tradingHoursTypeName + orderFlowPlusTypeNameSuffix; string tradingHoursTypeFullyQualifiedName = tradingHoursType.FullName; string tradingHoursTypeFullyQualifiedName_OrderFlowPlusTradingHours = tradingHoursTypeFullyQualifiedName + orderFlowPlusTypeNameSuffix; if (!dynamicTypeDb.DynamicEnumIsAlreadyDefined(tradingHoursTypeFullyQualifiedName)) { System.Type tradingHoursEnumUnderlyingType = typeof(System.String); List enumeratedConstantValues = new List(); List enumeratedConstantValues_OrderFlowPlusTradingHours = new List(); List enumeratedConstantNames = new List(); List enumeratedConstantNames_OrderFlowPlusTradingHours = new List(); enumeratedConstantValues.Add(HDynamicTypeDb.TradingHoursName_UseInstrumentSettings_ID); enumeratedConstantValues_OrderFlowPlusTradingHours.Add(HDynamicTypeDb.TradingHoursName_UseDataSeriesSettings_ID); enumeratedConstantNames.Add(TradingHours.UseInstrumentSettingsInstance.ToString()); enumeratedConstantNames_OrderFlowPlusTradingHours.Add(TradingHours.UseDataSeriesSettingsInstance.ToString()); for (int i = 0; i < TradingHours.All.Count; i++) { NinjaTrader.Data.TradingHours tradingHours = TradingHours.All[i]; if (tradingHours != null) { if (!enumeratedConstantValues.Contains(tradingHours.Name)) { enumeratedConstantValues.Add(tradingHours.Name); enumeratedConstantNames.Add(tradingHours.ToString()); } if (!enumeratedConstantValues_OrderFlowPlusTradingHours.Contains(tradingHours.Name)) { enumeratedConstantValues_OrderFlowPlusTradingHours.Add(tradingHours.Name); enumeratedConstantNames_OrderFlowPlusTradingHours.Add(tradingHours.ToString()); } } } HDynamicEnum dynamicEnum = new HDynamicEnum(tradingHoursTypeFullyQualifiedName, tradingHoursTypeName, tradingHoursType.Namespace, tradingHoursType.Assembly.FullName, (tradingHoursType.Assembly.Location ?? string.Empty), tradingHoursType.Name, string.Empty, tradingHoursEnumUnderlyingType.FullName, tradingHoursEnumUnderlyingType.Name, tradingHoursEnumUnderlyingType.Namespace, tradingHoursEnumUnderlyingType.Assembly.FullName, (tradingHoursEnumUnderlyingType.Assembly.Location ?? string.Empty), true, HDynamicEnumOutputTypes.Text, enumeratedConstantNames, enumeratedConstantValues ); HDynamicEnum dynamicEnum_OrderFlowPlusTradingHours = new HDynamicEnum(tradingHoursTypeFullyQualifiedName_OrderFlowPlusTradingHours, tradingHoursTypeName_OrderFlowPlusTradingHours, tradingHoursType.Namespace, tradingHoursType.Assembly.FullName, (tradingHoursType.Assembly.Location ?? string.Empty), tradingHoursTypeName_OrderFlowPlusTradingHours, string.Empty, tradingHoursEnumUnderlyingType.FullName, tradingHoursEnumUnderlyingType.Name, tradingHoursEnumUnderlyingType.Namespace, tradingHoursEnumUnderlyingType.Assembly.FullName, (tradingHoursEnumUnderlyingType.Assembly.Location ?? string.Empty), true, HDynamicEnumOutputTypes.Text, enumeratedConstantNames_OrderFlowPlusTradingHours, enumeratedConstantValues_OrderFlowPlusTradingHours ); dynamicTypeDb.AddDynamicEnum(dynamicEnum); dynamicTypeDb.AddDynamicEnum(dynamicEnum_OrderFlowPlusTradingHours); } } } catch (Exception ex) { string customErrorDescription = "The TradingHours \"List of Choices\" Data Types could not be imported because an error occurred during the import process."; QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, ex, "Couldn't import the TradingHours \"List of Choices\" Data Types.", customErrorDescription); } try { string movingAverage_Choices_From_MovingAverageEnumConverter_FullyQualifiedName = "NinjaTrader.NinjaScript.Indicators.MovingAverage_Choices_From_MovingAverageEnumConverter"; string movingAverage_Choices_From_MovingAverageEnumConverter_Name = "MovingAverage_Choices_From_MovingAverageEnumConverter"; Type movingAverage_Choices_From_MovingAverageEnumConverter_Type = typeof(NinjaTrader.NinjaScript.Indicators.MovingAverageEnumConverter); if (!dynamicTypeDb.DynamicEnumIsAlreadyDefined(movingAverage_Choices_From_MovingAverageEnumConverter_FullyQualifiedName)) { System.Type movingAverage_Choices_From_MovingAverageEnumConverter_UnderlyingType = typeof(System.Int32); List enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter = new List(); List enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter = new List(); enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("1"); enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("EMA"); enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("2"); enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("HMA"); enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("3"); enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("SMA"); enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("4"); enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("TMA"); enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("5"); enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("TEMA"); enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("6"); enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter.Add("WMA"); HDynamicEnum dynamicEnum_MovingAverage_Choices_From_MovingAverageEnumConverter = new HDynamicEnum(movingAverage_Choices_From_MovingAverageEnumConverter_FullyQualifiedName, movingAverage_Choices_From_MovingAverageEnumConverter_Name, movingAverage_Choices_From_MovingAverageEnumConverter_Type.Namespace, movingAverage_Choices_From_MovingAverageEnumConverter_Type.Assembly.FullName, (movingAverage_Choices_From_MovingAverageEnumConverter_Type.Assembly.Location ?? string.Empty), movingAverage_Choices_From_MovingAverageEnumConverter_Name, string.Empty, movingAverage_Choices_From_MovingAverageEnumConverter_UnderlyingType.FullName, movingAverage_Choices_From_MovingAverageEnumConverter_UnderlyingType.Name, movingAverage_Choices_From_MovingAverageEnumConverter_UnderlyingType.Namespace, movingAverage_Choices_From_MovingAverageEnumConverter_UnderlyingType.Assembly.FullName, (movingAverage_Choices_From_MovingAverageEnumConverter_UnderlyingType.Assembly.Location ?? string.Empty), true, HDynamicEnumOutputTypes.Int32, enumeratedConstantNames_MovingAverage_Choices_From_MovingAverageEnumConverter, enumeratedConstantValues_MovingAverage_Choices_From_MovingAverageEnumConverter ); dynamicTypeDb.AddDynamicEnum(dynamicEnum_MovingAverage_Choices_From_MovingAverageEnumConverter); } } catch (Exception ex) { string customErrorDescription = "The MovingAverage_Choices_From_MovingAverageEnumConverter \"List of Choices\" Data Type could not be imported because an error occurred during the import process."; QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, ex, "Couldn't import the MovingAverage_Choices_From_MovingAverageEnumConverter \"List of Choices\" Data Type.", customErrorDescription); } HashSet methodInfoNames_Qualified_In_StrategyBaseClass = new HashSet(); try { List methodInfos_Qualified_In_StrategyBaseClass = base.GetType().GetMethods().ToList(); foreach (MethodInfo methodInfo_Qualified_In_StrategyBaseClass in methodInfos_Qualified_In_StrategyBaseClass) { if (!methodInfoNames_Qualified_In_StrategyBaseClass.Contains(methodInfo_Qualified_In_StrategyBaseClass.Name)) methodInfoNames_Qualified_In_StrategyBaseClass.Add(methodInfo_Qualified_In_StrategyBaseClass.Name); } } catch (Exception ex) { QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, ex, "Unable to create a list of function names available to NinjaTrader® strategies in this instance of NinjaTrader®.", null); } for (int i = 0; i < derivedIndicatorTypes.Count; i++) { Type derivedIndicatorType = derivedIndicatorTypes[i]; if (derivedIndicatorType == null) continue; var indicatorType = NinjaTrader.Core.Globals.AssemblyRegistry.GetType(derivedIndicatorType.FullName); if (indicatorType == null) continue; try { bool hasPossiblyFixableIssues = false; string possiblyFixableIssueMessages = string.Empty; bool instanceMethodExistsWithIndicatorNameInStrategyBaseClass = methodInfoNames_Qualified_In_StrategyBaseClass.Contains(derivedIndicatorType.Name); if (!instanceMethodExistsWithIndicatorNameInStrategyBaseClass) { hasPossiblyFixableIssues = true; possiblyFixableIssueMessages = "Indicator \"" + indicatorType.FullName + "\" is not currently usable in a NinjaTrader® strategy as a typical indicator using "; possiblyFixableIssueMessages += "typical NinjaScript® indicator syntax in your installation of NinjaTrader®, but this might (or might not) be fixable by you by "; possiblyFixableIssueMessages += "re-installing the indicator in NinjaTrader® and re-licensing the indicator if the indicator requires a license."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "Most indicators that are properly installed and licensed (by entering a license key, for instance) "; possiblyFixableIssueMessages += "can be used in a NinjaTrader® strategy using typical NinjaScript® indicator syntax that includes the name of the indicator in the strategy."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "The name of this indicator, however, is not among the list of indicator names that are available to "; possiblyFixableIssueMessages += "NinjaTrader® strategies using typical NinjaScript® indicator syntax in your installation of NinjaTrader®. "; possiblyFixableIssueMessages += "You can verify this for yourself by 1) opening the NinjaScript® Editor from the "; possiblyFixableIssueMessages += "\"New\" Main Menu from within NinjaTrader®, then 2) opening one of the editable, i.e. unlocked, strategies in the \"Strategies\" folder "; possiblyFixableIssueMessages += "on the \"NinjaScript® Explorer\" pane on the right side of the NinjaScript® Editor's window (note that the editable strategies have "; possiblyFixableIssueMessages += "icons with four horizontal lines whereas the the locked strategies' icons do not have four horizontal lines), then 3) typing the "; possiblyFixableIssueMessages += "five characters \"this.\", in that order (i.e. enter the '.' character last) somewhere near the middle of the strategy, and then 4) scrolling "; possiblyFixableIssueMessages += "through the alphabetically sorted list of indicators and other items available to the strategy that opens in a context menu after you type the "; possiblyFixableIssueMessages += "'.' character and noting the absence of this indicator's name and the existence of many other indicators' names in that list. "; possiblyFixableIssueMessages += "If typing the '.' character as the last character entered in the five "; possiblyFixableIssueMessages += "characters \"this.\" fails to cause a context menu to open, you need to type the characters \"this.\" in a different location, such as "; possiblyFixableIssueMessages += "after the first \"left curly brace\" character (which is also called the \"left curly bracket\" character) "; possiblyFixableIssueMessages += "after the text \"OnBarUpdate()\". Once you are done with verifying the lack of "; possiblyFixableIssueMessages += "your indicator's name in the context menu, be sure to remove the characters \"this.\" from the strategy you edited."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "If this indicator is actually only a drawing tool or if it is some other kind of visual object that is not the kind of indicator "; possiblyFixableIssueMessages += "that is usable in a NinjaTrader® strategy using typical NinjaScript® indicator syntax in the way that most indicators are, then this is not something that you can fix."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "However, if this indicator really is the kind of indicator that is usable in a NinjaTrader® strategy using typical NinjaScript® indicator syntax, "; possiblyFixableIssueMessages += "then perhaps all you have to do to fix this issue is to "; possiblyFixableIssueMessages += "re-install the indicator, and if the indicator requires a license, properly license the indicator, "; possiblyFixableIssueMessages += "for instance by entering a license key provided by the indicator vendor, then re-run the Quagensia N Edition indicator import process "; possiblyFixableIssueMessages += "and close and reopen Quagensia N Edition."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "If you are already using the newest version of Quagensia N Edition, have already tried re-installing "; possiblyFixableIssueMessages += "and re-licensing this indicator then re-importing your NinjaTrader® indicators into Quagensia N Edition using the "; possiblyFixableIssueMessages += "Quagensia N Edition Strategy that imports indicators that is built into the newest version of Quagensia N Edition, you are still seeing this message, "; possiblyFixableIssueMessages += "and you believe that this indicator is the kind of indicator that is usable in a NinjaTrader® strategy using typical NinjaScript® indicator syntax, "; possiblyFixableIssueMessages += "please inquire about this indicator in our official Discord community if you would like help determining if this indicator really "; possiblyFixableIssueMessages += "is the kind of indicator that is usable in a NinjaTrader® strategy using typical NinjaScript® indicator syntax and "; possiblyFixableIssueMessages += "so might be usable from within a Quagensia N Edition Strategy."; if (sAll != string.Empty) sAll += Environment.NewLine + Environment.NewLine; string possiblyFixableIssueMessages_With_LineBreaks = possiblyFixableIssueMessages; QF_BreakUpStringIntoLinesOfMaximumLength_62B0FC0CBBB24719B3A6FAFEB4D06A93(ref possiblyFixableIssueMessages_With_LineBreaks); sAll += QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + possiblyFixableIssueMessages_With_LineBreaks; } TypeInfo indicatorTypeInfo = indicatorType.GetTypeInfo(); dynamic indicatorObject = Activator.CreateInstance(indicatorType); if (indicatorObject != null) { indicatorObject.SetState(State.Configure); var indicatorBaseType = typeof(Indicator); HDynamicIndicator dynamicIndicator = new HDynamicIndicator(derivedIndicatorType.FullName, derivedIndicatorType.Name, derivedIndicatorType.Namespace, derivedIndicatorType.Assembly.FullName, (!string.IsNullOrWhiteSpace(derivedIndicatorType.Assembly.Location) ? derivedIndicatorType.Assembly.Location : string.Empty), (!string.IsNullOrWhiteSpace(indicatorObject.Name) ? indicatorObject.Name : derivedIndicatorType.Name), (!string.IsNullOrWhiteSpace(indicatorObject.Description) ? indicatorObject.Description : string.Empty), indicatorObject.ArePlotsConfigurable, false, string.Empty, hasPossiblyFixableIssues, possiblyFixableIssueMessages); #region Input Parameters List inputParamPropertyInfos = indicatorType .GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList() .Where(pi => pi.GetIndexParameters().Length == 0 && Attribute.IsDefined(pi, typeof(NinjaScriptPropertyAttribute))).ToList(); int inputParamPropertyInfosCount = inputParamPropertyInfos.Count; int paramCountOfFactoryMethodWithMostParams = -1; ParameterInfo[] indicatorParameterInfosOfFactoryMethodWithMostParams = null; List indicatorFactoryMethodMethodInfos = indicatorBaseType.GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(mi => mi.Name == indicatorType.Name && mi.ReturnType.ToString() == indicatorType.ToString()).ToList(); if (indicatorFactoryMethodMethodInfos.Count > 0) { for (int j = 0; j < indicatorFactoryMethodMethodInfos.Count; j++) { MethodInfo indicatorFactoryMethodMethodInfo = indicatorFactoryMethodMethodInfos[j]; if (indicatorFactoryMethodMethodInfo != null) { ParameterInfo[] indicatorParameterInfos = indicatorFactoryMethodMethodInfo.GetParameters(); if (indicatorParameterInfos.Length > paramCountOfFactoryMethodWithMostParams) { paramCountOfFactoryMethodWithMostParams = indicatorParameterInfos.Length; //indicatorMethodInfoBest = indicatorMethodInfo; indicatorParameterInfosOfFactoryMethodWithMostParams = indicatorParameterInfos; } } } if (indicatorParameterInfosOfFactoryMethodWithMostParams != null && indicatorParameterInfosOfFactoryMethodWithMostParams.Length > 0 && indicatorParameterInfosOfFactoryMethodWithMostParams.Length != inputParamPropertyInfosCount + 1) { dynamicIndicator.HasPossiblyFixableIssues = true; possiblyFixableIssueMessages = "Indicator \"" + indicatorType.FullName + "\" cannot be used in a Quagensia N Edition Strategy because unlike most indicators, there is no "; possiblyFixableIssueMessages += "function available to NinjaTrader® strategies that is named \"" + indicatorType.Name + "\" and that uses all of this indicator's "; possiblyFixableIssueMessages += "\"public properties\" that are \"decorated with an attribute\" named \"NinjaScriptProperty\"."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "This might (or might not) be fixable by you if you have access to this indicator's source code and can identify a reason why "; possiblyFixableIssueMessages += "one or more of this indicator's public properties decorated with the \"NinjaScriptProperty\" attribute are not included in a function "; possiblyFixableIssueMessages += "named \"" + indicatorType.Name + "\" that is available to NinjaTrader® strategies and then rectify the problem if that is possible. "; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "Here are the names of this indicator's public properties that are decorated with the \"NinjaScriptProperty\" attribute, which you can "; possiblyFixableIssueMessages += "verify for yourself if you have access to this indicator's source code by searching for the word \"NinjaScriptProperty\" in this indicator's source code:"; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; string decoratedPublicProperties = string.Empty; List decoratedPublicPropertyNamesList = new List(); for (int inputParamIndex = 0; inputParamIndex < inputParamPropertyInfosCount; inputParamIndex++) { PropertyInfo inputParamPropertyInfo = inputParamPropertyInfos[inputParamIndex]; decoratedPublicPropertyNamesList.Add(inputParamPropertyInfo.Name); decoratedPublicProperties += inputParamPropertyInfo.Name; if (inputParamIndex != inputParamPropertyInfosCount - 1) decoratedPublicProperties += ", "; } possiblyFixableIssueMessages += decoratedPublicProperties; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "Here are the names of the relevant parameters used by the function that 1) is named \"" + indicatorType.Name + "\", "; possiblyFixableIssueMessages += "2) is available to NinjaTrader® strategies, and 3) that a Quagensia N Edition Strategy would use if its parameter list "; possiblyFixableIssueMessages += "included all of this indicator's public properties decorated with the \"NinjaScriptProperty\" attribute:"; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; string indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeries = string.Empty; List indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeriesList = new List(); for (int inputParamIndex = 1; inputParamIndex < indicatorParameterInfosOfFactoryMethodWithMostParams.Length; inputParamIndex++) { ParameterInfo inputParamInfo = indicatorParameterInfosOfFactoryMethodWithMostParams[inputParamIndex]; indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeriesList.Add(inputParamInfo.Name); indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeries += inputParamInfo.Name; if (inputParamIndex != inputParamPropertyInfosCount - 1) indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeries += ", "; } List decoratedPublicPropertiesMissingAFunctionParamList = new List(); for (int inputParamIndex = 0; inputParamIndex < decoratedPublicPropertyNamesList.Count; inputParamIndex++) { if (!indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeriesList.Contains(decoratedPublicPropertyNamesList[inputParamIndex], StringComparer.OrdinalIgnoreCase)) decoratedPublicPropertiesMissingAFunctionParamList.Add(decoratedPublicPropertyNamesList[inputParamIndex]); } possiblyFixableIssueMessages += indicatorParameterInfoNamesOfFactoryMethodWithMostParams_ExceptFirstParamForDataSeries; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "You can verify this list of parameter names for yourself by 1) opening the NinjaScript® Editor from the "; possiblyFixableIssueMessages += "\"New\" Main Menu from within NinjaTrader®, then 2) opening one of the editable, i.e. unlocked, strategies in the \"Strategies\" folder "; possiblyFixableIssueMessages += "on the \"NinjaScript® Explorer\" pane on the right side of the NinjaScript® Editor's window (note that the editable strategies have "; possiblyFixableIssueMessages += "icons with four horizontal lines whereas the the locked strategies' icons do not have four horizontal lines), then 3) typing the "; possiblyFixableIssueMessages += "five characters \"this.\", in that order (i.e. enter the '.' character last) somewhere near the middle of the strategy, and then 4) scrolling "; possiblyFixableIssueMessages += "through the alphabetically sorted list of indicators and other items available to the strategy that opens in a context menu after you type the "; possiblyFixableIssueMessages += "'.' character, selecting the item with the same name as this indicator, i.e. the item named \"" + indicatorType.Name + "\", "; possiblyFixableIssueMessages += "then typing a left parenthesis character, i.e. the '(' character, to the right of the indicator name and noting the names of the parameters "; possiblyFixableIssueMessages += "used by the function named \"" + indicatorType.Name + "\" in the tooltip that appears. If typing the '.' character as the last character entered in the five "; possiblyFixableIssueMessages += "characters \"this.\" fails to cause a context menu to open, you need to type the characters \"this.\" in a different location, such as "; possiblyFixableIssueMessages += "after the first \"left curly brace\" character (which is also called the \"left curly bracket\" character) "; possiblyFixableIssueMessages += "after the text \"OnBarUpdate()\". Once you are done with verifying the list of parameter names used by this function, "; possiblyFixableIssueMessages += "be sure to remove the text you added to the strategy you edited."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; if (decoratedPublicPropertiesMissingAFunctionParamList.Count > 0) { possiblyFixableIssueMessages += "A case-insensitive comparison of the two lists above determined that the following public " + ((decoratedPublicPropertiesMissingAFunctionParamList.Count > 1) ? "properties that are" : "property that is") + " decorated with the \"NinjaScriptProperty\" attribute " + ((decoratedPublicPropertiesMissingAFunctionParamList.Count > 1) ? "appear" : "appears") + " to be missing from the list of parameters used by this function: "; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; for (int inputParamIndex = 0; inputParamIndex < decoratedPublicPropertiesMissingAFunctionParamList.Count; inputParamIndex++) possiblyFixableIssueMessages += decoratedPublicPropertiesMissingAFunctionParamList[inputParamIndex] + Environment.NewLine; possiblyFixableIssueMessages += Environment.NewLine; } possiblyFixableIssueMessages += "If you don't have access to this indicator's source code or if changing this indicator to fix this issue would break something else, "; possiblyFixableIssueMessages += "then this is not something that you can fix."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "However, if you are able to fix this issue in the indicator's source code, then perhaps all you have to do to fix this issue is to "; possiblyFixableIssueMessages += "fix this issue in the indicator's source code, then re-run the Quagensia N Edition indicator import process "; possiblyFixableIssueMessages += "and close and reopen Quagensia N Edition."; possiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine; possiblyFixableIssueMessages += "If you are already using the newest version of Quagensia N Edition, have already tried fixing this issue in the indicator's source code "; possiblyFixableIssueMessages += "then re-importing your NinjaTrader® indicators into Quagensia N Edition using the "; possiblyFixableIssueMessages += "Quagensia N Edition Strategy that imports indicators that is built into the newest version of Quagensia N Edition, you are still seeing this message, "; possiblyFixableIssueMessages += "and you believe that the indicator import process is incorrectly reporting this issue, "; possiblyFixableIssueMessages += "please inquire about this issue in our official Discord community if you would like help determining if this issue is fixable "; possiblyFixableIssueMessages += "so that you can use the \"" + indicatorType.Name + "\" indicator from within a Quagensia N Edition Strategy."; if (!string.IsNullOrWhiteSpace(dynamicIndicator.PossiblyFixableIssueMessages)) dynamicIndicator.PossiblyFixableIssueMessages += Environment.NewLine + Environment.NewLine + possiblyFixableIssueMessages; else dynamicIndicator.PossiblyFixableIssueMessages = possiblyFixableIssueMessages; if (sAll != string.Empty) sAll += Environment.NewLine + Environment.NewLine; string possiblyFixableIssueMessages_With_LineBreaks = possiblyFixableIssueMessages; QF_BreakUpStringIntoLinesOfMaximumLength_62B0FC0CBBB24719B3A6FAFEB4D06A93(ref possiblyFixableIssueMessages_With_LineBreaks); sAll += QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + possiblyFixableIssueMessages_With_LineBreaks; } } if (inputParamPropertyInfosCount > 0) { Dictionary categoryDisplayOrderByCategoryName = new Dictionary(); IEnumerable indicatorCategoryOrderAttributes = indicatorTypeInfo.GetCustomAttributes(true); if (indicatorCategoryOrderAttributes != null) { foreach (CategoryOrderAttribute indicatorCategoryOrderAttribute in indicatorCategoryOrderAttributes) { if (indicatorCategoryOrderAttribute != null) { string categoryOrderAttribute_CategoryName = indicatorCategoryOrderAttribute.Category != null ? indicatorCategoryOrderAttribute.Category.Trim() : string.Empty; double categoryOrderAttribute_CategoryDisplayOrder = indicatorCategoryOrderAttribute.Order; if (categoryOrderAttribute_CategoryName != string.Empty && !categoryDisplayOrderByCategoryName.ContainsKey(categoryOrderAttribute_CategoryName)) categoryDisplayOrderByCategoryName.Add(categoryOrderAttribute_CategoryName, categoryOrderAttribute_CategoryDisplayOrder); } } } for (int inputParamIndex = 0; inputParamIndex < inputParamPropertyInfosCount; inputParamIndex++) { PropertyInfo inputParamPropertyInfo = inputParamPropertyInfos[inputParamIndex]; string paramNameInCode = inputParamPropertyInfo.Name; string paramHumanReadableName = paramNameInCode; string paramDescription = string.Empty; string paramCategoryName = dynamicTypeDb.CategoryName_General; double paramCategoryDisplayOrder = HDynamicTypeDb.CategoryDisplayOrder_Default; Type inputParamPropertyInfoPropertyType = inputParamPropertyInfo.PropertyType; string paramDataTypeFullyQualifiedName = inputParamPropertyInfoPropertyType.FullName; string paramDataTypeNameInCode = inputParamPropertyInfoPropertyType.Name; bool paramDataTypeIsEnum = inputParamPropertyInfoPropertyType.IsEnum; string indicatorParameterInfoEnumUnderlyingType_FullName = string.Empty; bool isBrowsable_InputParam = true; string extraInfo_InputParam = string.Empty; bool hasErrors_InputParam = false; string errorMessages_InputParam = string.Empty; if (paramDataTypeIsEnum) { System.Type indicatorParameterInfoEnumUnderlyingType = System.Enum.GetUnderlyingType(inputParamPropertyInfoPropertyType); indicatorParameterInfoEnumUnderlyingType_FullName = indicatorParameterInfoEnumUnderlyingType.FullName; if (!dynamicTypeDb.DynamicEnumIsAlreadyDefined(paramDataTypeFullyQualifiedName)) { string enumHumanReadableName = inputParamPropertyInfoPropertyType.Name; string enumDescription = string.Empty; string enumSuffix = string.Empty; string enumValidValues = string.Empty; string[] indicatorParameterInfoEnumNames = System.Enum.GetNames(inputParamPropertyInfoPropertyType); Array indicatorParameterInfoEnumValues = System.Enum.GetValues(inputParamPropertyInfoPropertyType); List enumeratedConstantValues = new List(); foreach (object indicatorParameterInfoEnumValue in indicatorParameterInfoEnumValues) enumeratedConstantValues.Add(HDynamicTypeDbSer.ConvertIntegralNumberObjectToIntegralNumberValueString_ThrowsExceptionIfNull(indicatorParameterInfoEnumValue, indicatorParameterInfoEnumUnderlyingType_FullName)); List enumeratedConstantNames = indicatorParameterInfoEnumNames.ToList(); HDynamicEnum dynamicEnum = new HDynamicEnum(inputParamPropertyInfoPropertyType.FullName, inputParamPropertyInfoPropertyType.Name, inputParamPropertyInfoPropertyType.Namespace, inputParamPropertyInfoPropertyType.Assembly.FullName, (!string.IsNullOrWhiteSpace(inputParamPropertyInfoPropertyType.Assembly.Location) ? inputParamPropertyInfoPropertyType.Assembly.Location : string.Empty), enumHumanReadableName, enumDescription, indicatorParameterInfoEnumUnderlyingType.FullName, indicatorParameterInfoEnumUnderlyingType.Name, indicatorParameterInfoEnumUnderlyingType.Namespace, indicatorParameterInfoEnumUnderlyingType.Assembly.FullName, (!string.IsNullOrWhiteSpace(indicatorParameterInfoEnumUnderlyingType.Assembly.Location) ? indicatorParameterInfoEnumUnderlyingType.Assembly.Location : string.Empty), true, HDynamicEnumOutputTypes.NormalEnum, enumeratedConstantNames, enumeratedConstantValues ); dynamicTypeDb.AddDynamicEnum(dynamicEnum); } } HDynamicType paramMinValue = null; HDynamicType paramMaxValue = null; double paramDisplayOrder = HDynamicTypeDb.DisplayOrder_Default; HDynamicType defaultValue = null; if (Attribute.IsDefined(inputParamPropertyInfo, typeof(BrowsableAttribute))) { BrowsableAttribute paramBrowsableAttribute = inputParamPropertyInfo.GetCustomAttribute(typeof(BrowsableAttribute)) as BrowsableAttribute; if (paramBrowsableAttribute != null && !paramBrowsableAttribute.Browsable) isBrowsable_InputParam = false; } if (Attribute.IsDefined(inputParamPropertyInfo, typeof(DisplayAttribute))) { DisplayAttribute paramDisplayAttribute = inputParamPropertyInfo.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute; if (paramDisplayAttribute != null) { string paramHumanReadableName_Translated = string.Empty; try { paramHumanReadableName_Translated = paramDisplayAttribute.GetName(); } catch { paramHumanReadableName_Translated = paramDisplayAttribute.Name; } if (!string.IsNullOrWhiteSpace(paramHumanReadableName_Translated)) paramHumanReadableName = paramHumanReadableName_Translated; string paramDescription_Translated = string.Empty; try { paramDescription_Translated = paramDisplayAttribute.GetDescription(); } catch { paramDescription_Translated = paramDisplayAttribute.Description; } if (!string.IsNullOrWhiteSpace(paramDescription_Translated)) paramDescription = paramDescription_Translated; string paramCategoryName_Translated = string.Empty; try { paramCategoryName_Translated = paramDisplayAttribute.GetGroupName(); } catch { paramCategoryName_Translated = paramDisplayAttribute.GroupName; } if (!string.IsNullOrWhiteSpace(paramCategoryName_Translated)) paramCategoryName = paramCategoryName_Translated; if (categoryDisplayOrderByCategoryName.ContainsKey(paramCategoryName)) paramCategoryDisplayOrder = categoryDisplayOrderByCategoryName[paramCategoryName]; else paramCategoryDisplayOrder = HDynamicTypeDb.CategoryDisplayOrder_Default; double? paramDisplayAttribute_Raw = null; try { paramDisplayAttribute_Raw = paramDisplayAttribute.GetOrder(); } catch { paramDisplayAttribute_Raw = HDynamicTypeDb.DisplayOrder_Default; } if (paramDisplayAttribute_Raw.HasValue) paramDisplayOrder = paramDisplayAttribute_Raw.Value; else paramDisplayOrder = HDynamicTypeDb.DisplayOrder_Default; } } object propertyValueObject = inputParamPropertyInfo.GetValue(indicatorObject, null); IConvertible paramMinValueObjectAsIConvertible = null; IConvertible paramMaxValueObjectAsIConvertible = null; if (Attribute.IsDefined(inputParamPropertyInfo, typeof(RangeAttribute))) { RangeAttribute paramRangeAttribute = inputParamPropertyInfo.GetCustomAttribute(typeof(RangeAttribute)) as RangeAttribute; if (paramRangeAttribute != null) { object paramMinValueObject = paramRangeAttribute.Minimum; object paramMaxValueObject = paramRangeAttribute.Maximum; paramMinValueObjectAsIConvertible = paramMinValueObject as IConvertible; paramMaxValueObjectAsIConvertible = paramMaxValueObject as IConvertible; } } string propertyValue_As_String = (propertyValueObject != null ? propertyValueObject.ToString() : string.Empty); bool isTradingHours = false; bool isTradingHours_Choices_From_OrderFlowPlusTradingHoursDataConverter = false; bool isMovingAverage_Choices_From_MovingAverageEnumConverter = false; if (Attribute.IsDefined(inputParamPropertyInfo, typeof(TypeConverterAttribute))) { TypeConverterAttribute typeConverterAttribute = inputParamPropertyInfo.GetCustomAttribute(typeof(TypeConverterAttribute)) as TypeConverterAttribute; if (typeConverterAttribute != null) { if (typeConverterAttribute.ConverterTypeName.Contains("NinjaTrader.NinjaScript.OrderFlowPlusTradingHoursDataConverter,") && (inputParamPropertyInfoPropertyType.FullName == "System.String" || inputParamPropertyInfoPropertyType.FullName == "NinjaTrader.Data.TradingHours")) { isTradingHours_Choices_From_OrderFlowPlusTradingHoursDataConverter = true; paramDataTypeFullyQualifiedName = "NinjaTrader.Data.TradingHours_Choices_From_OrderFlowPlusTradingHoursDataConverter"; paramDataTypeNameInCode = "NinjaTrader.Data.TradingHours_Choices_From_OrderFlowPlusTradingHoursDataConverter"; extraInfo_InputParam = inputParamPropertyInfoPropertyType.FullName == "System.String" ? "S" : "T"; paramDataTypeIsEnum = true; if (propertyValue_As_String == TradingHours.UseDataSeriesSettingsInstance.Name) propertyValue_As_String = HDynamicTypeDb.TradingHoursName_UseDataSeriesSettings_ID; } else if (typeConverterAttribute.ConverterTypeName.Contains("NinjaTrader.NinjaScript.TradingHoursDataConverter,") && (inputParamPropertyInfoPropertyType.FullName == "System.String" || inputParamPropertyInfoPropertyType.FullName == "NinjaTrader.Data.TradingHours")) { isTradingHours = true; paramDataTypeFullyQualifiedName = "NinjaTrader.Data.TradingHours"; paramDataTypeNameInCode = "NinjaTrader.Data.TradingHours"; extraInfo_InputParam = inputParamPropertyInfoPropertyType.FullName == "System.String" ? "S" : "T"; paramDataTypeIsEnum = true; if (propertyValue_As_String == TradingHours.UseInstrumentSettingsInstance.Name) propertyValue_As_String = HDynamicTypeDb.TradingHoursName_UseInstrumentSettings_ID; } else if (typeConverterAttribute.ConverterTypeName.Contains("NinjaTrader.NinjaScript.Indicators.MovingAverageEnumConverter,") && SQ_IsANumericTypeThatAnInt32CanBeImplictlyCastToAndIsSupportedByQuagensia_62B0FC0CBBB24719B3A6FAFEB4D06A93(inputParamPropertyInfoPropertyType)) { isMovingAverage_Choices_From_MovingAverageEnumConverter = true; paramDataTypeFullyQualifiedName = "NinjaTrader.NinjaScript.Indicators.MovingAverage_Choices_From_MovingAverageEnumConverter"; paramDataTypeNameInCode = "NinjaTrader.NinjaScript.Indicators.MovingAverage_Choices_From_MovingAverageEnumConverter"; paramDataTypeIsEnum = true; } } } if (paramDataTypeIsEnum) { defaultValue = new HDynamicEnumValue(paramDataTypeFullyQualifiedName, propertyValue_As_String); } else { switch (paramDataTypeFullyQualifiedName) { case "System.Double": defaultValue = new HDynamicDouble((System.Double)propertyValueObject); System.Double minValueAsDouble = System.Double.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsDouble = paramMinValueObjectAsIConvertible.ToDouble(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicDouble(minValueAsDouble); System.Double maxValueAsDouble = System.Double.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsDouble = paramMaxValueObjectAsIConvertible.ToDouble(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicDouble(maxValueAsDouble); break; case "System.Single": defaultValue = new HDynamicSingle((System.Single)propertyValueObject); System.Single minValueAsSingle = System.Single.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsSingle = paramMinValueObjectAsIConvertible.ToSingle(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicSingle(minValueAsSingle); System.Single maxValueAsSingle = System.Single.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsSingle = paramMaxValueObjectAsIConvertible.ToSingle(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicSingle(maxValueAsSingle); break; case "System.Int32": defaultValue = new HDynamicInt32((System.Int32)propertyValueObject); System.Int32 minValueAsInt32 = System.Int32.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsInt32 = paramMinValueObjectAsIConvertible.ToInt32(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicInt32(minValueAsInt32); System.Int32 maxValueAsInt32 = System.Int32.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsInt32 = paramMaxValueObjectAsIConvertible.ToInt32(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicInt32(maxValueAsInt32); break; case "System.UInt32": defaultValue = new HDynamicUInt32((System.UInt32)propertyValueObject); System.UInt32 minValueAsUInt32 = System.UInt32.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsUInt32 = paramMinValueObjectAsIConvertible.ToUInt32(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicUInt32(minValueAsUInt32); System.UInt32 maxValueAsUInt32 = System.UInt32.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsUInt32 = paramMaxValueObjectAsIConvertible.ToUInt32(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicUInt32(maxValueAsUInt32); break; case "System.Int64": defaultValue = new HDynamicInt64((System.Int64)propertyValueObject); System.Int64 minValueAsInt64 = System.Int64.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsInt64 = paramMinValueObjectAsIConvertible.ToInt64(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicInt64(minValueAsInt64); System.Int64 maxValueAsInt64 = System.Int64.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsInt64 = paramMaxValueObjectAsIConvertible.ToInt64(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicInt64(maxValueAsInt64); break; case "System.UInt64": defaultValue = new HDynamicUInt64((System.UInt64)propertyValueObject); System.UInt64 minValueAsUInt64 = System.UInt64.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsUInt64 = paramMinValueObjectAsIConvertible.ToUInt64(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicUInt64(minValueAsUInt64); System.UInt64 maxValueAsUInt64 = System.UInt64.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsUInt64 = paramMaxValueObjectAsIConvertible.ToUInt64(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicUInt64(maxValueAsUInt64); break; case "System.Int16": defaultValue = new HDynamicInt16((System.Int16)propertyValueObject); System.Int16 minValueAsInt16 = System.Int16.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsInt16 = paramMinValueObjectAsIConvertible.ToInt16(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicInt16(minValueAsInt16); System.Int16 maxValueAsInt16 = System.Int16.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsInt16 = paramMaxValueObjectAsIConvertible.ToInt16(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicInt16(maxValueAsInt16); break; case "System.UInt16": defaultValue = new HDynamicUInt16((System.UInt16)propertyValueObject); System.UInt16 minValueAsUInt16 = System.UInt16.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsUInt16 = paramMinValueObjectAsIConvertible.ToUInt16(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicUInt16(minValueAsUInt16); System.UInt16 maxValueAsUInt16 = System.UInt16.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsUInt16 = paramMaxValueObjectAsIConvertible.ToUInt16(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicUInt16(maxValueAsUInt16); break; case "System.Byte": defaultValue = new HDynamicByte((System.Byte)propertyValueObject); System.Byte minValueAsByte = System.Byte.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsByte = paramMinValueObjectAsIConvertible.ToByte(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicByte(minValueAsByte); System.Byte maxValueAsByte = System.Byte.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsByte = paramMaxValueObjectAsIConvertible.ToByte(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicByte(maxValueAsByte); break; case "System.SByte": defaultValue = new HDynamicSByte((System.SByte)propertyValueObject); System.SByte minValueAsSByte = System.SByte.MinValue; if (paramMinValueObjectAsIConvertible != null) { try { minValueAsSByte = paramMinValueObjectAsIConvertible.ToSByte(CultureInfo.InvariantCulture); } catch { } } paramMinValue = new HDynamicSByte(minValueAsSByte); System.SByte maxValueAsSByte = System.SByte.MaxValue; if (paramMaxValueObjectAsIConvertible != null) { try { maxValueAsSByte = paramMaxValueObjectAsIConvertible.ToSByte(CultureInfo.InvariantCulture); } catch { } } paramMaxValue = new HDynamicSByte(maxValueAsSByte); break; case "System.String": defaultValue = new HDynamicString(propertyValueObject != null ? (propertyValueObject.ToString() ?? string.Empty) : string.Empty); break; case "System.Boolean": defaultValue = new HDynamicBoolean((System.Boolean)propertyValueObject); break; case "System.DateTime": HDynamicDateTimeTypes dynamicDateTimeType = HDynamicDateTimeTypes.DateAndTime_DateWithoutTime; if (Attribute.IsDefined(inputParamPropertyInfo, typeof(NinjaTrader.Gui.PropertyEditorAttribute))) { NinjaTrader.Gui.PropertyEditorAttribute paramPropertyEditorAttribute = inputParamPropertyInfo.GetCustomAttribute(typeof(NinjaTrader.Gui.PropertyEditorAttribute)) as NinjaTrader.Gui.PropertyEditorAttribute; if (paramPropertyEditorAttribute != null) { if (paramPropertyEditorAttribute.EditorType == "NinjaTrader.Gui.Tools.AutoCloseTimeEditorKey" || paramPropertyEditorAttribute.EditorType == "NinjaTrader.Gui.Tools.TimeEditorKey") { dynamicDateTimeType = HDynamicDateTimeTypes.DateAndTime_TimeOfDay; } else if (paramPropertyEditorAttribute.EditorType == "NinjaTrader.Gui.Tools.ChartAnchorTimeEditor") { dynamicDateTimeType = HDynamicDateTimeTypes.DateAndTime_Complete; } } } defaultValue = new HDynamicDateTime(dynamicDateTimeType, (System.DateTime)propertyValueObject); break; case "System.Windows.Media.Color": System.Windows.Media.Color color_Media = (System.Windows.Media.Color)propertyValueObject; defaultValue = new HDynamicColor(new HColorARGB(color_Media.A, color_Media.R, color_Media.G, color_Media.B)); break; case "System.Windows.Media.Brush": System.Windows.Media.Brush brush_Media = propertyValueObject as System.Windows.Media.Brush; if (brush_Media is System.Windows.Media.SolidColorBrush solidColorBrush_Media) defaultValue = new HDynamicWindowsMediaBrush_SolidColorBrush(new HColorARGB(solidColorBrush_Media.Color.A, solidColorBrush_Media.Color.R, solidColorBrush_Media.Color.G, solidColorBrush_Media.Color.B)); else defaultValue = new HDynamicWindowsMediaBrush_SolidColorBrush(new HColorARGB(255, 0, 0, 255)); break; case "NinjaTrader.Gui.Stroke": NinjaTrader.Gui.Stroke stroke = propertyValueObject as NinjaTrader.Gui.Stroke; QF_AddAddDynamicEnum_IfNeeded_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, typeof(NinjaTrader.Gui.DashStyleHelper), true); string dynamicDashStyleHelper_Stroke_Value = DashStyleHelper.Solid.ToString(); System.Windows.Media.SolidColorBrush solidColorBrush_Media_For_Stroke = QS_GetBrush_SolidColor(Colors.Blue); float stroke_Width = 1.0f; int stroke_Opacity = 100; if (stroke != null) { dynamicDashStyleHelper_Stroke_Value = stroke.DashStyleHelper.ToString(); System.Windows.Media.Brush brush_Media_For_Stroke = stroke.Brush; solidColorBrush_Media_For_Stroke = brush_Media_For_Stroke as System.Windows.Media.SolidColorBrush; if (solidColorBrush_Media_For_Stroke == null) solidColorBrush_Media_For_Stroke = QS_GetBrush_SolidColor(Colors.Blue); stroke_Width = stroke.Width; stroke_Opacity = stroke.Opacity; } defaultValue = new HDynamicNGuiStroke_SolidColorBrush( new HColorARGB(solidColorBrush_Media_For_Stroke.Color.A, solidColorBrush_Media_For_Stroke.Color.R, solidColorBrush_Media_For_Stroke.Color.G, solidColorBrush_Media_For_Stroke.Color.B) , dynamicDashStyleHelper_Stroke_Value, stroke_Width, stroke_Opacity); break; case "NinjaTrader.Gui.Tools.SimpleFont": string simpleFont_FontFamily = "Arial"; double simpleFont_Size = 12; bool simpleFont_Bold = false; bool simpleFont_Italic = false; NinjaTrader.Gui.Tools.SimpleFont simpleFont = propertyValueObject as NinjaTrader.Gui.Tools.SimpleFont; if (simpleFont != null) { simpleFont_FontFamily = simpleFont.Family != null ? simpleFont.Family.ToString() : string.Empty; simpleFont_Size = simpleFont.Size; simpleFont_Bold = simpleFont.Bold; simpleFont_Italic = simpleFont.Italic; } defaultValue = new HDynamicNGuiSimpleFont(simpleFont_FontFamily, simpleFont_Size, simpleFont_Bold, simpleFont_Italic); break; } } if (defaultValue == null) { hasErrors_InputParam = true; dynamicIndicator.HasErrors = true; if (sAll != string.Empty) sAll += Environment.NewLine + Environment.NewLine; sAll += QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 + Environment.NewLine + Environment.NewLine + "Indicator \"" + indicatorType.FullName + "\" could not be imported into Quagensia N Edition. " + Environment.NewLine + Environment.NewLine; string errorMessage_InputParam = "The input parameter named \"" + paramHumanReadableName + "\", and whose name in code is \"" + paramNameInCode + "\", has a data type of \"" + paramDataTypeFullyQualifiedName + "\". "; errorMessage_InputParam += "This data type is currently not supported for use as an input parameter of an imported indicator in Quagensia N Edition. "; errorMessage_InputParam += "If you are already using the newest version of Quagensia N Edition and have already tried re-importing your indicators using the "; errorMessage_InputParam += "built-in Quagensia N Edition Strategy that imports indicators using the newest version of Quagensia N Edition, "; errorMessage_InputParam += "please contact us at support [at] quagensia.com to let us know of this specific error message so we can either support it in a future version or let you know if it will be possible to support input parameters of this data type."; if (errorMessages_InputParam != string.Empty) errorMessages_InputParam += Environment.NewLine + Environment.NewLine; errorMessages_InputParam += errorMessage_InputParam; dynamicIndicator.ErrorMessages += errorMessages_InputParam; string errorMessages_InputParam_With_LineBreaks = errorMessages_InputParam; QF_BreakUpStringIntoLinesOfMaximumLength_62B0FC0CBBB24719B3A6FAFEB4D06A93(ref errorMessages_InputParam_With_LineBreaks); sAll += errorMessages_InputParam_With_LineBreaks; inputParamPropertyInfoPropertyType = typeof(System.String); paramDataTypeFullyQualifiedName = inputParamPropertyInfoPropertyType.FullName; paramDataTypeNameInCode = inputParamPropertyInfoPropertyType.Name; paramDataTypeIsEnum = false; paramMinValue = null; paramMaxValue = null; defaultValue = new HDynamicString(propertyValueObject != null ? (propertyValueObject.ToString() ?? string.Empty) : string.Empty); } HDynamicIndicator_InputParameter dynamicIndicator_InputParameter = new HDynamicIndicator_InputParameter(paramNameInCode, paramHumanReadableName, paramDescription, paramCategoryName, paramCategoryDisplayOrder, paramDataTypeFullyQualifiedName, paramDataTypeNameInCode, paramDataTypeIsEnum, paramMinValue, paramMaxValue, paramDisplayOrder, defaultValue, isBrowsable_InputParam, extraInfo_InputParam, hasErrors_InputParam, errorMessages_InputParam); dynamicIndicator.AddDynamicIndicator_InputParameter(dynamicIndicator_InputParameter); } } #endregion #region Internal Variables (Plots and Data Series) Plot[] indicatorPlots = indicatorObject.Plots; List dataSeriesPropertyInfos = indicatorType.GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList().Where(pi => pi.PropertyType == typeof(Series) && pi.Name != "Value").ToList(); if (indicatorPlots != null) { for (int j = 0; j < indicatorPlots.Length; j++) { Plot indicatorPlot = indicatorPlots[j]; string varNameInCode = "Plot" + HDynamicTypeDbSer.Int32ToString_Unformatted_ValueStore(j + 1); string varHumanReadableName = indicatorPlot.Name; string varDescription = "The plot named " + indicatorPlot.Name; string varCategoryName = "Plots"; string varDataTypeFullyQualifiedName = "NinjaTrader.NinjaScript.DataSeries"; string varDataTypeNameInCode = "DataSeries"; SolidColorBrush indicatorPlot_Brush_SolidColorBrush = indicatorPlot.Brush as SolidColorBrush; int indicatorPlot_Opacity = indicatorPlot.Opacity; float indicatorPlot_Width = indicatorPlot.Width; PlotStyle indicatorPlot_PlotStyle = indicatorPlot.PlotStyle; DashStyleHelper indicatorPlot_DashStyleHelper = indicatorPlot.DashStyleHelper; HColorARGB indicatorPlot_hColorARG = null; if (indicatorPlot_Brush_SolidColorBrush != null) indicatorPlot_hColorARG = new HColorARGB(indicatorPlot_Brush_SolidColorBrush.Color.A, indicatorPlot_Brush_SolidColorBrush.Color.R, indicatorPlot_Brush_SolidColorBrush.Color.G, indicatorPlot_Brush_SolidColorBrush.Color.B); else indicatorPlot_hColorARG = new HColorARGB(255, 0, 0, 255); HDynamicIndicator_InternalVariable dynamicIndicator_InternalVariable = new HDynamicIndicator_InternalVariable(varNameInCode, varHumanReadableName, varDescription, varCategoryName, varDataTypeFullyQualifiedName, varDataTypeNameInCode, true, false, int.MinValue, indicatorPlot_hColorARG, indicatorPlot_PlotStyle.ToString(), indicatorPlot_DashStyleHelper.ToString(), indicatorPlot_Width, indicatorPlot_Opacity, false, string.Empty); if (indicatorPlots.Length == 1 && (dataSeriesPropertyInfos == null || dataSeriesPropertyInfos.Count == 0)) dynamicIndicator.ValuePlot = dynamicIndicator_InternalVariable; else dynamicIndicator.AddDynamicIndicator_InternalVariable(dynamicIndicator_InternalVariable); } } if (dataSeriesPropertyInfos != null) { for (int j = 0; j < dataSeriesPropertyInfos.Count; j++) { PropertyInfo dataSeriesPropertyInfo = dataSeriesPropertyInfos[j]; string varNameInCode = dataSeriesPropertyInfo.Name; string varHumanReadableName = varNameInCode; string varDescription = string.Empty; string varCategoryName = string.Empty; string varDataTypeFullyQualifiedName = "NinjaTrader.NinjaScript.DataSeries"; string varDataTypeNameInCode = "DataSeries"; double varDisplayOrder = HDynamicTypeDb.DisplayOrder_Default; if (Attribute.IsDefined(dataSeriesPropertyInfo, typeof(DisplayAttribute))) { DisplayAttribute varDisplayAttribute = dataSeriesPropertyInfo.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute; if (varDisplayAttribute != null) { string varHumanReadableName_Translated = string.Empty; try { varHumanReadableName_Translated = varDisplayAttribute.GetName(); } catch { varHumanReadableName_Translated = varDisplayAttribute.Name; } varHumanReadableName = !string.IsNullOrWhiteSpace(varHumanReadableName_Translated) ? varHumanReadableName_Translated : varNameInCode; string varDescription_Translated = string.Empty; try { varDescription_Translated = varDisplayAttribute.GetDescription(); } catch { varDescription_Translated = varDisplayAttribute.Description; } varDescription = !string.IsNullOrWhiteSpace(varDescription_Translated) ? varDescription_Translated : string.Empty; string varCategoryName_Translated = string.Empty; try { varCategoryName_Translated = varDisplayAttribute.GetGroupName(); } catch { varCategoryName_Translated = varDisplayAttribute.GroupName; } varCategoryName = !string.IsNullOrWhiteSpace(varCategoryName_Translated) ? varCategoryName_Translated : dynamicTypeDb.CategoryName_General; double? varDisplayAttribute_Raw = null; try { varDisplayAttribute_Raw = varDisplayAttribute.GetOrder(); } catch { varDisplayAttribute_Raw = HDynamicTypeDb.DisplayOrder_Default; } if (varDisplayAttribute_Raw.HasValue) varDisplayOrder = varDisplayAttribute_Raw.Value; else varDisplayOrder = HDynamicTypeDb.DisplayOrder_Default; } } HDynamicIndicator_InternalVariable dynamicIndicator_InternalVariable = new HDynamicIndicator_InternalVariable(varNameInCode, varHumanReadableName, varDescription, varCategoryName, varDataTypeFullyQualifiedName, varDataTypeNameInCode, false, true, varDisplayOrder, new HColorARGB(255, 0, 0, 255), PlotStyle.Line.ToString(), DashStyleHelper.Solid.ToString(), 1, 100, false, string.Empty); dynamicIndicator.AddDynamicIndicator_InternalVariable(dynamicIndicator_InternalVariable); } } #endregion indicatorObject.SetState(State.Terminated); dynamicTypeDb.AddDynamicIndicator(dynamicIndicator); } else { sAll += "The Indicator \"" + indicatorType.FullName + "\" could not be imported because the following code returned null: Activator.CreateInstance(indicatorType)" + Environment.NewLine + Environment.NewLine; } } catch (Exception ex) { string customErrorDescription = "Indicator \"" + indicatorType.FullName + "\" could not be imported because an error occurred in the indicator importing process."; QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, ex, "Couldn't Import Indicator \"" + indicatorType.FullName + "\".", customErrorDescription); } } Type[] derivedEnumTypesFromAssemblyRegistry = Globals.AssemblyRegistry.GetDerivedTypes(typeof(System.Enum)); List derivedEnumTypes = derivedEnumTypesFromAssemblyRegistry.Where(det => !det.IsNested && det.IsPublic && !det.IsAbstract && det.FullName != "System.Enum").OrderBy(item => item.FullName).ToList(); for (int i = 0; i < derivedEnumTypes.Count; i++) { string enumTypeFullName = "UNKNOWN"; try { Type derivedEnumType = derivedEnumTypes[i]; if (derivedEnumType == null) continue; enumTypeFullName = derivedEnumType.FullName; var enumType = NinjaTrader.Core.Globals.AssemblyRegistry.GetType(enumTypeFullName); if (enumType == null) continue; QF_AddAddDynamicEnum_IfNeeded_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, enumType, false); } catch (Exception ex) { string customErrorDescription = "\"List of Choices\" Data Type \"" + enumTypeFullName + "\" could not be imported because an error occurred in the \"List of Choices\" Data Type importing process."; QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, ex, "Couldn't import \"List of Choices\" Data Type \"" + enumTypeFullName + "\".", customErrorDescription); } } #region After the Main Indicator Loop Print(sAll); Print(Environment.NewLine + Environment.NewLine); #endregion } #endregion // Auxiliary Functions #region Auxiliary Functions private bool QF_AddAddDynamicEnum_IfNeeded_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicTypeDb dynamicTypeDb, System.Type dataType, bool mightBeRequiredByADynamicType) { if (!dataType.IsEnum) return false; string enumTypeFullName = dataType.FullName; if (!dynamicTypeDb.DynamicEnumIsAlreadyDefined(enumTypeFullName)) { string enumTypeName = dataType.Name; System.Type enumUnderlyingType = System.Enum.GetUnderlyingType(dataType); string enumUnderlyingType_FullName = enumUnderlyingType.FullName; string enumHumanReadableName = dataType.Name; string enumDescription = string.Empty; string[] enumNames = System.Enum.GetNames(dataType); List enumeratedConstantNames = enumNames.ToList(); Array enumValues = System.Enum.GetValues(dataType); List enumeratedConstantValues = new List(); foreach (object enumValue in enumValues) enumeratedConstantValues.Add(HDynamicTypeDbSer.ConvertIntegralNumberObjectToIntegralNumberValueString_ThrowsExceptionIfNull(enumValue, enumUnderlyingType_FullName)); HDynamicEnum dynamicEnum = new HDynamicEnum(enumTypeFullName, enumTypeName, dataType.Namespace, dataType.Assembly.FullName, (!string.IsNullOrWhiteSpace(dataType.Assembly.Location) ? dataType.Assembly.Location : string.Empty), enumHumanReadableName, enumDescription, enumUnderlyingType.FullName, enumUnderlyingType.Name, enumUnderlyingType.Namespace, enumUnderlyingType.Assembly.FullName, (!string.IsNullOrWhiteSpace(enumUnderlyingType.Assembly.Location) ? enumUnderlyingType.Assembly.Location : string.Empty), mightBeRequiredByADynamicType, HDynamicEnumOutputTypes.NormalEnum, enumeratedConstantNames, enumeratedConstantValues); dynamicTypeDb.AddDynamicEnum(dynamicEnum); return true; } return false; } private bool QF_SerializeHDynamicTypeDb_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicTypeDb dynamicTypeDb) { try { if (!HDynamicTypeDbSer.ParentDirectoryExists(dynamicTypeDb.FilePath)) { string exceptionMessage = "Couldn't save the " + HDynamicTypeDb.Trans_DynamicIndicatorsAndTypesHumanReadableFileName + " to the requested file path, " + Environment.NewLine + "\"" + dynamicTypeDb.FilePath + "\", " + Environment.NewLine + "because its folder path, \"" + HDynamicTypeDbSer.Directory_GetParent(dynamicTypeDb.FilePath) + "\", doesn't exist or is inaccessible. " + Environment.NewLine + Environment.NewLine + "If the folder path points to a network drive or cloud drive, perhaps your machine is " + Environment.NewLine + "not connected to the network or network drive, perhaps your machine is not connected " + Environment.NewLine + "to the the internet, or perhaps you need to log into a cloud service to access a cloud drive. " + Environment.NewLine + Environment.NewLine + "Please save this file to Quagensia N Edition's \"My Algos\" folder." + Environment.NewLine; throw new Exception(exceptionMessage); } else if (!dynamicTypeDb.FilePath.EndsWith(HDynamicTypeDb.DynamicIndicatorsAndTypesHardcodedEndingFilePath, StringComparison.OrdinalIgnoreCase)) { string exceptionMessage = "Couldn't save the " + HDynamicTypeDb.Trans_DynamicIndicatorsAndTypesHumanReadableFileName + " to the requested file path, " + Environment.NewLine + "\"" + dynamicTypeDb.FilePath + "\", " + Environment.NewLine + "because this file must be saved to Quagensia N Edition's \"My Algos\" folder, which will always " + Environment.NewLine + "be in a folder path that ends with the following three subfolders: " + HDynamicTypeDb.DynamicIndicatorsAndTypesHardcodedEndingFolderPath + "." + Environment.NewLine + Environment.NewLine + "Please save this file to Quagensia N Edition's \"My Algos\" folder." + Environment.NewLine + Environment.NewLine; if ((QX_WriteImportedIndicatorsandTypesFiletoDefaultLocationMyDocumentsQuagensiaQuagensia_NMy_AlgosA) == false) { exceptionMessage += "The most probable reason why most users receive this message is that like you, they unchecked the " + Environment.NewLine + "checkbox of this strategy's first input parameter to indicate that their \"My Algos\" folder is in a non-default " + Environment.NewLine + "folder path when in reality very few users ever change the folder path of their \"My Algos\" folder." + Environment.NewLine + Environment.NewLine + "If your \"My Algos\" folder really is in a non-default folder path, then just make sure that " + Environment.NewLine + "the folder path you enter into the textbox of this strategy's second input parameter ends " + Environment.NewLine + "with the following 3 folders: " + HDynamicTypeDb.DynamicIndicatorsAndTypesHardcodedEndingFolderPath + "." + Environment.NewLine + Environment.NewLine; } exceptionMessage += "To find the folder path of your \"My Algos\" folder, right click on it in the Algo Explorer on the left side of " + Environment.NewLine + "Quagensia N Edition and select \"Open Folder\" in the context menu that appears. This will open the \"My Algos\" folder " + Environment.NewLine + "using your default file management application, which is usually File Explorer (previously called Windows Explorer)." + Environment.NewLine + "The folder path of the \"My Algos\" folder should be shown in the \"address bar\" of the file management application at the" + Environment.NewLine + "top of the file management application's window. If the folder path of your \"My Algos\" folder is not shown in the" + Environment.NewLine + "\"address bar\" or is not displayed with backslashes ('\\' characters), you may have to left click in the " + Environment.NewLine + "\"address bar\" to get the folder path to appear as a proper Windows folder path with backslashes." + Environment.NewLine; throw new Exception(exceptionMessage); } byte[] dynamicTypeDbFileAsBytes = HDynamicTypeDb.SerializeHDynamicTypeDbToByteArray(dynamicTypeDb); File.WriteAllBytes(dynamicTypeDb.FilePath, dynamicTypeDbFileAsBytes); dynamicTypeDb.CompatibleWithSerializationVersion = HDynamicTypeDbSer.SerializationVersion_Current; dynamicTypeDb.CompatibleWithFourPartVersionNbr = HDynamicTypeDbSer.SerializationFourPartVersionNbr_Current; } catch (Exception ex) { string customErrorDescription = null; if (!HDynamicTypeDbSer.ParentDirectoryExists(dynamicTypeDb.FilePath)) { customErrorDescription = "This problem can sometimes occur due to overly strict anti-virus settings that stop NinjaTrader® from being able to write this file to " + Environment.NewLine + "disk at the location you specified. For instance, if you use the \"Windows Security\" application that comes with Microsoft Windows to " + Environment.NewLine + "protect your computer, and its \"Controlled folder access\" setting is set to \"On\", the \"Windows Security\" application will stop NinjaTrader® " + Environment.NewLine + "from being able to write this file to disk at the location you specified. You can fix this by explicitly allowing NinjaTrader® " + Environment.NewLine + "to do these things from within Windows Security by opening Windows Security, clicking the \"Virus & threat protection\" " + Environment.NewLine + "tab, then scrolling down to the bottom of the screen and clicking the \"Manage ransomware protection\" link, clicking the " + Environment.NewLine + "\"Allow an app through Controlled folder access\" link, clicking the \"Add an allowed app\" button, and from the drop-down " + Environment.NewLine + "list selecting \"Recently blocked apps\", then clicking the \"+\" button next to the NinjaTrader.exe executable. " + Environment.NewLine + "If this problem is due to your Windows Security settings, a Windows Security alert window should appear in the lower right of your " + Environment.NewLine + "screen, but if it doesn't you can find it by either searching for \"Windows Security\" in the Microsoft Windows search text box or " + Environment.NewLine + "by clicking on its icon, which is probably a blue shield that you should be able to find by clicking an " + Environment.NewLine + "\"up/expand\" icon in the lower right corner of your screen and clicking the Windows Security icon from the list of icons that appear " + Environment.NewLine + "above the \"up/expand\" icon."; } QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(dynamicTypeDb, ex, HDynamicTypeDb.Trans_CouldntSaveHDynamicTypeDbFileToDisk(string.Empty), customErrorDescription); return false; } return true; } private void QF_HandleError_62B0FC0CBBB24719B3A6FAFEB4D06A93(HDynamicType dynamicType, Exception exception, string customMessage, string customDescription) { try { string exceptionMessage = (exception != null && !string.IsNullOrEmpty(exception.Message)) ? exception.Message : string.Empty; string errorMessage = !string.IsNullOrEmpty(customMessage) ? customMessage : exceptionMessage; if (string.IsNullOrEmpty(errorMessage)) errorMessage = "Unspecified Error"; errorMessage = HDynamicTypeDbSer.GetErrorMessageString(exception, errorMessage, customDescription); Print(Environment.NewLine + Environment.NewLine); Print(errorMessage); } catch { } } private HashSet SQ_NumericTypesThatAnInt32CanBeImplictlyCastToAndAreSupportedByQuagensia_62B0FC0CBBB24719B3A6FAFEB4D06A93 = new HashSet { typeof(System.Double), typeof(System.Single), typeof(System.Int32), typeof(System.Int64) }; private bool SQ_IsANumericTypeThatAnInt32CanBeImplictlyCastToAndIsSupportedByQuagensia_62B0FC0CBBB24719B3A6FAFEB4D06A93(Type dataType) { return SQ_NumericTypesThatAnInt32CanBeImplictlyCastToAndAreSupportedByQuagensia_62B0FC0CBBB24719B3A6FAFEB4D06A93.Contains(dataType); } private string qs_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 = null; private string QS_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 { get { if (qs_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 == null) qs_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93 = new String('=', QS_NumberOfCharsInOneLineOfHumanReadableComments_IdealMax_62B0FC0CBBB24719B3A6FAFEB4D06A93); return qs_HorizontalLineSeparator_62B0FC0CBBB24719B3A6FAFEB4D06A93; } } private int QS_NumberOfCharsInOneLineOfHumanReadableComments_IdealMax_62B0FC0CBBB24719B3A6FAFEB4D06A93 = 120; private void QF_BreakUpStringIntoLinesOfMaximumLength_62B0FC0CBBB24719B3A6FAFEB4D06A93(ref string value) { List lines = QF_GetLinesFromMultiLineString_62B0FC0CBBB24719B3A6FAFEB4D06A93(value); for (int i = 0; i < lines.Count; i++) { if (lines[i].Length > QS_NumberOfCharsInOneLineOfHumanReadableComments_IdealMax_62B0FC0CBBB24719B3A6FAFEB4D06A93) { string[] splitLine = lines[i].Split(new char[] { ' ' }); List subLines = new List(); string subLine = string.Empty; for (int j = 0; j < splitLine.Length; j++) { if (subLine == string.Empty) { subLine = splitLine[j]; } else if (subLine.Length + splitLine[j].Length + 1 <= QS_NumberOfCharsInOneLineOfHumanReadableComments_IdealMax_62B0FC0CBBB24719B3A6FAFEB4D06A93) { subLine += " " + splitLine[j]; } else { subLines.Add(subLine); subLine = splitLine[j]; } if (j == splitLine.Length - 1 && subLine != string.Empty) subLines.Add(subLine); } lines[i] = QF_GetMultiLineStringFromLines_62B0FC0CBBB24719B3A6FAFEB4D06A93(subLines, Environment.NewLine); } } value = QF_GetMultiLineStringFromLines_62B0FC0CBBB24719B3A6FAFEB4D06A93(lines, Environment.NewLine); } private List QF_GetLinesFromMultiLineString_62B0FC0CBBB24719B3A6FAFEB4D06A93(string multiLineString) { multiLineString = multiLineString.Replace("\r", ""); multiLineString = multiLineString.Replace("\n", Environment.NewLine); List multiLineStringList = multiLineString.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).ToList(); return multiLineStringList; } private string QF_GetMultiLineStringFromLines_62B0FC0CBBB24719B3A6FAFEB4D06A93(List lines, string newLineDelimiter) { StringBuilder s = new StringBuilder(); for (int i = 0; i < lines.Count; i++) { s.Append(lines[i]); if (i < lines.Count - 1) s.Append(newLineDelimiter); } return s.ToString(); } #endregion // The Objects // // The code below contains the objects that hold the dynamically // generated indicator info, enumerated constant (for dynamic "List of // Choices" drop-down lists) info, and other info. The info held in these // objects is written to the "Imported Indicators and Types" file when // requested to do so by the code in the first "Raw Code Output (Single // or Multiple Statements)" logic component above. #region The Objects public partial class HDynamicIndicator : HDynamicType { public string FullyQualifiedName { get; set; } public string NameInCode { get; set; } public string Namespace { get; set; } public string AssemblyFullName { get; set; } public string AssemblyLocation { get; set; } public string HumanReadableName { get; set; } public string Description { get; set; } public bool PlotsAreConfigurable { get; set; } public bool HasErrors { get; set; } public string ErrorMessages { get; set; } public bool HasPossiblyFixableIssues { get; set; } public string PossiblyFixableIssueMessages { get; set; } public HDynamicIndicator_InternalVariable ValuePlot { get; set; } public bool IndicatorHasAtLeastOneVisiblePlotThatCanBeDisplayedOnAChart { get { return true; } } public bool IndicatorCanBeUsedInCalculations_ItIsNotForDisplayPurposesOnly { get { return true; } } public bool HasSameUserFacingNameAsAnotherDynamicIndicator { get; set; } public List _dynamicIndicator_InputParameters { get; set; } public List GetDynamicIndicator_InputParameters() { return _dynamicIndicator_InputParameters; } public void AddDynamicIndicator_InputParameter(HDynamicIndicator_InputParameter dynamicIndicator_InputParameter) { _dynamicIndicator_InputParameters.Add(dynamicIndicator_InputParameter); } public List _dynamicIndicator_InternalVariables { get; set; } public List GetDynamicIndicator_InternalVariables() { return _dynamicIndicator_InternalVariables; } public void AddDynamicIndicator_InternalVariable(HDynamicIndicator_InternalVariable dynamicIndicator_InternalVariable) { _dynamicIndicator_InternalVariables.Add(dynamicIndicator_InternalVariable); } public HDynamicIndicator(string fullyQualifiedName, string nameInCode, string nameSpace, string assemblyFullName, string assemblyLocation, string humanReadableName, string description, bool plotsAreConfigurable, bool hasErrors, string errorMessages, bool hasPossiblyFixableIssues, string possiblyFixableIssueMessages) : base(fullyQualifiedName) { FullyQualifiedName = fullyQualifiedName; NameInCode = nameInCode; Namespace = nameSpace; AssemblyFullName = assemblyFullName; AssemblyLocation = assemblyLocation; HumanReadableName = humanReadableName; Description = description; _dynamicIndicator_InputParameters = new List(); _dynamicIndicator_InternalVariables = new List(); PlotsAreConfigurable = plotsAreConfigurable; ValuePlot = null; HasErrors = hasErrors; ErrorMessages = errorMessages; HasPossiblyFixableIssues = hasPossiblyFixableIssues; PossiblyFixableIssueMessages = possiblyFixableIssueMessages; } public override string ToString() { string s = "FullyQualifiedName: " + FullyQualifiedName + Environment.NewLine + "NameInCode: " + NameInCode + Environment.NewLine + "Namespace: " + Namespace + Environment.NewLine + "AssemblyFullName: " + AssemblyFullName + Environment.NewLine + "AssemblyLocation: " + AssemblyLocation + Environment.NewLine + "HumanReadableName: " + HumanReadableName + Environment.NewLine + "Description: " + Description + Environment.NewLine + "PlotsAreConfigurable: " + PlotsAreConfigurable + Environment.NewLine + "ValuePlot: " + (ValuePlot != null ? ValuePlot.ToString() : "null") + Environment.NewLine + "IndicatorHasAtLeastOneVisiblePlotThatCanBeDisplayedOnAChart: " + IndicatorHasAtLeastOneVisiblePlotThatCanBeDisplayedOnAChart + Environment.NewLine + "IndicatorCanBeUsedInCalculations_ItIsNotForDisplayPurposesOnly: " + IndicatorCanBeUsedInCalculations_ItIsNotForDisplayPurposesOnly + Environment.NewLine + "HasSameUserFacingNameAsAnotherDynamicIndicator: " + HasSameUserFacingNameAsAnotherDynamicIndicator + Environment.NewLine + "HasErrors: " + HasErrors + Environment.NewLine + "ErrorMessages: " + ErrorMessages + Environment.NewLine + "HasPossiblyFixableIssues: " + HasPossiblyFixableIssues + Environment.NewLine + "PossiblyFixableIssueMessages: " + PossiblyFixableIssueMessages + Environment.NewLine; s += "Input Parameters:" + Environment.NewLine; foreach (HDynamicIndicator_InputParameter dynamicIndicator_InputParameter in _dynamicIndicator_InputParameters) s += dynamicIndicator_InputParameter.ToString() + Environment.NewLine; s += Environment.NewLine; s += "Internal Variables:" + Environment.NewLine; foreach (HDynamicIndicator_InternalVariable dynamicIndicator_InternalVariable in _dynamicIndicator_InternalVariables) s += dynamicIndicator_InternalVariable.ToString() + Environment.NewLine; s += Environment.NewLine; return s; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicIndicator; } public override string HTypeName { get { return "Dynamic Indicator"; } } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, FullyQualifiedName); HDynamicTypeDbSer.WriteString(w, NameInCode); HDynamicTypeDbSer.WriteString(w, Namespace); HDynamicTypeDbSer.WriteString(w, AssemblyFullName); HDynamicTypeDbSer.WriteString(w, AssemblyLocation); HDynamicTypeDbSer.WriteString(w, HumanReadableName); HDynamicTypeDbSer.WriteString(w, Description); HDynamicTypeDbSer.WriteBoolean(w, PlotsAreConfigurable); HDynamicTypeDbSer.WriteHDynamicType(w, ValuePlot); HDynamicTypeDbSer.WriteBoolean(w, HasErrors); HDynamicTypeDbSer.WriteString(w, ErrorMessages); HDynamicTypeDbSer.WriteBoolean(w, HasPossiblyFixableIssues); HDynamicTypeDbSer.WriteString(w, PossiblyFixableIssueMessages); HDynamicTypeDbSer.WriteListOfHDynamicTypes(w, _dynamicIndicator_InputParameters); HDynamicTypeDbSer.WriteListOfHDynamicTypes(w, _dynamicIndicator_InternalVariables); HDynamicTypeDbSer.WriteBoolean(w, HasSameUserFacingNameAsAnotherDynamicIndicator); } } public partial class HDynamicIndicator_InputParameter : HDynamicType { public string NameInCode { get; set; } public string HumanReadableName { get; set; } public string Description { get; set; } public string CategoryName { get; set; } public double CategoryDisplayOrder { get; set; } public string DataTypeFullyQualifiedName { get; set; } public string DataTypeNameInCode { get; set; } public bool DataTypeIsEnum { get; set; } public HDynamicType MinValue { get; set; } public HDynamicType MaxValue { get; set; } public double DisplayOrder { get; set; } public HDynamicType DefaultValue { get; set; } public bool IsBrowsable { get; set; } public string ExtraInfo { get; set; } public bool HasErrors { get; set; } public string ErrorMessages { get; set; } public HDynamicIndicator_InputParameter(string nameInCode, string humanReadableName, string description, string categoryName, double categoryDisplayOrder, string dataTypeFullyQualifiedName, string dataTypeNameInCode, bool dataTypeIsEnum, HDynamicType minValue, HDynamicType maxValue, double displayOrder, HDynamicType defaultValue, bool isBrowsable, string extraInfo, bool hasErrors, string errorMessages) : base(nameInCode) { NameInCode = nameInCode; HumanReadableName = humanReadableName; Description = description; CategoryName = categoryName; CategoryDisplayOrder = categoryDisplayOrder; DataTypeFullyQualifiedName = dataTypeFullyQualifiedName; DataTypeNameInCode = dataTypeNameInCode; DataTypeIsEnum = dataTypeIsEnum; MinValue = minValue; MaxValue = maxValue; DisplayOrder = displayOrder; DefaultValue = defaultValue; IsBrowsable = isBrowsable; ExtraInfo = extraInfo; HasErrors = hasErrors; ErrorMessages = errorMessages; } public override string ToString() { string s = "NameInCode: " + NameInCode + Environment.NewLine + "HumanReadableName: " + HumanReadableName + Environment.NewLine + "Description: " + Description + Environment.NewLine + "CategoryName: " + CategoryName + Environment.NewLine + "CategoryDisplayOrder: " + CategoryDisplayOrder + Environment.NewLine + "DataTypeFullyQualifiedName: " + DataTypeFullyQualifiedName + Environment.NewLine + "DataTypeNameInCode: " + DataTypeNameInCode + Environment.NewLine + "DataTypeIsEnum: " + DataTypeIsEnum + Environment.NewLine + "MinValue: " + MinValue + Environment.NewLine + "MaxValue: " + MaxValue + Environment.NewLine + "DisplayOrder: " + DisplayOrder + Environment.NewLine + "DefaultValue: " + DefaultValue + Environment.NewLine + "IsBrowsable: " + IsBrowsable + Environment.NewLine + "ExtraInfo: " + ExtraInfo + Environment.NewLine + "HasErrors: " + HasErrors + Environment.NewLine + "ErrorMessages: " + ErrorMessages + Environment.NewLine; return s; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicIndicator_InputParameter; } public override string HTypeName { get { return "Dynamic Indicator Input Parameter"; } } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, NameInCode); HDynamicTypeDbSer.WriteString(w, HumanReadableName); HDynamicTypeDbSer.WriteString(w, Description); HDynamicTypeDbSer.WriteString(w, CategoryName); HDynamicTypeDbSer.WriteDouble(w, CategoryDisplayOrder); HDynamicTypeDbSer.WriteString(w, DataTypeFullyQualifiedName); HDynamicTypeDbSer.WriteString(w, DataTypeNameInCode); HDynamicTypeDbSer.WriteBoolean(w, DataTypeIsEnum); HDynamicTypeDbSer.WriteHDynamicType(w, MinValue); HDynamicTypeDbSer.WriteHDynamicType(w, MaxValue); HDynamicTypeDbSer.WriteDouble(w, DisplayOrder); HDynamicTypeDbSer.WriteHDynamicType(w, DefaultValue); HDynamicTypeDbSer.WriteBoolean(w, IsBrowsable); HDynamicTypeDbSer.WriteString(w, ExtraInfo); HDynamicTypeDbSer.WriteBoolean(w, HasErrors); HDynamicTypeDbSer.WriteString(w, ErrorMessages); } } public partial class HDynamicIndicator_InternalVariable : HDynamicType { public string NameInCode { get; set; } public string HumanReadableName { get; set; } public string Description { get; set; } public string CategoryName { get; set; } public string DataTypeFullyQualifiedName { get; set; } public string DataTypeNameInCode { get; set; } public bool IndicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart { get; set; } public bool IndicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly { get; set; } public double DisplayOrder { get; set; } public HColorARGB Plot_ColorARGB { get; set; } public string Plot_PlotStyleEnumConstName { get; set; } public string Plot_DashStyleHelperEnumConstName { get; set; } public float Plot_Width { get; set; } public int Plot_Opacity { get; set; } public bool HasErrors { get; set; } public string ErrorMessages { get; set; } public HDynamicIndicator_InternalVariable(string nameInCode, string humanReadableName, string description, string categoryName, string dataTypeFullyQualifiedName, string dataTypeNameInCode, bool indicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart, bool indicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly, double displayOrder, HColorARGB plot_ColorARGB, string plot_PlotStyleEnumConstName, string plot_DashStyleHelperEnumConstName, float plot_Width, int plot_Opacity, bool hasErrors, string errorMessages ) : base(nameInCode) { NameInCode = nameInCode; HumanReadableName = humanReadableName; Description = description; CategoryName = categoryName; DataTypeFullyQualifiedName = dataTypeFullyQualifiedName; DataTypeNameInCode = dataTypeNameInCode; IndicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart = indicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart; IndicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly = indicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly; DisplayOrder = displayOrder; Plot_ColorARGB = plot_ColorARGB; Plot_PlotStyleEnumConstName = plot_PlotStyleEnumConstName; Plot_DashStyleHelperEnumConstName = plot_DashStyleHelperEnumConstName; Plot_Width = plot_Width; Plot_Opacity = plot_Opacity; HasErrors = hasErrors; ErrorMessages = errorMessages; } public override string ToString() { string s = "NameInCode: " + NameInCode + Environment.NewLine + "HumanReadableName: " + HumanReadableName + Environment.NewLine + "Description: " + Description + Environment.NewLine + "CategoryName: " + CategoryName + Environment.NewLine + "DataTypeFullyQualifiedName: " + DataTypeFullyQualifiedName + Environment.NewLine + "DataTypeNameInCode: " + DataTypeNameInCode + Environment.NewLine + "IndicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart: " + IndicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart + Environment.NewLine + "IndicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly: " + IndicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly + Environment.NewLine + "DisplayOrder: " + DisplayOrder + Environment.NewLine + "Plot_ColorARGB: " + Plot_ColorARGB + Environment.NewLine + "Plot_PlotStyleEnumConstName: " + Plot_PlotStyleEnumConstName + Environment.NewLine + "Plot_DashStyleHelperEnumConstName: " + Plot_DashStyleHelperEnumConstName + Environment.NewLine + "Plot_Width: " + Plot_Width + Environment.NewLine + "Plot_Opacity: " + Plot_Opacity + Environment.NewLine + "HasErrors: " + HasErrors + Environment.NewLine + "ErrorMessages: " + ErrorMessages + Environment.NewLine; return s; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicIndicator_InternalVariable; } public override string HTypeName { get { return "Dynamic Indicator Internal Variable"; } } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, NameInCode); HDynamicTypeDbSer.WriteString(w, HumanReadableName); HDynamicTypeDbSer.WriteString(w, Description); HDynamicTypeDbSer.WriteString(w, CategoryName); HDynamicTypeDbSer.WriteString(w, DataTypeFullyQualifiedName); HDynamicTypeDbSer.WriteString(w, DataTypeNameInCode); HDynamicTypeDbSer.WriteBoolean(w, IndicatorPlotIsAVisiblePlotThatCanBeDisplayedOnAChart); HDynamicTypeDbSer.WriteBoolean(w, IndicatorPlotCanBeUsedInCalculationsItIsNotForDisplayPurposesOnly); HDynamicTypeDbSer.WriteDouble(w, DisplayOrder); HDynamicTypeDbSer.WriteColorARGB(w, Plot_ColorARGB.A, Plot_ColorARGB.R, Plot_ColorARGB.G, Plot_ColorARGB.B); HDynamicTypeDbSer.WriteString(w, Plot_PlotStyleEnumConstName); HDynamicTypeDbSer.WriteString(w, Plot_DashStyleHelperEnumConstName); HDynamicTypeDbSer.WriteSingle(w, Plot_Width); HDynamicTypeDbSer.WriteInt32(w, Plot_Opacity); HDynamicTypeDbSer.WriteBoolean(w, HasErrors); HDynamicTypeDbSer.WriteString(w, ErrorMessages); } } public enum HDynamicEnumOutputTypes : int { NormalEnum = 1, Text = 2, Int32 = 3 } public partial class HDynamicEnum : HDynamicType { public string FullyQualifiedName { get; set; } public string NameInCode { get; set; } public string Namespace { get; set; } public string AssemblyFullName { get; set; } public string AssemblyLocation { get; set; } public string HumanReadableName { get; set; } public string Description { get; set; } public string UnderlyingType_FullyQualifiedName { get; set; } public string UnderlyingType_NameInCode { get; set; } public string UnderlyingType_Namespace { get; set; } public string UnderlyingType_AssemblyFullName { get; set; } public string UnderlyingType_AssemblyLocation { get; set; } public bool MightBeRequiredByADynamicType { get; set; } public HDynamicEnumOutputTypes EnumOutputType = HDynamicEnumOutputTypes.NormalEnum; public List EnumeratedConstantNames { get; set; } public List EnumeratedConstantValues { get; set; } public bool HasSameUserFacingNameAsAnotherDynamicEnum { get; set; } public HDynamicEnum(string fullyQualifiedName, string nameInCode, string nameSpace, string assemblyFullName, string assemblyLocation, string humanReadableName, string description, string underlyingType_FullyQualifiedName, string underlyingType_NameInCode, string underlyingType_Namespace, string underlyingType_AssemblyFullName, string underlyingType_AssemblyLocation, bool mightBeRequiredByADynamicType, HDynamicEnumOutputTypes enumOutputType, List enumeratedConstantNames, List enumeratedConstantValues ) : base(fullyQualifiedName) { FullyQualifiedName = fullyQualifiedName; NameInCode = nameInCode; Namespace = nameSpace; AssemblyFullName = assemblyFullName; AssemblyLocation = assemblyLocation; HumanReadableName = humanReadableName; Description = description; UnderlyingType_FullyQualifiedName = underlyingType_FullyQualifiedName; UnderlyingType_NameInCode = underlyingType_NameInCode; UnderlyingType_Namespace = underlyingType_Namespace; UnderlyingType_AssemblyFullName = underlyingType_AssemblyFullName; UnderlyingType_AssemblyLocation = underlyingType_AssemblyLocation; MightBeRequiredByADynamicType = mightBeRequiredByADynamicType; EnumOutputType = enumOutputType; EnumeratedConstantNames = enumeratedConstantNames; EnumeratedConstantValues = enumeratedConstantValues; } public override string ToString() { string s = "FullyQualifiedName: " + FullyQualifiedName + Environment.NewLine + "NameInCode: " + NameInCode + Environment.NewLine + "Namespace: " + Namespace + Environment.NewLine + "AssemblyFullName: " + AssemblyFullName + Environment.NewLine + "AssemblyLocation: " + AssemblyLocation + Environment.NewLine + "HumanReadableName: " + HumanReadableName + Environment.NewLine + "Description: " + Description + Environment.NewLine + "UnderlyingType_FullyQualifiedName: " + UnderlyingType_FullyQualifiedName + Environment.NewLine + "UnderlyingType_NameInCode: " + UnderlyingType_NameInCode + Environment.NewLine + "UnderlyingType_Namespace: " + UnderlyingType_Namespace + Environment.NewLine + "UnderlyingType_AssemblyFullName: " + UnderlyingType_AssemblyFullName + Environment.NewLine + "UnderlyingType_AssemblyLocation: " + UnderlyingType_AssemblyLocation + Environment.NewLine + "MightBeRequiredByADynamicType: " + MightBeRequiredByADynamicType + Environment.NewLine + "EnumOutputType: " + EnumOutputType + Environment.NewLine + "HasSameUserFacingNameAsAnotherDynamicEnum: " + HasSameUserFacingNameAsAnotherDynamicEnum + Environment.NewLine; s += "Enumerated Constant Names:" + Environment.NewLine; foreach (string enumeratedConstantName in EnumeratedConstantNames) s += enumeratedConstantName.ToString() + Environment.NewLine; s += "Enumerated Constant Values:" + Environment.NewLine; foreach (string enumeratedConstantValue in EnumeratedConstantValues) s += enumeratedConstantValue.ToString() + Environment.NewLine; s += Environment.NewLine; return s; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicEnum; } public override string HTypeName { get { return "Dynamic Enum"; } } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, FullyQualifiedName); HDynamicTypeDbSer.WriteString(w, NameInCode); HDynamicTypeDbSer.WriteString(w, Namespace); HDynamicTypeDbSer.WriteString(w, AssemblyFullName); HDynamicTypeDbSer.WriteString(w, AssemblyLocation); HDynamicTypeDbSer.WriteString(w, HumanReadableName); HDynamicTypeDbSer.WriteString(w, Description); HDynamicTypeDbSer.WriteString(w, UnderlyingType_FullyQualifiedName); HDynamicTypeDbSer.WriteString(w, UnderlyingType_NameInCode); HDynamicTypeDbSer.WriteString(w, UnderlyingType_Namespace); HDynamicTypeDbSer.WriteString(w, UnderlyingType_AssemblyFullName); HDynamicTypeDbSer.WriteString(w, UnderlyingType_AssemblyLocation); HDynamicTypeDbSer.WriteBoolean(w, MightBeRequiredByADynamicType); HDynamicTypeDbSer.WriteInt32(w, (int)EnumOutputType); HDynamicTypeDbSer.WriteListOfStrings(w, EnumeratedConstantNames); HDynamicTypeDbSer.WriteListOfStrings(w, EnumeratedConstantValues); HDynamicTypeDbSer.WriteBoolean(w, HasSameUserFacingNameAsAnotherDynamicEnum); } } public partial class HDynamicTypeDb : HDynamicType { public static double DisplayOrder_Default = double.MaxValue; public static double CategoryDisplayOrder_Default = 100; public static string TradingHoursName_UseInstrumentSettings_ID = " - Quagensia ID"; public static string TradingHoursName_UseDataSeriesSettings_ID = " - Quagensia ID"; public string FilePath { get; set; } public int LangId { get; set; } public string CategoryName_Parameters { get; set; } public string CategoryName_DataSeries { get; set; } public string CategoryName_General { get; set; } public string CategoryName_Misc { get; set; } public string HumanReadableName_Input_InputParameter { get; set; } public string TradingHoursName_UseInstrumentSettings { get; set; } public string TradingHoursName_UseDataSeriesSettings { get; set; } private Dictionary _dynamicEnumsByFullyQualifiedName; public List _dynamicEnums; private HashSet _dynamicEnumUserFacingNames; private HashSet _dynamicEnumUserFacingNamesWithDuplicates; public List GetDynamicEnums(bool includeEnumsWithNoItems) { return includeEnumsWithNoItems ? _dynamicEnums : _dynamicEnums.Where(de => de.EnumeratedConstantNames.Count > 0).ToList(); } public bool AddDynamicEnum(HDynamicEnum dynamicEnum) { if (!_dynamicEnumsByFullyQualifiedName.ContainsKey(dynamicEnum.FullyQualifiedName)) { _dynamicEnums.Add(dynamicEnum); _dynamicEnumsByFullyQualifiedName.Add(dynamicEnum.FullyQualifiedName, dynamicEnum); if (_dynamicEnumUserFacingNames.Contains(dynamicEnum.NameInCode)) { if (!_dynamicEnumUserFacingNamesWithDuplicates.Contains(dynamicEnum.NameInCode)) _dynamicEnumUserFacingNamesWithDuplicates.Add(dynamicEnum.NameInCode); } else { _dynamicEnumUserFacingNames.Add(dynamicEnum.NameInCode); } return true; } else { return false; } } public bool DynamicEnumIsAlreadyDefined(string fullyQualifiedName) { return _dynamicEnumsByFullyQualifiedName.ContainsKey(fullyQualifiedName); } private Dictionary _dynamicIndicatorsByFullyQualifiedName; private List _dynamicIndicators; private HashSet _dynamicIndicatorUserFacingNames; private HashSet _dynamicIndicatorUserFacingNamesWithDuplicates; public List GetDynamicIndicators() { return _dynamicIndicators; } public bool AddDynamicIndicator(HDynamicIndicator dynamicIndicator) { if (!_dynamicIndicatorsByFullyQualifiedName.ContainsKey(dynamicIndicator.FullyQualifiedName)) { _dynamicIndicators.Add(dynamicIndicator); _dynamicIndicatorsByFullyQualifiedName.Add(dynamicIndicator.FullyQualifiedName, dynamicIndicator); if (_dynamicIndicatorUserFacingNames.Contains(dynamicIndicator.HumanReadableName)) { if (!_dynamicIndicatorUserFacingNamesWithDuplicates.Contains(dynamicIndicator.HumanReadableName)) _dynamicIndicatorUserFacingNamesWithDuplicates.Add(dynamicIndicator.HumanReadableName); } else { _dynamicIndicatorUserFacingNames.Add(dynamicIndicator.HumanReadableName); } return true; } else { return false; } } public int CompatibleWithSerializationVersion { get; set; } public Version CompatibleWithFourPartVersionNbr { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicTypeDb; } public override string HTypeName { get { return "Dynamic Type Database"; } } public HDynamicTypeDb(string filePath, int langId, string categoryName_Parameters, string categoryName_DataSeries, string categoryName_Misc, string categoryName_General, string humanReadableName_Input_InputParameter, string tradingHoursName_UseInstrumentSettings, string tradingHoursName_UseDataSeriesSettings) : base() { FilePath = filePath; LangId = langId; CategoryName_Parameters = categoryName_Parameters; CategoryName_DataSeries = categoryName_DataSeries; CategoryName_Misc = categoryName_Misc; CategoryName_General = categoryName_General; HumanReadableName_Input_InputParameter = humanReadableName_Input_InputParameter; TradingHoursName_UseInstrumentSettings = tradingHoursName_UseInstrumentSettings; TradingHoursName_UseDataSeriesSettings = tradingHoursName_UseDataSeriesSettings; _dynamicEnumsByFullyQualifiedName = new Dictionary(); _dynamicEnums = new List(); _dynamicEnumUserFacingNames = new HashSet(); _dynamicEnumUserFacingNamesWithDuplicates = new HashSet(); _dynamicIndicatorsByFullyQualifiedName = new Dictionary(); _dynamicIndicators = new List(); _dynamicIndicatorUserFacingNames = new HashSet(); _dynamicIndicatorUserFacingNamesWithDuplicates = new HashSet(); } public override string ToString() { string s = "FilePath: " + FilePath + Environment.NewLine + "LangId: " + LangId + Environment.NewLine + "CategoryName_Parameters: " + CategoryName_Parameters + Environment.NewLine + "CategoryName_DataSeries: " + CategoryName_DataSeries + Environment.NewLine + "CategoryName_Misc: " + CategoryName_Misc + Environment.NewLine + "CategoryName_General: " + CategoryName_General + Environment.NewLine + "HumanReadableName_Input_InputParameter: " + HumanReadableName_Input_InputParameter + Environment.NewLine + "TradingHoursName_UseInstrumentSettings: " + TradingHoursName_UseInstrumentSettings + Environment.NewLine + "TradingHoursName_UseDataSeriesSettings: " + TradingHoursName_UseDataSeriesSettings + Environment.NewLine + Environment.NewLine; s += "Dynamic Indicators:" + Environment.NewLine; foreach (HDynamicIndicator dynamicIndicator in _dynamicIndicators) s += dynamicIndicator.ToString() + Environment.NewLine; s += Environment.NewLine; s += "Dynamic Enumerated Constants:" + Environment.NewLine; foreach (HDynamicEnum dynamicEnum in _dynamicEnums) s += dynamicEnum.ToString() + Environment.NewLine; s += Environment.NewLine; return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteInt32(w, LangId); HDynamicTypeDbSer.WriteString(w, CategoryName_Parameters); HDynamicTypeDbSer.WriteString(w, CategoryName_DataSeries); HDynamicTypeDbSer.WriteString(w, CategoryName_Misc); HDynamicTypeDbSer.WriteString(w, CategoryName_General); HDynamicTypeDbSer.WriteString(w, HumanReadableName_Input_InputParameter); HDynamicTypeDbSer.WriteString(w, TradingHoursName_UseInstrumentSettings); HDynamicTypeDbSer.WriteString(w, TradingHoursName_UseDataSeriesSettings); HDynamicTypeDbSer.WriteListOfHDynamicTypes(w, _dynamicEnums); HDynamicTypeDbSer.WriteListOfHDynamicTypes(w, _dynamicIndicators); } #region SerializeHDynamicTypeDb(HDynamicTypeDb dynamicTypeDb) and Serialize() public static byte[] SerializeHDynamicTypeDbToByteArray(HDynamicTypeDb dynamicTypeDb) { foreach (string dynamicEnumUserFacingNameWithDuplicates in dynamicTypeDb._dynamicEnumUserFacingNamesWithDuplicates) { for (int i = 0; i < dynamicTypeDb._dynamicEnums.Count; i++) { if (dynamicTypeDb._dynamicEnums[i].HumanReadableName == dynamicEnumUserFacingNameWithDuplicates) dynamicTypeDb._dynamicEnums[i].HasSameUserFacingNameAsAnotherDynamicEnum = true; } } foreach (string dynamicIndicatorUserFacingNameWithDuplicates in dynamicTypeDb._dynamicIndicatorUserFacingNamesWithDuplicates) { for (int i = 0; i < dynamicTypeDb._dynamicIndicators.Count; i++) { if (dynamicTypeDb._dynamicIndicators[i].HumanReadableName == dynamicIndicatorUserFacingNameWithDuplicates) dynamicTypeDb._dynamicIndicators[i].HasSameUserFacingNameAsAnotherDynamicIndicator = true; } } using (MemoryStream memoryStream = new MemoryStream()) { using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { HDynamicTypeDbSer.StartHDynamicTypeDbSerialization(binaryWriter); HDynamicTypeDbSer.WriteHDynamicType(binaryWriter, dynamicTypeDb); return memoryStream.ToArray(); } } } public static string Trans_CouldntSaveHDynamicTypeDbFileToDisk(string reason) { string s = "Couldn't save " + Trans_DynamicIndicatorsAndTypesHumanReadableFileName + " to disk."; if (!string.IsNullOrEmpty(reason)) s += Environment.NewLine + Environment.NewLine + reason; return s; } public static string Trans_DynamicIndicatorsAndTypesHumanReadableFileName_Shortened { get { return "Imported Indicators and Types"; } } public static string Trans_DynamicIndicatorsAndTypesHumanReadableFileName { get { return "\"" + Trans_DynamicIndicatorsAndTypesHumanReadableFileName_Shortened + "\" file"; } } public static string Trans_DynamicIndicatorsAndTypesLoaderStrategy { get { return "▶ Import Your Third-Party Indicators Into Quagensia By Applying This Strategy to a Chart!"; } } public static string DynamicIndicatorsAndTypesFileName { get { return GetDynamicIndicatorsAndTypesFileName("n"); } } public static string GetDynamicIndicatorsAndTypesFileName(string edition_Abbreviation_SpokenLangNeutral_ToLower_CultureInvariant) { return "ImportedIndicatorsAndTypes.qdt" + edition_Abbreviation_SpokenLangNeutral_ToLower_CultureInvariant + "x"; } public static string DynamicIndicatorsAndTypesHardcodedEndingFolderPath { get { return "Quagensia\\Quagensia_N\\My_Algos"; } } public static string DynamicIndicatorsAndTypesHardcodedEndingFilePath { get { return DynamicIndicatorsAndTypesHardcodedEndingFolderPath + "\\" + DynamicIndicatorsAndTypesFileName; } } #endregion } public partial class HDynamicDouble : HDynamicType { public double Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicDouble; } public override string HTypeName { get { return "Dynamic Double"; } } public HDynamicDouble(double value) : base("System.Double") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteDouble(w, Value); } } public partial class HDynamicSingle : HDynamicType { public float Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicSingle; } public override string HTypeName { get { return "Dynamic Single"; } } public HDynamicSingle(float value) : base("System.Single") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteSingle(w, Value); } } public partial class HDynamicInt32 : HDynamicType { public int Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicInt32; } public override string HTypeName { get { return "Dynamic Int32"; } } public HDynamicInt32(int value) : base("System.Int32") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteInt32(w, Value); } } public partial class HDynamicUInt32 : HDynamicType { public uint Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicUInt32; } public override string HTypeName { get { return "Dynamic UInt32"; } } public HDynamicUInt32(uint value) : base("System.UInt32") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteUInt32(w, Value); } } public partial class HDynamicInt64 : HDynamicType { public long Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicInt64; } public override string HTypeName { get { return "Dynamic Int64"; } } public HDynamicInt64(long value) : base("System.Int64") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteInt64(w, Value); } } public partial class HDynamicUInt64 : HDynamicType { public ulong Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicUInt64; } public override string HTypeName { get { return "Dynamic UInt64"; } } public HDynamicUInt64(ulong value) : base("System.UInt64") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteUInt64(w, Value); } } public partial class HDynamicInt16 : HDynamicType { public short Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicInt16; } public override string HTypeName { get { return "Dynamic Int16"; } } public HDynamicInt16(short value) : base("System.Int16") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteInt16(w, Value); } } public partial class HDynamicUInt16 : HDynamicType { public ushort Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicUInt16; } public override string HTypeName { get { return "Dynamic UInt16"; } } public HDynamicUInt16(ushort value) : base("System.UInt16") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteUInt16(w, Value); } } public partial class HDynamicByte : HDynamicType { public byte Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicByte; } public override string HTypeName { get { return "Dynamic Byte"; } } public HDynamicByte(byte value) : base("System.Byte") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteByte(w, Value); } } public partial class HDynamicSByte : HDynamicType { public sbyte Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicSByte; } public override string HTypeName { get { return "Dynamic SByte"; } } public HDynamicSByte(sbyte value) : base("System.SByte") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteSByte(w, Value); } } public partial class HDynamicString : HDynamicType { public string Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicString; } public override string HTypeName { get { return "Dynamic String"; } } public HDynamicString(string value) : base("System.String") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value + Environment.NewLine; return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, Value); } } public partial class HDynamicBoolean : HDynamicType { public bool Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicBoolean; } public override string HTypeName { get { return "Dynamic Boolean"; } } public HDynamicBoolean(bool value) : base("System.Boolean") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteBoolean(w, Value); } } public enum HDynamicDateTimeTypes : int { DateAndTime_Complete = 1, DateAndTime_TimeOfDay = 2, DateAndTime_DateWithoutTime = 3 } public partial class HDynamicDateTime : HDynamicType { public HDynamicDateTimeTypes DynamicDateTimeType = HDynamicDateTimeTypes.DateAndTime_Complete; public DateTime Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicDateTime; } public override string HTypeName { get { return "Dynamic DateTime"; } } public HDynamicDateTime(HDynamicDateTimeTypes dynamicDateTimeType, DateTime value) : base("System.DateTime") { DynamicDateTimeType = dynamicDateTimeType; Value = value; } public override string ToString() { string s = base.ToString() + ", DynamicDateTimeType: " + DynamicDateTimeType.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteInt32(w, (int)DynamicDateTimeType); HDynamicTypeDbSer.WriteDateTime(w, Value); } } public partial class HDynamicColor : HDynamicType { public HColorARGB Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicColor; } public override string HTypeName { get { return "Dynamic Color"; } } public HDynamicColor(HColorARGB value) : base("Quagensia.HDynamicColor") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteColorARGB(w, Value.A, Value.R, Value.G, Value.B); } } public partial class HDynamicWindowsMediaBrush_SolidColorBrush : HDynamicType { public HColorARGB Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicWindowsMediaBrush_SolidColorBrush; } public override string HTypeName { get { return "Dynamic Windows Media Brush (Solid Color Brush)"; } } public HDynamicWindowsMediaBrush_SolidColorBrush(HColorARGB value) : base("System.Windows.Media.SolidColorBrush") { Value = value; } public override string ToString() { string s = base.ToString() + ", Value: " + Value.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteColorARGB(w, Value.A, Value.R, Value.G, Value.B); } } public class HColorARGB { #region Declarations and Initialization public byte A; public byte R; public byte G; public byte B; public HColorARGB(byte alpha, byte red, byte green, byte blue) { A = alpha; R = red; G = green; B = blue; } public override string ToString() { return "A=" + A.ToString() + ", R=" + R.ToString() + ", G=" + G.ToString() + ", B=" + B.ToString(); } #endregion } public partial class HDynamicNGuiStroke_SolidColorBrush : HDynamicType { public HColorARGB ColorARGB { get; set; } public string DashStyleHelperValue { get; set; } public float Width { get; set; } public int Opacity { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicNGuiStroke_SolidColorBrush; } public override string HTypeName { get { return "Dynamic N Gui Stroke"; } } public HDynamicNGuiStroke_SolidColorBrush(HColorARGB colorARGB, string dashStyleHelperValue, float width, int opacity) : base("NinjaTrader.Gui.Stroke") { ColorARGB = colorARGB; DashStyleHelperValue = dashStyleHelperValue; Width = width; Opacity = opacity; } public override string ToString() { string s = base.ToString() + ", ColorARGB: " + ColorARGB.ToString() + ", DashStyleHelperValue: " + DashStyleHelperValue + ", Width: " + Width.ToString() + ", Opacity: " + Opacity.ToString(); return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteColorARGB(w, ColorARGB.A, ColorARGB.R, ColorARGB.G, ColorARGB.B); HDynamicTypeDbSer.WriteString(w, DashStyleHelperValue); HDynamicTypeDbSer.WriteSingle(w, Width); HDynamicTypeDbSer.WriteInt32(w, Opacity); } } public partial class HDynamicNGuiSimpleFont : HDynamicType { public string FontFamilyName { get; set; } public double FontSize { get; set; } public bool IsBold { get; set; } public bool IsItalic { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicNGuiSimpleFont; } public override string HTypeName { get { return "Dynamic N Gui SimpleFont"; } } public HDynamicNGuiSimpleFont(string fontFamilyName, double fontSize, bool isBold, bool isItalic) : base("NinjaTrader.Gui.Tools.SimpleFont") { FontFamilyName = fontFamilyName; FontSize = fontSize; IsBold = isBold; IsItalic = isItalic; } public override string ToString() { string s = base.ToString() + ", FontFamilyName: " + FontFamilyName + ", FontSize: " + FontSize + ", IsBold: " + IsBold + ", IsItalic: " + IsItalic; return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, FontFamilyName); HDynamicTypeDbSer.WriteDouble(w, FontSize); HDynamicTypeDbSer.WriteBoolean(w, IsBold); HDynamicTypeDbSer.WriteBoolean(w, IsItalic); } } public partial class HDynamicEnumValue : HDynamicType { public string EnumTypeFullName { get; set; } public string Value { get; set; } public override HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicEnumValue; } public override string HTypeName { get { return "Dynamic Enum Value"; } } public HDynamicEnumValue(string enumTypeFullName, string value) : base("Quagensia.HDynamicEnumValue") { EnumTypeFullName = enumTypeFullName; Value = value; } public override string ToString() { string s = base.ToString() + ", EnumTypeFullName: " + EnumTypeFullName + ", Value: " + Value + Environment.NewLine; return s; } public override void Serialize(BinaryWriter w) { base.Serialize(w); HDynamicTypeDbSer.WriteString(w, EnumTypeFullName); HDynamicTypeDbSer.WriteString(w, Value); } } public partial class HDynamicType { public string DynamicTypeId { get; set; } public virtual string HTypeName { get { return "Dynamic Type"; } } public virtual HDynamicTypes GetHDynamicType() { return HDynamicTypes.HDynamicType; } public HDynamicType() { DynamicTypeId = string.Empty; } public HDynamicType(string dynamicTypeId) { DynamicTypeId = dynamicTypeId; } public override string ToString() { string s = "HTypeName: " + HTypeName + ", DynamicTypeId: " + DynamicTypeId; return s; } public virtual void Serialize(BinaryWriter w) { HDynamicTypeDbSer.WriteInt32(w, (int)GetHDynamicType()); } } public enum HDynamicTypes { HDynamicType = 1, HDynamicTypeDb = 2, HDynamicEnum = 3, HDynamicIndicator = 4, HDynamicIndicator_InputParameter = 5, HDynamicIndicator_InternalVariable = 6, HDynamicDouble = 7, HDynamicSingle = 8, HDynamicInt32 = 9, HDynamicUInt32 = 10, HDynamicInt64 = 11, HDynamicUInt64 = 12, HDynamicInt16 = 13, HDynamicUInt16 = 14, HDynamicByte = 15, HDynamicSByte = 16, HDynamicString = 17, HDynamicBoolean = 18, HDynamicDateTime = 19, HDynamicColor = 20, HDynamicEnumValue = 21, HDynamicWindowsMediaBrush_SolidColorBrush = 22, HDynamicNGuiStroke_SolidColorBrush = 23, HDynamicNGuiSimpleFont = 24 } public static partial class HDynamicTypeDbSer { public static int SerializationVersion_Current = 3; public static Version SerializationFourPartVersionNbr_Current = new Version(SerializationVersion_Current, 0, 0, 0); #region Serialization Controller Code public static long QuagensiaDynamicTypeDbFileStartValue = 5218519701657381021; public static void StartHDynamicTypeDbSerialization(BinaryWriter binaryWriter) { WriteInt32(binaryWriter, SerializationVersion_Current); WriteString(binaryWriter, SerializationFourPartVersionNbr_Current_Unformatted); WriteInt64(binaryWriter, QuagensiaDynamicTypeDbFileStartValue); } #endregion #region Write To Binary File public static void WriteDouble(BinaryWriter binaryWriter, double value) { binaryWriter.Write(value); } public static void WriteSingle(BinaryWriter binaryWriter, float value) { binaryWriter.Write(value); } public static void WriteInt32(BinaryWriter binaryWriter, int value) { binaryWriter.Write(value); } public static void WriteUInt32(BinaryWriter binaryWriter, uint value) { binaryWriter.Write(value); } public static void WriteInt64(BinaryWriter binaryWriter, long value) { binaryWriter.Write(value); } public static void WriteUInt64(BinaryWriter binaryWriter, ulong value) { binaryWriter.Write(value); } public static void WriteInt16(BinaryWriter binaryWriter, short value) { binaryWriter.Write(value); } public static void WriteUInt16(BinaryWriter binaryWriter, ushort value) { binaryWriter.Write(value); } public static void WriteByte(BinaryWriter binaryWriter, byte value) { binaryWriter.Write(value); } public static void WriteSByte(BinaryWriter binaryWriter, sbyte value) { binaryWriter.Write(value); } public static void WriteBoolean(BinaryWriter binaryWriter, bool value) { WriteInt32(binaryWriter, ConvertBooleanToInteger(value)); } public static void WriteString(BinaryWriter binaryWriter, string value) { if (String.IsNullOrEmpty(value)) { WriteBoolean(binaryWriter, false); } else { byte[] bytes = UnicodeEncoding.UTF8.GetBytes(value); binaryWriter.Write(bytes.Length); binaryWriter.Write(bytes); } } public static void WriteDateTime(BinaryWriter binaryWriter, DateTime value) { WriteInt64(binaryWriter, value.Ticks); } public static void WriteColorARGB(BinaryWriter binaryWriter, byte a, byte r, byte g, byte b) { WriteByte(binaryWriter, a); WriteByte(binaryWriter, r); WriteByte(binaryWriter, g); WriteByte(binaryWriter, b); } public static void WriteListOfStrings(BinaryWriter binaryWriter, List collection) { binaryWriter.Write(collection.Count); foreach (string item in collection) WriteString(binaryWriter, item); } public static void WriteHDynamicType(BinaryWriter binaryWriter, HDynamicType dynamicTypeValToWrite) { if (dynamicTypeValToWrite == null) { WriteInt32(binaryWriter, 0); return; } dynamicTypeValToWrite.Serialize(binaryWriter); } public static void WriteListOfHDynamicTypes(BinaryWriter binaryWriter, List collection) where T : HDynamicType { WriteInt32(binaryWriter, collection.Count); foreach (HDynamicType dynamicType in collection) WriteHDynamicType(binaryWriter, dynamicType); } #endregion #region Version Number public static string VersionNumberString(string versionNumber) { return "v. " + versionNumber; } private static string _serializationFourPartVersionNbr_Unformatted = null; public static string SerializationFourPartVersionNbr_Current_Unformatted { get { if (_serializationFourPartVersionNbr_Unformatted == null) { _serializationFourPartVersionNbr_Unformatted = Int32ToString_Unformatted_ValueStore(SerializationFourPartVersionNbr_Current.Major) + "." + Int32ToString_Unformatted_ValueStore(SerializationFourPartVersionNbr_Current.Minor) + "." + Int32ToString_Unformatted_ValueStore(SerializationFourPartVersionNbr_Current.Build) + "." + Int32ToString_Unformatted_ValueStore(SerializationFourPartVersionNbr_Current.Revision); } return _serializationFourPartVersionNbr_Unformatted; } } public static Version GetVersion_From_VersionNumberStringUnformatted(string versionNumberString_Unformatted) { return new Version(versionNumberString_Unformatted); } public static string Int32ToString_Unformatted_ValueStore(int intValue) { return intValue.ToString(CultureInfo.InvariantCulture); } #endregion public static bool ParentDirectoryExists(string fullPath) { DirectoryInfo directoryInfo = Directory_GetParent(fullPath); return directoryInfo != null && directoryInfo.Exists; } public static DirectoryInfo Directory_GetParent(string path) { try { return Directory.GetParent(path); } catch { return null; } } public static string GetErrorMessageString(Exception exception, string customMessage, string customDescription) { string s = customMessage != null ? ("ERROR: " + customMessage + Environment.NewLine) : string.Empty; if (exception != null) { if (s != string.Empty) s += Environment.NewLine; s += GetExceptionMessage(exception); } if (!string.IsNullOrEmpty(customDescription)) { if (s != string.Empty) s += Environment.NewLine; s += customDescription; } return s; } private static string GetExceptionMessage(Exception exception) { string s = "*** ERROR DETAILS***" + Environment.NewLine + "Exception Message: " + (exception.Message ?? string.Empty) + Environment.NewLine + "Source: " + (exception.Source ?? string.Empty) + Environment.NewLine + "Exception Data: " + (exception.Data != null ? ToDebugString(exception.Data) : string.Empty) + Environment.NewLine + "Stack Trace: " + Environment.NewLine + (exception.StackTrace != null ? exception.StackTrace : string.Empty) + Environment.NewLine; if (exception.InnerException != null) s += "Inner Exception: " + Environment.NewLine + GetExceptionMessage(exception.InnerException); return s; } public static string ToDebugString(object value) { return value != null ? value.ToString() : "null"; } public static int ConvertBooleanToInteger(bool value) { return value ? 1 : 0; } private static HashSet _integralNumberTypesConvertibleToInt64 = new HashSet() { "System.Byte", "System.SByte", "System.Int16", "System.UInt16", "System.Int32", "System.UInt32", "System.Int64" }; public static string ConvertIntegralNumberObjectToIntegralNumberValueString_ThrowsExceptionIfNull(object integralNumberObject, string fullNameOfDataType) { if (_integralNumberTypesConvertibleToInt64.Contains(fullNameOfDataType)) return Convert.ToInt64(integralNumberObject).ToString(CultureInfo.InvariantCulture); else if (fullNameOfDataType == "System.UInt64") return Convert.ToUInt64(integralNumberObject).ToString(CultureInfo.InvariantCulture); else throw new Exception("The function \"ConvertIntegralNumberObjectToIntegralNumberValueString\" only supports the following integral types: System.Byte, System.SByte, System.Int16, System.UInt16, System.Int32, System.UInt32, System.Int64, and System.UInt64, but its \"fullNameOfDataType\" parameter was passed a value of \"" + fullNameOfDataType + "\"."); } } #endregion // The purpose of the code below is to precede the ending "}" that is // generated by the Quagensia N Edition code generator for the // OnBarUpdate() function from which this function is called so that when // the Quagensia N Edition code generator generates the ending "}" for // the "When Bar Updates" section in which this function is the // bottom-most trading logic component, a compilation error will not // occur due to the ending "}" not having a starting "{" to pair up with // and close off. void QF_EmptyFunction_62B0FC0CBBB24719B3A6FAFEB4D06A93() { } #region Properties [NinjaScriptProperty] [Display(Name="Write \"Imported Indicators and Types\" File to Default Location (\\Quagensia\\Quagensia_N\\My_Algos) (Almost All Users Should Check This Check Box)", Description="", Order=1, GroupName="Parameters")] public bool QX_WriteImportedIndicatorsandTypesFiletoDefaultLocationMyDocumentsQuagensiaQuagensia_NMy_AlgosA { get; set; } [NinjaScriptProperty] [Display(Name="Custom Folder Path To Which The \"Imported Indicators and Types\" File Should Be Written (If Check Box Above is Unchecked)", Description="If you are one if the small minority of Quagensia N Edition users who\r\nhas changed the location where your Quagensia N Edition files are\r\nstored from the default location of \"\\Quagensia\\Quagensia_N\" to another folder path, like\r\n\"D:\\Files\\Quagensia\\Quagensia_N\", by changing the \"Quagensia User\r\nFolder's Parent Folder\" setting in the Options window, then set the\r\nBoolean (True or False) input parameter above this one to \"False\" by\r\nunchecking its check box in the NinjaTrader® user interface, then set\r\nthis Text input parameter to the folder path of your Quagensia N\r\nEdition \"My Algos\" folder.\r\n\r\nHere is an example of a properly formatted folder path that shows the\r\nlocation of the default \"My Algos\" folder on a machine for Windows\r\nuser \"brook.hunter\":\r\n\r\nC:\\Users\\brook.hunter\\Documents\\Quagensia\\Quagensia_N\\My_Algos", Order=2, GroupName="Parameters")] public string QX_CustomFolderPathToWhichTheImportedIndicatorsandTypesFileShouldBeWrittenIfCheckBoxAboveisUnch { get; set; } [Display(Name="Show Custom Drawn Objects", Description="When this property is set to true, custom drawn objects like dots,\r\nlines, rectangles, triangles, etc., and all custom changes to other\r\nvisuals, such as the chart background color, will be visible on the\r\nchart. If you want large optimizations of your strategy to run faster\r\nand don't need to see the custom drawn objects and custom painting,\r\nset this property to false. The value of this property only affects\r\nobjects that are drawn using the custom drawing functions built into\r\nQuagensia. Plots of indicators, editable time series, and horizontal\r\nlines that are configured by checking the \"Plot This\" check boxes in\r\nthe \"Internal Variables\" and \"Input Parameters\" sections of a\r\nQuagensia Strategy are not affected by the value of this property.", Order=3, GroupName ="Parameters")] public bool QS_DoCustomDrawingAndPainting_UserPreference { get; set; } [Display(Name="Print to NinjaScript® Output Window ", Description="If this strategy normally prints to the NinjaScript® Output window\r\nusing the \"Print to Output Window\" functions built into Quagensia, you\r\ncan set this parameter to \"false\" instead of \"true\" to cause your\r\nstrategy to not print to the NinjaScript® Output window. Setting this\r\ninput parameter to \"false\" can improve the performance of your\r\nstrategy in scenarios where it would otherwise print to the\r\nNinjaScript® Output window thousands of times, including reducing the\r\ntime it takes to finish an optimization of your strategy over a large\r\nnumber of parameter sets. Examples of situations where you should\r\nconsider setting this input parameter to \"false\" to stop all printing\r\nto the NinjaScript® Output window include situations such as if your\r\nstrategy normally prints to the NinjaScript® Output window on every\r\nbar or tick or on a high percentage of bars or ticks and you are\r\nrunning it on a chart with many thousands of bars or ticks, or if you\r\nare optimizing this strategy over a large number of parameter sets.", Order=4, GroupName ="Parameters")] public bool QS_DoPrintToOutputWindow_UserPreference { get; set; } #endregion #region Quagensia System Functions. Do Not Change Or Delete. /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quagensia N Edition's system functions are below. Do not change anything below this line. // The following copyright notice applies to all code and other content below this line: // Copyright © 2023-2024 Quagensia, Inc. All rights reserved. /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void QS_DrawHorizontalLine(NinjaScriptBase owner, bool isAutoScale, double y, Color color, DashStyleHelper dashStyle, int width) { if (QS_DrawCustomObjects()) { string newGuidString = QS_NewGuidString(); string uniqueTagName = "QS_HorizontalLine_" + newGuidString + "_" + QS_Int32ToString_Unformatted_ValueStore(CurrentBar) + "_" + QS_DoubleToString_ComputerReadable(y, 17); QS_DrawOrModifyHorizontalLine(owner, uniqueTagName, isAutoScale, y, color, dashStyle, width); } } private void QS_DrawOrModifyHorizontalLine(NinjaScriptBase owner, string tag, bool isAutoScale, double y, Color color, DashStyleHelper dashStyle, int width) { if (QS_DrawCustomObjects()) Draw.HorizontalLine(owner, tag, isAutoScale, y, QS_GetBrush_SolidColor(color), dashStyle, width); } private void QS_DrawText(NinjaScriptBase owner, int barsAgo, double y, string text) { if (QS_DrawCustomObjects()) { string newGuidString = QS_NewGuidString(); string uniqueTagName = "QS_Text_" + newGuidString + "_" + QS_Int32ToString_Unformatted_ValueStore(CurrentBar) + "_" + QS_Int32ToString_Unformatted_ValueStore(barsAgo) + "_" + QS_DoubleToString_ComputerReadable(y, 17); QS_DrawOrModifyText(owner, uniqueTagName, barsAgo, y, text); } } private void QS_DrawOrModifyText(NinjaScriptBase owner, string tag, int barsAgo, double y, string text) { if (QS_DrawCustomObjects()) Draw.Text(owner, tag, text, barsAgo, y); } private void QS_DrawText(NinjaScriptBase owner, int barsAgo, double y, string text, Color colorText) { if (QS_DrawCustomObjects()) { string newGuidString = QS_NewGuidString(); string uniqueTagName = "QS_Text_" + newGuidString + "_" + QS_Int32ToString_Unformatted_ValueStore(CurrentBar) + "_" + QS_Int32ToString_Unformatted_ValueStore(barsAgo) + "_" + QS_DoubleToString_ComputerReadable(y, 17); QS_DrawOrModifyText(owner, uniqueTagName, barsAgo, y, text, colorText); } } private void QS_DrawOrModifyText(NinjaScriptBase owner, string tag, int barsAgo, double y, string text, Color colorText) { if (QS_DrawCustomObjects()) Draw.Text(owner, tag, text, barsAgo, y, QS_GetBrush_SolidColor(colorText)); } private void QS_DrawTextFixed(NinjaScriptBase owner, string text, TextPosition textPosition) { if (QS_DrawCustomObjects()) { string newGuidString = QS_NewGuidString(); string uniqueTagName = "QS_TextFixed_" + newGuidString + "_" + QS_Int32ToString_Unformatted_ValueStore(CurrentBar); QS_DrawOrModifyTextFixed(owner, uniqueTagName, text, textPosition); } } private void QS_DrawOrModifyTextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition) { if (QS_DrawCustomObjects()) Draw.TextFixed(owner, tag, text, textPosition); } private void QS_DrawTextFixed(NinjaScriptBase owner, string text, TextPosition textPosition, Color colorText) { if (QS_DrawCustomObjects()) { string newGuidString = QS_NewGuidString(); string uniqueTagName = "QS_TextFixed_" + newGuidString + "_" + QS_Int32ToString_Unformatted_ValueStore(CurrentBar); QS_DrawOrModifyTextFixed(owner, uniqueTagName, text, textPosition, colorText); } } private void QS_DrawOrModifyTextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, Color colorText) { if (QS_DrawCustomObjects()) Draw.TextFixed(owner, tag, text, textPosition, QS_GetBrush_SolidColor(colorText), null, null, null, 0); } private bool QS_DrawCustomObjects() { return QS_DoCustomDrawingAndPainting_UserPreference; } private void QS_Print(string messageToPrint) { if (QS_PrintToOutputWindow()) Print(messageToPrint); } private bool QS_PrintToOutputWindow() { return QS_DoPrintToOutputWindow_UserPreference; } private void QS_OnTerminated() { lock (QS_LockObject_Drawing) { if (QS_Brushes_SolidColor_Custom != null) { List keys = new List(QS_Brushes_SolidColor_Custom.Keys); foreach (Color key in keys) QS_Brushes_SolidColor_Custom[key] = null; QS_Brushes_SolidColor_Custom = null; } } } private static object QS_LockObject_Drawing = new object(); private SolidColorBrush QS_GetBrush_SolidColor(Color color) { SolidColorBrush b = QS_GetBrush_SolidColor_System(color); if (b != null) return b; else return QS_GetBrush_SolidColor_Custom(color); } private Dictionary QS_Brushes_SolidColor_Custom = null; private SolidColorBrush QS_GetBrush_SolidColor_Custom(Color color) { SolidColorBrush b = null; lock (QS_LockObject_Drawing) { if (QS_Brushes_SolidColor_Custom == null) QS_Brushes_SolidColor_Custom = new Dictionary(); if (!QS_Brushes_SolidColor_Custom.TryGetValue(color, out b)) { b = new SolidColorBrush(color); b.Freeze(); QS_Brushes_SolidColor_Custom.Add(color, b); } } return b; } private Dictionary QS_Brushes_SolidColor_System = null; private SolidColorBrush QS_GetBrush_SolidColor_System(Color color) { SolidColorBrush b = null; lock (QS_LockObject_Drawing) { if (QS_Brushes_SolidColor_System == null) QS_Populate_Brushes_SolidColor_System(); QS_Brushes_SolidColor_System.TryGetValue(color, out b); } return b; } private void QS_Populate_Brushes_SolidColor_System() { lock (QS_LockObject_Drawing) { QS_Brushes_SolidColor_System = new Dictionary(); PropertyInfo[] brushPropertyInfos = typeof(Brushes).GetProperties(BindingFlags.Static | BindingFlags.Public); foreach (PropertyInfo brushPropertyInfo in brushPropertyInfos) { SolidColorBrush b = brushPropertyInfo.GetValue(null) as SolidColorBrush; if (b != null && !QS_Brushes_SolidColor_System.ContainsKey(b.Color)) QS_Brushes_SolidColor_System.Add(b.Color, b); } } } private static string QS_Int32ToString_Unformatted_ValueStore(int intValue) { return intValue.ToString(CultureInfo.InvariantCulture); } private static string QS_Int64ToString_Unformatted_ValueStore(long longValue) { return longValue.ToString(CultureInfo.InvariantCulture); } private static string QS_DoubleToString_ComputerReadable_Not_Rounded_FormatInfoString = "0." + new string('#', 339); private static string QS_DoubleToString_ComputerReadable(double doubleValue) { return doubleValue.ToString(QS_DoubleToString_ComputerReadable_Not_Rounded_FormatInfoString, System.Globalization.CultureInfo.InvariantCulture); } private static string QS_DoubleToString_ComputerReadable(double doubleValue, int roundingDecimalPlaces) { return doubleValue.ToString("0." + new string('#', roundingDecimalPlaces), System.Globalization.CultureInfo.InvariantCulture); } private static string QS_NewGuidString() { Guid guid = Guid.NewGuid(); return QS_GetHGuidString(guid); } private static string QS_GetHGuidString(Guid guid) { return guid.ToString("N", CultureInfo.InvariantCulture); } #endregion } }