From c5d06eb06fba0418781260160c4aef6650eb2b94 Mon Sep 17 00:00:00 2001 From: Miha Date: Wed, 20 Apr 2022 00:21:03 -0700 Subject: [PATCH] coverage fix --- .github/workflows/main_automation.yml | 68 +- QuanTAlib.sln | 3 + .../dll/TradingPlatform.BusinessLayer.xml | 9003 ----------------- Source/Basics/TSeries.cs | 22 +- Source/Indicators/JMA_Series.cs | 17 +- 5 files changed, 63 insertions(+), 9050 deletions(-) delete mode 100644 Quantower/dll/TradingPlatform.BusinessLayer.xml diff --git a/.github/workflows/main_automation.yml b/.github/workflows/main_automation.yml index 52013222..5546f943 100644 --- a/.github/workflows/main_automation.yml +++ b/.github/workflows/main_automation.yml @@ -41,7 +41,11 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="Tests/coverage.xml" + #run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="./coverage.xml" + run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" + /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + /d:sonar.host.url="https://sonarcloud.io" + /d:sonar.cs.dotcover.reportsPaths=./coveragereport.html - name: Build Core DLL run: dotnet build ./Source/QuanTAlib.csproj --verbosity normal --configuration Release --nologo @@ -50,10 +54,12 @@ jobs: - name: dotnet Test run: dotnet test ./Tests/Tests.csproj --verbosity normal --configuration Release --nologo - - name: DotCover Test - run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=Tests/coveragereport.xml - - name: dotnet-coverage - run: dotnet-coverage collect 'dotnet test' -f xml -o 'Tests/coverage.xml' + - name: DotCover Test XML + run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=./coveragereport.xml + - name: DotCover Test HTML + run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=HTML --dcoutput=./coveragereport.html +# - name: dotnet-coverage +# run: dotnet-coverage collect 'dotnet test' -f xml -o './coverage.xml' - name: Sonar reporter env: @@ -62,38 +68,38 @@ jobs: run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" - name: CodeCov run - run: codecov -f ./Tests/coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }} + run: codecov -f ./coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }} - name: Codacy coverage reporter uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: ./Tests/coveragereport.xml + coverage-reports: ./coveragereport.xml - - name: Zip DLLs - uses: thedoctor0/zip-release@master - with: - type: 'zip' - directory: \Quantower\Settings\Scripts\Indicators\QuanTAlib - filename: QL_Quantower.zip +# - name: Zip DLLs +# uses: thedoctor0/zip-release@master +# with: +# type: 'zip' +# directory: \Quantower\Settings\Scripts\Indicators\QuanTAlib +# filename: QL_Quantower.zip - - name: Release - uses: marvinpinto/action-automatic-releases@latest - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" - prerelease: true - title: "Pre-release Build" - files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.zip +# - name: Release +# uses: marvinpinto/action-automatic-releases@latest +# with: +# repo_token: "${{ secrets.GITHUB_TOKEN }}" +# automatic_release_tag: "latest" +# prerelease: true +# title: "Pre-release Build" +# files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.zip - - name: Push package to nuget.org - run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg' - --api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }} - --source https://api.nuget.org/v3/index.json - --skip-duplicate +# - name: Push package to nuget.org +# run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg' +# --api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }} +# --source https://api.nuget.org/v3/index.json +# --skip-duplicate - - name: Push package to github - run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg' - --api-key ${{ secrets.GITHUB_TOKEN }} - --source https://nuget.pkg.github.com/mihakralj/index.json - --skip-duplicate +# - name: Push package to github +# run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg' +# --api-key ${{ secrets.GITHUB_TOKEN }} +# --source https://nuget.pkg.github.com/mihakralj/index.json +# --skip-duplicate diff --git a/QuanTAlib.sln b/QuanTAlib.sln index 9704e0a0..cc6b9863 100644 --- a/QuanTAlib.sln +++ b/QuanTAlib.sln @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 17.2.32210.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{283EACC9-3AF6-4DAE-9C1C-0F7F8C8CD70D}" + ProjectSection(ProjectDependencies) = postProject + {5096AEA1-81BC-46E7-9F2B-B408AFAA850C} = {5096AEA1-81BC-46E7-9F2B-B408AFAA850C} + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuanTAlib", "Source\QuanTAlib.csproj", "{AAE21F8A-9BC2-4647-A9EB-4DC86C569080}" EndProject diff --git a/Quantower/dll/TradingPlatform.BusinessLayer.xml b/Quantower/dll/TradingPlatform.BusinessLayer.xml deleted file mode 100644 index d26ac619..00000000 --- a/Quantower/dll/TradingPlatform.BusinessLayer.xml +++ /dev/null @@ -1,9003 +0,0 @@ - - - - TradingPlatform.BusinessLayer - - - - - Access to the chart panel - - - - - Chart panel unique ID - - - - - Collection of chart windows - - - - - Current X scale value - width of the bar in pixels - - - - - Provides time zone of current chart. - - - - - Provides custom sessions of current chart. - - - - - Current tick size of the chart - - - - - Main window of the chart - - - - - Current right offset value - - - - - Collection of chart drawings - - - - - Force chart refreshing - - - - - The MouseDown event occurs when the mouse button is pressed down - - - - - The MouseUp event occurs when the mouse button is released - - - - - The MouseClick event occurs when the mouse button is clicked - - - - - The MouseMove event occurs when the mouse moving over the chart - - - - - The MouseDown event occurs when the user scrolling mouse wheel - - - - - The MouseDown event occurs when the mouse enter the chart - - - - - The MouseDown event occurs when the mouse leave the chart - - - - - - - - - - Access to the chart drawings collection - - - - - Add chart drawing to the collection - - - - - - Remove specified chart drawing from collection - - - - - - Get chart drawing by ID - - - - - - - Get all chart drawings assigned to specified symbol - - - - - - The Added events occured, when new chart drawing was added to collection - - - - - The Moved events occured, when chart drawing was moved - - - - - The Removed events occured, when chart drawing was removed from the collection - - - - - The SelectionChanged events occured, when selected chart drawing was changed - - - - - Access to the particular window from chart panel - - - - - Client rectangle of the chart window - - - - - Determines, whether this window is the main window of the chart - - - - - Chart window number - - - - - Special object, allows you to convert values from x/y scale to Time/Price and back - - - - - - - - - - Converter between x/y and Time/Price scales - - - - - Get the DateTime value that is corresponding to specified x coordinate - - - - - - - Get the Price value that is corresponding to specified y coordinate - - - - - - - Get the X coordinate that is corresponding to specified DateTime value - - - - - - - Get the Y coordinate that is corresponding to specified price value - - - - - - - Get the bar index that is corresponding to specified DateTime value - - - - - - - Access to the chart drawing - - - - - Determines, the way how chart drawing was created: manually or programmatically - - - - - Determines, the availability of drawing - only current chart or all charts with same symbol - - - - - The unique ID of the chart drawing - - - - - Determines, whether chart drawing draws above or below the main chart - - - - - Determines, state of the chart drawing: Locked or Unlocked - - - - - Get time and price of the particular point of the chart drawing - - - - - Set time and price value for particular point of the chart drawing - - - - - - - - - - - - - - - Gets s list - - - - - Gets symbol types list - - - - - Gets s list - - - - - Gets s list - - - - - Gets Exchanges list - - - - - Gets Orders list - - - - - Gets Order Types list - - - - - Represents exist orders history - - - - - Gets Positions list - - - - - Gets Closed Positions list - - - - - Gets Trades list - - - - - Gets Corporate Actions list - - - - - Gets Report Types list - - - - - Gets DealTickets list - - - - - Vendor connection respond bundle - - - - - The connection status - - - - - The respond message - - - - - Ping state dictum - - - - - Ping signals connected - - - - - Ping signals disconnected - - - - - Mediates a history meta data with available data types and intervals on vendor side - - - - - History data types - - - - - History intervals - - - - - Asset id bearer - - - - - Asset name bearer - - - - - Asset description - - - - - Asset id bearer - - - - - Performs a binding with broker or data provider - - - - - Specifies any operation before breaking a connection with broker or data provider - - - - - Called when platform finished retreiving all required informations from vendor during connecting - - - - - Ping processing before its visualization in the terminal - - - - - Retrieves an information about available accounts. Yon need to specify at least one account - - - - - Confirms allowed nonfixed list by vendor - - - - - Retrieves a collection of available exchange markets from vendor - - - - - Retrieves information about available assets. - - - - - Retrieves information about available symbols. - - - - - Gets an available symbols types from vendor - - - - - Derives a non fixed symbol from vendor - - - - - Derives a non-fixed list of symbols from vendor - - - - - Retrieves allowed/supported order types - - - - - Retrieves an information about opened orders at the time of connection. - - - - - Retrieves an information about positions at the time of connection - - - - - Gets trades history from server for requested time range - - - - - Subscribing to quote data: Level1/Level2/Trade - - - - - Unsubscribing from quote data: Level1/Level2/Trade - - - - - Gets a list of supported historical intervals and data types by vendor - - - - - Prepare and sending order placing request to broker - - - - - Sending order modification request to broker - - - - - Sending order cancellation request to broker - - - - - Sending position closing request to broker - - - - - Gets information about available reports from vendor - - - - - Called when platform need to generate particular report - - - - - Ping respond bundle - - - - - Ping time - - - - - Time spent for single request - - - - - Ping state - - - - - Performs a binding with broker or data provider - - - - - Specifies any operation before breaking a connection with broker or data provider - - - - - Called when platform finished retreiving all required informations from vendor during connecting - - - - - Ping processing before its visualization in the terminal - - - - - Retrieves an information about available accounts. Yon need to specify at least one account - - - - - Retrieves a collection of available exchange markets from vendor - - - - - Retrieves information about available assets. - - - - - Retrieves information about available symbols. - - - - - Gets an available symbols types from vendor - - - - - Derives a non fixed symbol from vendor - - - - - Derives a non-fixed list of symbols from vendor - - - - - Retrieves an information about opened orders at the time of connection. - - - - - Retrieves an information about positions at the time of connection - - - - - Retrieves an information about closed positions at the time of connection - - - - - Subscribing to quote data: Level1/Level2/Trade - - - - - Unsubscribing from quote data: Level1/Level2/Trade - - - - - Gets a list of supported historical intervals and data types by vendor - - - - - Prepare and sending order placing request to broker - - - - - Sending order modification request to broker - - - - - Sending order cancellation request to broker - - - - - Sending position closing request to broker - - - - - Gets information about available reports from vendor - - - - - Called when platform need to generate particular report - - - - - Retrieves allowed/supported order types - - - - - Confirms allowed nonfixed list by vendor - - - - - Gets a settings list from a vendor selection of the setup window - - - - - The ID of the order group. This group created when trades done by the MAM account. - - - - - Total quantity of the order - - - - - Gets OrderType - - - - - Gets order price value - - - - - Gets order trigger price value - - - - - Gets order trailing offset value - - - - - Gets orders current status - - - - - Gets orders last update time - - - - - Gets Position Id. - - - - - Gets StopLoss holder for given order - - - - - Gets TakeProfit holder for given order - - - - - Orders Type Id. It is used for the orders type comparing. - - - - - Gets order TIF(Time-In-Force) type - - - - - Gets orders expiration time - - - - - Remaining quantity of the order - - - - - Filled quantity of the order - - - - - Gets open order original status - - - - - Will be triggered on each invocation - - - - - Снапшот для эмулятора - - - - - Текущая версия для сериализации. Если что-то меняем и нужно делать поддержку старого формата - можно использовать версию. - - - - - Version 1.1: изменилась схема работы с коннектами: стали доступны кастомные коннекты - - - - - Defines 'Volume Analysis' calculation result item - - - - - Contains all user's account information - - - - - Gets account unique code. - - - - - Obtaining account name. - - - - - Gets base currency of account. Account CCY is always equal to the server CCY in AlgoStudio - - - - - Gets current balance of the account. - - - - - Gets additional account information - - - - - Will be triggered on each account information updating - - - - - Gets Account name - - - - - - Creates a business object info with an Account data which can be used for the restoring/serialization process. - - - - - - ключ для апи, обязательно для заполнения и должен быть уникальным - - - - - используется в связске с AccountAdditionalInfoItemFormatingType.CustomAsset для форматирования в заданном ассете - - - - - Defines asset entity - - - - - Asset id bearer - - - - - Asset name bearer - - - - - Asset description - - - - - Defines a number precision of the change value - - - - - Gets precision value - - - - - Gets asset ISO 4217 code - - - - - Creates an Asset instance - - given connection Id - - - - Formats price into precision normalized string - - - - - - - Formats price into concatenated string which contains the precision normalized value and Asset's name - - - - - - - Gets Asset name - - - - - - Uses comparison by Assets names - - - - - - - Unique ID during active session. Don't use for serialization - - - - - Договориль использовать множественное число для типа инструмента - - - - - Завели для индийской интеграции - - - - - Represents information about corporate action. - - - - - Get the date and time when trade was executed - - - - - Will be triggered on corporate action updating - - - - - Base class for all Custom symbols: Synthetics, Custom Formulas, etc. - - - - - Создать symbol message, содержащий аггрегированный параметры из нескольких инструменов - - - - - alexb: нам достаточно подставлять правильный HistoricalData - он сделает всю работу - - - - - Расчёт Bid/Ask/BidSize/AskSize для синтетика - - - - - Расчёт Last/LastSize для синтетика - - - - - Расчёт Level2 для синтетика - - - - - Расчёт DayBar для синтетика - - - - - Расчёт бара дял синтетика - - - - - Increment current position - - - - - Will be triggered on each invocation - - - - - Applies an position modificaion or position changing by accepting a message. - - - - - - Contains all information which belong to the given exchange - - - - - Gets Exchange Id - - - - - Gets Exchange name - - - - - Used for the Exchanges comparing - - - - - Compares Exchnges in order by next - SortIndex, Exchange name, Connection Id, Exchange Id. - - - - - - - Provides possibility to group and sort symbols for each connection - - - - - Gets group Id - - - - - Gets group name - - - - - Gets sort index for comparing process - - - - - Represents trading information about pending order - - - - - The ID of the order group. This group created when trades done by the MAM account. - - - - - Gets Position Id. - - - - - Total quantity of the order - - - - - Filled quantity of the order - - - - - Remaining quantity of the order - - - - - Orders Type Id. It is used for the orders type comparing. - - - - - Gets OrderType - - - - - Gets order price value - - - - - Gets order trigger price value - - - - - Gets order trailing offset value - - - - - Gets orders current status - - - - - Gets open order original status - - - - - Gets order TIF(Time-In-Force) type - - - - - Gets orders expiration time - - - - - Gets orders last update time - - - - - Gets StopLoss holder for given order - - - - - Gets TakeProfit holder for given order - - - - - Will be triggered on each invocation - - - - - Creates Order instance - - - - - - Applies an order modificaion or order changing by accepting a message. - - - - - - Cancels pending order - - - - - - Represents an wrapper - - - - - Represents trading information about related position - - - - - Will be triggered on each and invocation - - - - - Gets position quantity value - - - - - Gets position open order price - - - - - Gets position openning time - - - - - Gets Profit/loss (without swaps or commissions) all calculated based on the current broker's price. For open position it shows the profit/loss you would make if you close the position at the current price. If position closed, this parameter show profit/loss what trader have after closing this position. - - - - - Gets Profit/loss calculated based on the current broker's price. For open position it shows the profit/loss you would make if you close the position at the current price. If position closed, this parameter show profit/loss what trader have after closing this position. - - - - - Gets fee amount for the position. - - - - - Gets PnL swaps - - - - - The market price obtainable from your broker. - - - - - Closes position if quantity is not specified else - uses partial closing operation. - - - - - - - Gets StopLoss order which belongs to the position - - - - - Gets TakeProfit order which belongs to the position - - - - - Returns ticks amount between open and current price. - - - - - Represents a report grid which can hold system reports based on s and s content. - - - - - Columns collection - - - - - Rows collection - - - - - Initializes report grid - - - - - Adds coloring column to the report - - - - - Adds default(non-colored) column to the report - - - - - Exposes report cell decoration - - - - - Cell label - - - - - Cell value - - - - - Exposes report column decoration - - - - - Header of the column - - - - - Column value type - - - - - Exposes report row decoration - - - - - A collection of cells - - - - - Initializes cells in the row - - - - - Adds cells to the row by label and value - - - - - Adds cells to the row by value only - - - - - Defines report request parameters from which can be used in - - - - - Gets report Id - - - - - Gets report Name - - - - - report settings - - - - - Represents a permisions checking tool which use next priority order , , and - - - - - Represent access to symbol information and properties. - - - - - Gets symbol Id - - - - - Gets symbol name - - - - - Gets symbol description - - - - - Gets symbol type - - - - - Gets symbol base Asset - - - - - Gets symbol counter Asset - - - - - Gets Exchange of current symbol - - - - - Returns delay with which quote come in platform. - - - - - Gets symbol additional info - - - - - The highest trade allowed - - - - - The lowest trade allowed - - - - - Gets symbol NettingType - - - - - Gets SymbolGroup - - - - - Gets current SymbolQuotingType - - - - - Amount of base asset for one lot. - - - - - Stores list of symbol ticksizes - - - - - Cached value of TickSize (if 1 level) - - - - - Step of the lot changes - - - - - Step of the notional value changes - - - - - Gets derivative expiration date - - - - - Gets derivative last trading date - - - - - Gets derivative maturity date - - - - - Gets derivative strike price - - - - - Gets derivative option style - - - - - Gets derivative option type - - - - - Gets derivative option serie - - - - - Gets derivative underlier name - - - - - Gets derivative underlier symbol - - - - - Gets Ask price - - - - - Gets Ask size - - - - - Gets Bid price - - - - - Gets Bid size - - - - - Gets quote time - - - - - Gets last price - - - - - Gets last size - - - - - Gets last time - - - - - Gets mark price - - - - - Gets mark size - - - - - Gets open price - - - - - Gets previous close price - - - - - Gets high price - - - - - Gets low price - - - - - Gets volume value - - - - - Gets PrevSettlement value - - - - - Gets ticks amount - - - - - Gets trades amount - - - - - Gets Level2 data - - - - - Gets spread value between Bid and Ask - - - - - Gets percentage value - - - - - Gets change value between Bid/Last and Close price - - - - - Gets percentage value - - - - - Default history type - - - - - List of all available history types - - - - - Gets SymbolVolumeType - - - - - Will be triggered when new Level1 quote is comming - - - - - Will be triggered when new Level2 quote is comming - - - - - Will be triggered when new trade quote is comming - - - - - Will be triggered when new correctional quote is comming from the vendor. - - - - - Will be triggered when symbol updated. - - - - - Gets real time calculation setting - - - - - Gets real time calculation setting - - - - - Gets real time calculation setting - - - - - Gets real time calculation setting - - - - - Gets historical data according to period and other parameters - - - - - - - - - Gets historical data according to period and other parameters - - - - - - - - - - Gets historical data according to aggregation and other parameters - - - - - - - - - - Gets historical data according to given history request - - - - - - - Gets historical ticks data according to given parameters - - - - - - - - - Returns rounded to price - - - - - Calculates new price which equal to given price shifted by a number of given ticks - - - - - - - - Calculates ticks between two prices - - - - - - - - Gets cached symbol tick size or retrives it from the list - - - - - - - Gets symbol tick cost retrived from the list by price - - - - - - - Returns VariableTick if it can be retrived from list by price or null - - - - - - - Gets cached tick size if it available, else tries to obtain with Last, Bid, Ask, first element of list otherwise - - - - - - Formats price value to the appropriative string with a counting on tick precision. - - - - - - - Formats price value to the appropriative string with a counting on max tick precision. - - - - - - - Returns string with formatted ticks value - - - - - - - Comparing by value - - - - - - - Gets symbol orders types list which are allowed. - - - - - - - Process order placing with given request parameters - - - - - - - An symbol has possibility to obtain the default account - - - - - Represents information about trade. - - - - - Gets the unique identifier of the order initiating the trade. - - - - - Gets a unique identifier of the position, which is related to this trade. - - - - - Get the price where trade was executed - - - - - Get the trade quantity - - - - - Get the date and time when trade was executed - - - - - Get the trade Gross P&L - - - - - Get the trade Net P&L - - - - - Get the fee value that was charged for this trade - - - - - Get the trade order type - - - - - Will be triggered on trade updating - - - - - Represent access to level2 data. - - - - - Gets Level2 Asks list - - - - - Gets Level2 Bids list - - - - - Gets current Level2 data - - Parameters of DepthOfMarket - - - - - Gets current Level2 data - - Parameters of request for Leve2Item collection - - - - - Leve2 data. Contains Bids and Ask collections - - - - - Represent parameters of DepthOfMarket - - - - - Represent parameters of request for Leve2Item collection - - - - - Aggregation method - - - - - Required amount of level2 - - - - - Use custom tick size - - - - - Calculate cumulative size - - - - - Aggregation method - - - - - Represent access to level2 item. - - - - - Cumulative size - - - - - Imbalance Percent - - - - - Price - - - - - Size - - - - - Time - - - - - MMID - - - - - проверка на вхождение - - - - - Represents information about connection and provides an access to the current trading information(Symbols, Orders, Position, Accounts etc.). - - - - - Provides access to all business objects which are belong to this connection - - - - - Gets connection Id - - - - - Gets connection Name - - - - - Gets connection's vendor name - - - - - Contains list of connection settings. Will be reused on each population time. - - - - - Gets connection's state (Connected/Connecting/Fail etc.) - - - - - Defines connection type - - - - - Will be triggered when changed. - - - - - Will be triggered when changed. - - - - - Represents connection ping time - - - - - Messages count that one is waited to process - - - - - Gets a matched available metadata info with the vendor's side - - - - - Establishes a connection to a specified vendor - - - - - - Closes a connection. - - - - - Только для использования в ConnectionCache - - - - - alexb: "Умный" поиск - разрешаем указывать слова в любом порядке - - - - - Generates a report with given requested parameters - - specifies Report's type - - - - - Gets connection's s list - - - - - Gets connection's symbol types list which are allowed in this connection - - - - - Gets connection's s list - - - - - Gets connection's s list - - - - - Gets all Exchanges which are allowed in this connection - - - - - Gets all Orders which are belong to this connection - - - - - Gets all Order Types which are available on this connection - - - - - Represents all exist orders history which are belong to this connection. - - - - - Gets all Positions which are belong to this connection - - - - - Gets all Closed Positions which are belong to this connection - - - - - Gets all Trades which are belong to this connection - - - - - Gets all Corporate actions which are belong to this connection - - - - - Gets all Report Types which are available on this connection - - - - - Gets all DealTickets which are belong to this connection - - - - - Gets all Account operations which are available on this connection - - - - - Server connection status - - - - - Specifies connection using type. - - - - - Specifies how connection was created: by default or by user - - - - - Represents all needed parameters for the connection constructing process. - - - - - Gets a user friendly name of the connection - - - - - Gets connection group - - - - - Gets vendor's name - - - - - Gets connection Id - - - - - Favorites one will be displayed in Control center toolbar - - - - - Gets ConnectionState - - - - - Gets vendor's settings - - - - - Specifies how connection was created: by default or by user - - - - - realization - - - - - Creates connection info instance - - - - - - Creates connection info instance. - - - - - - - - - дефолтовый период пигования - - - - - Таймер, по которому проходит пинг - - - - - Запускаем таймер - - - - - Останавливаем таймер - - - - - Коннекты, которые нужно подключить - - - - - - Сколько ждем до следующей попытки - - - - - The main entry point in the API. Core keeps access to all business logic entities and their properties: - connections, accounts, symbols, positions, orders, etc. Some of them can be reached through using managers or directly via specified collections. - You can always acces the Core object via static Core.Instance property. - - - - - Gets a singleton instance of . API entry point - - - - - Gets an access to all created connections and manages them - - - - - Gets an access to the system logging mechanism - - - - - Obtains licence rules for the current user - - - - - Obtains metrics service - - - - - Gets an access to all available trading data vendors and creates them - - - - - Gets an access to the all available aggregation types - - - - - Access to Volume Analysis calculations - - - - - Gets an access to the all available indicators and creates them - - - - - Gets an access to the all available trading strategies and manages them - - - - - Gets a permissions checking mechanism - - - - - Gets a time based conversion and synchronization mechanism - - - - - Gets SMTP mail service for sending emails - - - - - Represents current trading status - - - - - Will be triggered when changed - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections - - - - - Gets all available s from open connections. Otherwise returns empty list - > - - - - Gets all available s from open connections - - - - - Starts a initialization process which initializes given Managers, and Utils. And provides a subscribing on events. - - - - - Disposes all previously initialized modules and unsubscribe from events - - - - - Will be triggered when new added to the core - - - - - Gets an instance of exist Account or creates a new one with given info parameter - - - - - - - Will be triggered when new added to the core - - - - - Returns all s from open connections which satisfy given request parameters, otherwise returns empty list - - - - - - - Retrieves any by given request parameters. Otherwise returns null - - - Must be specified if open connections total is more than one. Will search only in Synthetic symbols list if id is equal to - - - - - - Gets an instance of exist symbol or creates a new one with given info parameter - - - - - - - Will be triggered when new placed - - - - - Will be triggered when canceled - - - - - Gets instance by given Id string. Otherwise returns null - - - Must be specified if open connections total is more than one - - - - - Gets instance by given Id string. Otherwise returns null - - - Must be specified if open connections total is more than one - - - - - Will be triggered when new opened - - - - - Will be triggered when closed - - - - - Gets instance by given Id string. Otherwise returns null - - - Must be specified if open connections total is more than one - - - - - Gets Profit'n'Loss with given request parameters from open connection. Otherwise returns null - - - - - - - Will be triggered when new added - - - - - Will be triggered when removed - - - - - Will be triggered when new occured - - - - - Will be triggered when new occured - - - - - Will be triggered when new added - - - - - Places with given request parameters - - - - - - - Modifies by given request parameters - - - - - - - Closes with given request parameters - - - - - - - Cancels with given request parameters - - - - - - - Returns with given request parameters from open connection - - - - - - - Will be triggered when new received - - - - - Sends custom request if connection with given Id is open - - - - - - - Subscribe on custom messages - - custom message handler - custom messages Id - - - - Unsubscribe from custom messages - - custom message handler - custom messages Id - - - - Gets all previously configured s - - - - - Gets an access to s and manages them - - - - - Adds if given parameters are valid - - - - - - - Replaces exist list by new list in if given parameters are valid - - - - - - - Removes with a given name - - - - - - Replaces list name by new given name in if given parameters are valid - - - - - - - Represent all available Historical Symbols - - - - - Will be triggered when custom symbol added - - - - - Will be triggered when custom symbol removed - - - - - Will be triggered when custom symbol updated - - - - - Represent all available Synthetic items - - - - - Adds given Synthetic to the list if it does not contain - - - - - - Removes given Synthetic from the list if it exists - - - - - - Returns current version number - - - - - - Returns the time of last successful build - - - - - - Override to change string representation of aggregation - - - - - Represent access to historical data information and indicators control. - - - - - Gets HistoricalData symbol - - - - - Gets HistoricalData Period - - - - - Gets HistoricalData aggregation - - - - - Gets HistoricalData history type - - - - - Gets HistoricalData left time boundary - - - - - Gets HistoricalData right time boundary - - - - - Gets HistoricalData items amount - - - - - Retrieves HistoricalData item by indexing offset and direction to find. - - - - - - - - Will be triggered when new historical item created - - - - - Will be triggered when current historical item changed or updated - - - - - Gets access to built-in indicators - - - - - Reloads entire HistoricalData - - - - - Gets index by time with counting on search direction - - - - - Creates indicator by it's name and if it successfully created adds it to the HistoricalData - - - - - - - - Adds indicator to the HistoricalData - - - - - - Removes indicator from the HistoricalData - - - - - - Will be triggered when volume analysis of current historical item changed or updated - - - - - Period that can be used as a basis for history aggregations - - - - - - - - - - Represents historical data bar item - - - - - Gets bar's right time border - - - - - Defines bar's ticks count - - - - - Defines Open price - - - - - Defines High price - - - - - Defines Low price - - - - - Defines Close price - - - - - Gets Median (High+Low)/2 price - - - - - Gets Typical (High+Low+Close)/3 price - - - - - Gets Weighted (High+Low+Close+Close)/4 price - - - - - Defines ticks amount - - - - - Defines volume value - - - - - Gets price by indexing - - - - - - - Creates HistoryItemBar instance with default OHLC price = - - - - - Comparing by , OHLC, - - - - - - - Represents historical data trade item - - - - - Defines price value - - - - - Defines volume value - - - - - Defines trade operation side as aggressor flag - - - - - Gets price by indexing - - - - - - - Creates HistoryItemLast instance - - - - - Comparing by , OHLC, - - - - - - - Gets price by indexing - - - - - - - Creates HistoryItemLast instance - - - - - Represents historical data tick item - - - - - Defines Bid price - - - - - Defines Bid size - - - - - Defines Ask price - - - - - Defines Ask size - - - - - Gets price by indexing - - - - - - - Creates HistoryItemBar instance with default Ask/AskSize/Bid/BidSize = - - - - - Comparing by , OHLC, - - - - - - - Resolves a history request parameters per symbol - - - - - Represents mechanism for supporting predefined and custom periods - - - - - Gets period multiplier - - - - - Gets base period type - - - - - Gets ticks value as an result of base period multiplicated by - - - - - Creates Period instance with greater than 0 - - - - - - - True if their base paeriods and are respectively equal. - - - - - - - - True if any of their base paeriods and are respectively not equal. - - - - - - - - True if their ticks values are satisfying initial condition - - - - - - - - True if their ticks values are satisfying initial condition - - - - - - - - True if their ticks values are satisfying initial condition - - - - - - - - True if their ticks values are satisfying initial condition - - - - - - - - True if their base paeriods and are respectively equal. - - - - - - - Formats given value to a specific user friendly string - - - - - - - Returns value in ticks according to base period type - - - - - - - Returns shorted string according to base period type - - - - - - - Converts time gap into dates range - - - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Predefined period - - - - - Проход по диапазону дат с заданным шагом - - - - - Represent access to DayBar quote, which contains summary information about instrument prices. - - - - - High price - - - - - Open price - - - - - Low price - - - - - Previous Close price - - - - - Ticks value - - - - - Volume value - - - - - Previous settlement price - - - - - Bid price - - - - - Bid size - - - - - Ask price - - - - - Ask size - - - - - Last price - - - - - Last size - - - - - Trades value - - - - - Change value - - - - - Change value in percentage - - - - - - - - - - Represent access to DOM2 quote, which contains Bids and Asks. - - - - - Collection of Asks quotes - - - - - Collection of Bids quotes - - - - - Represent access to trade information. - - - - - Price at which trade occured - - - - - Size of the trade - - - - - Information about operation side of the trade - - - - - Shows the direction of price movement, comparing to previous value. - - - - - - - - - - - - - - - - - - - - - - - - - Represent access to Level2 quote. - - - - - Price type of Level2 quote: Bid or Ask - - - - - Price of Level2 quote - - - - - Size of Level2 quote - - - - - Unique ID of Level2 quote - - - - - Shows, whether Level2 quote is using only for removing from depth - - - - - Broker identifier that send level2 quote - - - - - specifies the implied quantity associated with the price for the quote. Subtracting this amount from the Size yields the outright quantity for the price level. A value of zero indicates that the implied size is not available/defined or that it is actually zero. - - - - - Time of the quote - - - - - Represent access to quote information. - - - - - Bid price - - - - - Bid size - - - - - Ask price - - - - - Ask size - - - - - Shows the direction of bid price movement, comparing to previous value. - - - - - Shows the direction of ask price movement, comparing to previous value. - - - - - Constants for licence keys - - - - - User licences info store - - - - - Current state of connection to licence server - - - - - Current connected user info - - - - - All active licences that user have - - - - - Check that user have licence - - - - - Specifies the reason of price data updating. - - - - - Indicates the processing of new historical bar. - - - - - Indicates the coming of new real-time tick. - - - - - Indicates a start of new real-time bar. - - - - - Specifies the type of events when indicator should recalculate itself. - - - - - Specifies the style of indicator line. - - - - - Moving average mode - - - - - Simple Moving Average - - - - - Exponential Moving Average - - - - - Smoothed Moving Average - - - - - Linearly Weighted Moving Average - - - - - - - - - - Displays HV schedule and percentile value. - - - - - Displays the percentile schedule only. - - - - - Returns an instance of the Exponential Moving Average (EMA) indicator. - EMA provides a weighted price calculation for the last N periods. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - namespace Example - { - ]]> - - ]]> - public class EMA : Indicator - { - #region Parameters - - // Period of moving average. - [InputParameter("Period of Exponential Moving Average", 0, 1, 999, 1, 0)] - public int Period = 2; - - // Price type of moving average. - [InputParameter("Sources prices for MA", 1, new object[] - { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted - })] - public PriceType SourcePrice = PriceType.Close; - - // Holds EMA's smoothing values. - private Indicator ema; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public EMA() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "EMA"; - Description = "Exponential moving average example"; - - // Defines line on demand with particular parameters. - AddLineSeries("EMA", Color.DodgerBlue, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbol or timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "EMA (" + Period.ToString() + ": " + SourcePrice.ToString() + ")"; - // Creates an instance of the proper indicator (EMA) from the default indicators list. - ema = Core.Instance.IndicatorManager.BuiltIn.EMA(Period, SourcePrice); - // Adds an auxiliary (EMA) indicator to the current one (EMA Example). - // This will let inner indicator (EMA) to be calculated in advance to the current one (EMA Example). - AddIndicator(ema); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip if count is smaller than period value. - if (Count Period) - return; - - // Sets value for displaying on the chart. - SetValue(ema.GetValue()); - } - } - } - - - Period of Exponential Moving Average - Sources prices for MA - - - - Gets the Linearly Weighted Moving Average - Linear Weighted Moving Average makes the most recent bar more important unlike SMA. - - - - using System; - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - public class TestLWMA : Indicator - { - #region Input params - Indicator slowLWMA, fastLWMA; - #endregion - // Input Parameter with an input field or checkbox (if bolean) - [InputParameter("Period slow LWMA", 0, 1, 9999)] - public int slowPeriod = 12; - [InputParameter("Period fast LWMA", 0, 1, 9999)] - public int fastPeriod = 8; - // Input Parameter with a dropdown - [InputParameter("Sources prices for calculation LWMA", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestLWMA() - : base() - { - // Defines indicator's name and description. - Name = "LWMA test"; - Description = "Example of using built-in LWMA indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("TestLWMA", Color.Blue, 1, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbol or timeframe) updates. - /// ]]> - public override void Init() - { - ShortName = "LWMA ("+slowPeriod.ToString()+":"+fastPeriod.ToString()+")"; - // Creation of an indicator with long period - slowLWMA = Core.Instance.IndicatorManager.BuiltIn.LWMA(slowPeriod, SourcePrice); - AddIndicator(slowLWMA); - // Creation of an indicator with short period - fastLWMA = Core.Instance.IndicatorManager.BuiltIn.LWMA(fastPeriod, SourcePrice); - AddIndicator(fastLWMA); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - if (Count ]]> Math.Max(slowPeriod, fastPeriod)) - SetValue((slowLWMA.GetValue() + fastLWMA.GetValue()) / 2); - } - } - } - - - Moving average period - Type of the price - - - - - Gets the SMA(Simple Moving Average) indicator. - The 'SMA' indicator provides an average price for the last N periods. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestSMA : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("Period of Simple Moving Average", 0, 1, 999, 1, 0)] - public int Period = 2; - - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for MA", 1, new object[] - { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted - })] - public PriceType SourcePrice = PriceType.Close; - - private Indicator sma; - - public TestSMA() - : base() - { - Name = "TestSMA"; - Description = "Example of using SMA indicator"; - - // Define one line with particular parameters. - AddLineSeries("Signal", Color.Green, 5, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serve for identification of related indicators with different parameters. - ShortName = "TestMA (" + Period + ":" + SourcePrice.ToString() + ")"; - - // Get SMA indicator from built-in indicator collection - sma = Core.Instance.IndicatorManager.BuiltIn.SMA(Period, SourcePrice); - - // Add auxiliary SMA indicator to the current. - AddIndicator(sma); - } - - public override void OnUpdate(UpdateArgs args) - { - // Checking, if current amount of bars - // more, than period of moving average. If it is - // then the calculation is possible - if (Count Period) - return; - - // Get SMA values for current and previos bars - var currentSmaValue = sma.GetValue(0); - var previousSmaValue = sma.GetValue(1); - - // Set value to the "Signal" line buffer - if (previousSmaValue currentSmaValue) - SetValue(1); - else if (previousSmaValue ]]> currentSmaValue) - SetValue(-1); - else - SetValue(0); - } - } - } - - - Period of simple moving average. - Sources prices for MA. - - - - - Returns an instance of the Smoothed Moving Average (SMMA) indicator. - SMMA indicator provides a smoothed average price for the last N periods. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Smoothed Moving Average example. - /// ]]> - public class SMMA : Indicator - { - #region Parameters - - // Period of moving average. - [InputParameter("Period of Smoothed Moving Average", 0, 1, 999, 1, 0)] - public int Period = 12; - - // Price type of moving average. - [InputParameter("Sources prices for MA", 1, new object[] - { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted - })] - public PriceType SourcePrice = PriceType.Close; - - // Holds SMMA's smoothing values. - Indicator smma; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public SMMA() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "SMMA"; - Description = "Smoothed moving average example"; - - // Defines line on demand with particular parameters. - AddLineSeries("SMMA", Color.DodgerBlue, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbol or timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "SMMA (" + MaPeriod.ToString() + ": " + SourcePrice.ToString() + ")"; - // Creates an instance of the proper indicator (SMMA) from the default indicators list. - smma = Core.Instance.IndicatorManager.BuiltIn.SMMA(Period, SourcePrice); - // Adds an auxiliary (SMMA) indicator to the current one (SMMA Example). - // This will let inner indicator (SMMA) to be calculated in advance to the current one (SMMA Example). - AddIndicator(smma); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip if count is smaller than period value. - if (Count Period) - return; - - // Sets value for displaying on the chart. - SetValue(smma.GetValue()); - } - } - } - - - Moving average period - Type of the price - - - - - Gets the PPMA(Pivot Point Moving Average) indicator. - The 'PPMA' indicator uses the pivot point calculation as the input a simple moving average. - - - - using TradingPlatform.BusinessLayer; - - namespace Example - { - public class TestPPMA : Indicator - { - //Defines input parameter as input field - [InputParameter("Period of TestPPMA", 0, 1, 999, 1, 0)] - public int Period = 2; - - private Indicator ppma; - private Indicator ema; - - public TestPPMA() - : base() - { - // Defines indicator's name and description. - Name = "TestPPMA"; - Description = "Example of using PPMA indicator"; - - // This example doesn't require indicator lines - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TPPMA (" + Period + ")"; - - // Create PPMA and EMA indicators from built-in indicator collection - ppma = Core.Instance.IndicatorManager.BuiltIn.PPMA(Period); - ema = Core.Instance.IndicatorManager.BuiltIn.EMA(Period, PriceType.Close); - - // Add auxiliary indicators to the current. - AddIndicator(ppma); - AddIndicator(ema); - } - - public override void OnUpdate(UpdateArgs args) - { - //Skip the history. Start calculation only on the real time data. - if (args.Reason == UpdateReason.HistoricalBar) - return; - - // Get EMA and PPMA values of previous bar (1 offset) from first line (line index is 0) - var prevEma = ema.GetValue(1); - var prevPPMA = ppma.GetValue(1, 1); - - // Get EMA and PPMA values of current bar (0 offset) form second line (line index is 1) - var currentPPMA = ppma.GetValue(0, 1); - var currentEma = ema.GetValue(0); - - // Show the alert window with some info - if (prevEma prevPPMA currentEma ]]> currentPPMA) - Alert("The ema crossed ppma from bottom to top"); - else if (prevEma ]]> prevPPMA currentEma currentPPMA) - Alert("The ema crossed ppma from top to bottom"); - } - } - } - - - Period of PPMA indicator - - - - - - Gets the MAS3 (3MASignal) indicator. - The 'MAS3' indicator offers buy and sell signals according to intersections of three moving averages. - - - - using TradingPlatform.BusinessLayer; - - namespace Example - { - public class TestMAS3 : Indicator - { - //Defines input parameters as input fields - [InputParameter("Short Moving Average Period", 0, 1, 999, 1, 0)] - public int ShortMaPeriod = 5; - - [InputParameter("Middle Moving Average Period", 1, 1, 999, 1, 0)] - public int MiddleMaPeriod = 10; - - [InputParameter("Long Moving Average Period", 2, 1, 999, 1, 0)] - public int LongMaPeriod = 25; - - [InputParameter("Amount of bars passed before opening position", 3, 1, 999, 1, 0)] - public int BarsInterval = 1; - - private Indicator mas; - private double trend = 0d; - - public TestMAS3() - : base() - { - // Defines indicator's name and description. - Name = "TestMAS3"; - Description = "Example of using MAS3 indicator"; - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestMAS3 (" + ShortMaPeriod + ":" + MiddleMaPeriod + ":" + LongMaPeriod + ":" + BarsInterval + ")"; - - // Get MAS3 indicator from built-in indicator collection. - mas = Core.Instance.IndicatorManager.BuiltIn.MAS3(ShortMaPeriod, MiddleMaPeriod, LongMaPeriod, BarsInterval); - - // Add auxiliary indicators to the current. - AddIndicator(mas); - } - - public override void OnUpdate(UpdateArgs args) - { - //Skip the history. Start calculation only on the real time data. - if (args.Reason == UpdateReason.HistoricalBar) - return; - - // Get MAS3 value of current bar (0 offset by default) - var currentTrend = mas.GetValue(); - - // The service method, which according to the 'currentTrend' value returns the trend name (as string) - var trendName = GetTrendNameHelper(currentTrend); - - // Show the alert window, with the info about current market trend - if (currentTrend != trend) - Alert($"The market trend was changed. Current trend is: '{ trendName }'"); - - trend = currentTrend; - } - - private string GetTrendNameHelper(double trend) - { - if (trend ]]> 0d) - return "Up"; - else if (trend 0d) - return "Down"; - else - return "None"; - } - } - } - - - Short moving average period. - Middle moving average period. - Long moving average period. - The count of bars. The trend will be determined on this interval. - - - - - - Gets the specific MA indicator, according to selected 'MaMode'. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestMA : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("Period of Moving Average", 0, 1, 999, 1, 0)] - public int Period = 10; - - // Displays Input Parameter as dropdown list. - [InputParameter("MA mode", 1, new object[]{ - "Simple Moving Average", MaMode.SMA, - "Exponential Moving Average", MaMode.EMA, - "Smoothed Moving Average", MaMode.SMMA, - "Linearly Weighted Moving Average", MaMode.LWMA, - })] - public MaMode MaType = MaMode.SMA; - [InputParameter("Sources prices for MA", 2, new object[]{ - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted - })] - public PriceType SourcePrice = PriceType.Close; - - private Indicator testMa; - private Indicator sma; - - public TestMA() - : base() - { - // Defines indicator's name and description. - Name = "TestMA"; - Description = "Test of built-in MA method"; - - // Defines one line with particular parameters. - AddLineSeries("MA", Color.Green, 2, LineStyle.SimpleChart); - } - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TMA (" + Period + ":" + SourcePrice.ToString() + ":" + MaType.ToString() + ")"; - - // Get MA indicator from built-in indicator collection (according to selected 'MaType'). - testMa = HistoricalData.BuiltIn.MA(Period, SourcePrice, MaType); - - // Get SMA indicator from built-in indicator collection. - sma = HistoricalData.BuiltIn.SMA(Period, SourcePrice); - } - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Print name of 'testMa' indicator and its value - // + name of 'sma' indicator (it's always "SMA") and its value - // + 'true' if their values are equal or 'false' if it isn't. - Print($"{testMa.Name}: {testMa.GetValue()}. \n" + - $"{sma.Name}: {sma.GetValue()}. \n" + - $"Indicator values are equal: {testMa.GetValue() sma.GetValue()}."); - - } - } - } - - - Period of moving average. - Type of price. - MA mode. - - - - - - Gets the BB(Bollinger Bands) indicator. - The 'BB' indicator provides a relative definition of high and low based on standard deviation and a simple moving average. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestBB : Indicator - { - //Defines 'Period' input parameters as input field and set allowable range from 1 to 999 - [InputParameter("Period of MA for envelopes", 0, 1, 999)] - public int Period = 5; - - //Defines 'Period' input parameters as input field and set allowable range from 0.1 to 100.0, increment of 0.1 - [InputParameter("Value of confidence interval", 1, 0.1, 100.0, 0.1, 1)] - public double D = 1.0; - - //Defines input parameters as dropdown lists - [InputParameter("Sources prices for MA", 2, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrices = PriceType.Low; - [InputParameter("Type of moving average", 3, new object[]{ - "Simple Moving Average", MaMode.SMA, - "Exponential Moving Average", MaMode.EMA, - "Smoothed Moving Average", MaMode.SMMA, - "Linearly Weighted Moving Average", MaMode.LWMA, - })] - public MaMode MaType = MaMode.SMA; - - private Indicator bb; - - public TestBB() - : base() - { - // Defines indicator's name and description. - Name = "TestBB"; - Description = "Example of using built-in BB indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("Diff", Color.Red, 5, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestBB (" + Period + ":" + D + ":" + SourcePrices.ToString() + ":" + MaType.ToString() + ")"; - - // Get BB indicator from built-in indicator collection. - bb = HistoricalData.BuiltIn.BB(Period, D, SourcePrices, MaType); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get BB values from zero ("Upper Band") and second ("Lower Band") lines. - var upperBand = bb.GetValue(0, 0); - var lowerBand = bb.GetValue(0, 2); - - // Get close price - var closePrice = Close(); - - // Calculates a difference between current close price and specific 'BB' line value. - var diff = 0d; - if (upperBand closePrice lowerBand closePrice) - diff = closePrice - upperBand; - else if (upperBand ]]> closePrice lowerBand ]]> closePrice) - diff = closePrice - lowerBand; - - // Set value to 'Diff' line buffer. - SetValue(diff, 0, 0); - } - } - } - - - Period of MA for envelopes. - Value of confidence interval. - Sources prices for MA. - Type of moving average. - - - - - - Gets the Commodity Channel Index. - Measures the position of price in relation to its moving average. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Indicators - { - public class TestCCI : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("CCI Period", 0, 1, 999, 1, 0)] - public int Period = 14; - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for MA", 0, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Typical; - #endregion Parameters - - private Indicator CCI; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestCCI() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestCCI"; - Description = "Example of using built-in CCI indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("CCI Line", Color.Red, 1, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - ShortName = "TestCCI ("+Period.ToString()+")"; - // Get 'CCI' indicator from built-in indicator collection. - CCI = Core.Instance.IndicatorManager.BuiltIn.CCI(Period, SourcePrice, MAType); - AddIndicator(CCI); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get values from 'CCI' indicator lines. - var cciRecent = CCI.GetValue(); - if(args.Reason != UpdateReason.NewTick cciRecent]]>100 cciRecent150) - Print("Long signal"); - else if(args.Reason != UpdateReason.NewTick cciRecent-100 cciRecent]]>-150) - Print("Short signal"); - } - } - } - - - Period for CCI MA - Sources prices for CCI - MA mode for CCI - - - - - - Returns an instance of the Modified Moving Average (MMA) indicator. - MMA comprises a sloping factor to help it overtake with the growing or declining value of the trading price of the currency. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Modified Moving Average example. - /// ]]> - public class MMA : Indicator - { - #region Parameters - - // Period of moving average. - [InputParameter("Period of Modified Moving Average", 0, 1, 999, 1, 0)] - public int Period = 2; - - // Price type of moving average. - [InputParameter("Sources prices for MA", 1, new object[] - { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted - })] - public PriceType SourcePrice = PriceType.Close; - - // Holds MMA's smoothing values. - private Indicator mma; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public MMA() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "MMA"; - Description = "Modified Moving Average example"; - - // Defines line on demand with particular parameters. - AddLineSeries("MMA", Color.DodgerBlue, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "MMA (" + Period.ToString() + ": "+ SourcePrice.ToString() + ")"; - // Creates an instance of the proper indicator (MMA) from the default indicators list. - mma = Core.Instance.IndicatorManager.BuiltIn.MMA(Period, SourcePrice); - // Adds an auxiliary (MMA) indicator to the current one (MMA Example). - // This will let inner indicator (MMA) to be calculated in advance to the current one (MMA Example). - AddIndicator(mma); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip if count is smaller than period value. - if (Count Period) - return; - - // Sets value for displaying on the chart. - SetValue(mma.GetValue()); - } - } - } - - - Period of Modified Moving Average - Sources prices for MA - - - - - Gets the Regression indicator - The Linear Regression Indicator plots the ending value of a Linear Regression Line for a specified number of bars; showing, statistically, where the price is expected to be. - - - - using System; - using TradingPlatform.BusinessLayer; - - namespace Indicators - { - public class TestRegression : Indicator - { - #region Input params - Indicator slowRL, fastRL; - ///]]> - ///Input Parameter with an input field or checkbox (if bolean) - ///]]> - [InputParameter("Period slow", 0, 1, 9999)] - public int Rlslow = 12; - [InputParameter("Period fast", 2, 1, 9999)] - public int Rlfast = 8; - /// ]]> - /// Input Parameter with a dropdown - /// ]]> - [InputParameter("Sources prices for calculation", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - #endregion - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestRegression() - : base() - { - Name = "Regression test"; - Description = "Example of using built-in Regression indicator"; - AddLineSeries(); - } - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public override void Init() - { - ShortName = "TestRegression ("+Rlslow.ToString()+":"+Rlfast.ToString()+")"; - // Creation of an indicator with long period - slowRL = Core.Instance.IndicatorManager.BuiltIn.Regression(Rlslow, SourcePrice); - AddIndicator(slowRL); - // Creation of an indicator with short period - fastRL = Core.Instance.IndicatorManager.BuiltIn.Regression(Rlfast, SourcePrice); - AddIndicator(fastRL); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - if (Count Math.Max(Rlslow, Rlfast)) - return; - - if (fastRL.GetValue()slowRL.GetValue()) - Alert("Downgoing"); - else if (fastRL.GetValue()]]>slowRL.GetValue()) - Alert("Upgoing"); - } - } - } - - - Moving average period - Type of the price - - - - - Gets the Channel (Price Channel) indicator. - The 'Channel' indicator is based on measurement of min and max prices for the definite number of periods. - - - - using TradingPlatform.BusinessLayer; - - namespace Example - { - public class TestChannel : Indicator - { - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Period of MA for envelopes", 0, 1, 999, 1, 0)] - public int Period = 5; - - private Indicator channel; - - public TestChannel() - : base() - { - // Defines indicator's name and description. - Name = "TestChannel"; - Description = "Example of using built-in Channel indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("Highest", Color.Red, 2, LineStyle.SimpleChart); - AddLineSeries("Lowest", Color.CadetBlue, 2, LineStyle.SimpleChart); - - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestChannel (" + Period + ")"; - - // Get 'Channel' indicator from built-in indicator collection. - channel = HistoricalData.BuiltIn.Channel(Period); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get values from 'Channel' indicator lines. - var highestValue = channel.GetValue(0, 0); - var lowestValue = channel.GetValue(0, 1); - - // Set values to the 'TestChannel' buffers ('Highest' and 'Lowest' lines). - SetValue(highestValue, 0, 0); - SetValue(lowestValue, 0, 1); - } - } - } - - - Period of price channel - - - - - - Gets the AFIRMA indicator - Autoregressive finite impulse response moving average. A digital filter accurately shows the price movement as powered with least square method to minimise time lag - - - - using System; - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Indicators - { - public class TestAfirma : Indicator - { - #region Input params - Indicator Afirma, Windowing; - /// - ///Input Parameter with an input field or checkbox (if bolean) - /// - [InputParameter("Window period", 0, 1, 9999)] - public int Period = 20; - /// - /// Input Parameter with a dropdown - /// - [InputParameter("Sources prices for calculation", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - [InputParameter("Windowing function", 2, new object[]{ - "Hanning", AfirmaMode.Hanning, - "Hamming", AfirmaMode.Hamming, - "Blackman", AfirmaMode.Blackman, - "Blackman - Harris", AfirmaMode.BlackmanHarris} - )] - public AfirmaMode win = AfirmaMode.Hanning; - #endregion - public TestAfirma() - : base() - { - Name = "Afirma GAP"; - Description = "Prints gap between Window function and least-squares method"; - AddLineSeries("Line", Color.Blue, 1, LineStyle.SimpleChart); - } - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public override void Init() - { - // Creation of an indicator Windowing MA with least-squares method overlapping (Afirma) - Afirma = Core.Instance.IndicatorManager.BuiltIn.AFIRMA(Period, SourcePrice, win, true); - AddIndicator(Afirma); - // Creation of an indicator Windowing MA - Windowing = Core.Instance.IndicatorManager.BuiltIn.AFIRMA(Period, SourcePrice, win, false); - AddIndicator(Windowing); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - if (Count Period) - return; - var res = Math.Abs((Afirma.GetValue()-Windowing.GetValue()))/100; - Print(res.ToString()+" %"); - } - } - } - - - Moving average period - Type of the price - Afirma mode - with least squares method overlapping if true - - - - - Gets the RSI indicator. - Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - namespace Example - { - public class SmoothRSI : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("RSI Period", 0, 1, 999, 1, 0)] - public int Period = 14; - [InputParameter("EMA Period", 0, 1, 999, 1, 0)] - public int emaPeriod = 10; - #endregion Parameters - // Default will be performed on Close prices - [InputParameter("Sources prices for the RSI line", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - // Default will be performed on Simple mode - [InputParameter("Mode for the RSI line", 2, new object[] { - "Simple", RSIMode.Simple, - "Exponential", RSIMode.Exponential} - )] - public RSIMode SourceRSI = RSIMode.Exponential; - private Indicator RSI; - - public SmoothRSI() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "RSItest"; - Description = "Example of using built-in RSI indicator"; - - AddLineSeries("Smooth RSI line", Color.CadetBlue, 2, LineStyle.SimpleChart); - } - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public override void Init() - { - ShortName = "Smooth RSI ("+emaPeriod.ToString()+")"; - // Get 'RSI' indicator from built-in indicator collection. - RSI = Core.Instance.IndicatorManager.BuiltIn.RSI(Period, SourcePrice, SourceRSI); - AddIndicator(RSI); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]>. - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get MA values from 'RSI' indicator lines. - var rsiValue = RSI.GetValue(0, 1); - - // Set values to the 'SmoothRSI' buffers. - SetValue(rsiValue); - } - } - } - - - RSI Period - Price Type - RSI Mode (Simple or Exponential) - - - - - - Returns an instance of the McGinley Dynamic indicator. - McGinley Dynamic avoids of most whipsaws and it rapidly moves up or down according to a quickly changing market. It needs no adjusting because it is dynamic and it adjusts itself. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// McGinley Dynamic example. - /// ]]> - public class MD : Indicator - { - #region Parameters - - // Period of McGinley Dynamic. - [InputParameter("Period", 0, 1, 999, 1, 0)] - public int Period = 2; - - // Smoothing of McGinley Dynamic. - [InputParameter("Smoothing", 1, 1, 999, 1, 0)] - public int Smoothing = 2; - - // Price type of McGinley Dynamic. - [InputParameter("Source price", 2, new object[] - { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted - })] - public PriceType SourcePrice = PriceType.Close; - - // Holds MD's smoothing values. - private Indicator md; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public MD() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "MD"; - Description = "McGinley Dynamic example"; - - // Defines line on demand with particular parameters. - AddLineSeries("MD", Color.DodgerBlue, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "MD (" + Period.ToString() + ": " + Smoothing.ToString() + ": " + SourcePrice.ToString() + ")"; - // Creates an instance of the proper indicator from the default indicators list. - md = Core.Instance.IndicatorManager.BuiltIn.MD(Period, Smoothing, SourcePrice); - // Adds an auxiliary (MD) indicator to the current one (MD). - // This will let inner indicator (MD) to be calculated in advance to the current one (MD). - AddIndicator(md); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip if count is smaller than period value. - if (Count Period) - return; - - // Sets value for displaying on the chart. - SetValue(md.GetValue()); - } - } - } - - - Period of exponential moving average - Dynamic tracking factor - Source price type - - - - - Gets the MAE (Moving Average Envelope) indicator. - The 'MAE' indicator demonstrates a range of the prices discrepancy from a Moving Average. - - - - using TradingPlatform.BusinessLayer; - - namespace Example - { - public class TestMAE : Indicator - { - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Period of MA for envelopes", 0, 1, 999, 1, 0)] - public int Period = 5; - - // Defines the 'SourcePrice' parameter as dropdown list - [InputParameter("Sources prices for MA", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Low; - - // Defines the 'MaType' parameter as dropdown list - [InputParameter("Type of moving average", 2, new object[]{ - "Simple Moving Average", MaMode.SMA, - "Exponential Moving Average", MaMode.EMA, - "Smoothed Moving Average", MaMode.SMMA, - "Linearly Weighted Moving Average", MaMode.LWMA, - })] - public MaMode MaType = MaMode.SMA; - - // Defines the 'UpShift' parameter as input field (where 'min' is 0.1, 'max' is 1.0 and 'increment' is 0.1). - [InputParameter("Upband deviation in %", 3, 0.1, 1.0, 0.1, 1)] - public double UpShift = 0.1; - - // Defines the 'DownShift' parameter as input field (where 'min' is 0.1, 'max' is 1.0 and 'increment' is 0.1). - [InputParameter("Downband deviation in %", 4, 0.1, 1.0, 0.1, 1)] - public double DownShift = 0.1; - - private Indicator mae; - - public TestMAE() - : base() - { - // Defines indicator's name and description. - Name = "TestMAE"; - Description = "Example of using built-in MAE indicator"; - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestMAE (" + Period + ":" + UpShift + ":" + DownShift + ")"; - - // Get MAE indicator from built-in indicator collection. - mae = HistoricalData.BuiltIn.MAE(Period, SourcePrice, MaType, UpShift, DownShift); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip the history. Start calculation only on real-time data (newBar/newTick). - if (args.Reason == UpdateReason.HistoricalBar) - return; - - // Get current close price (0 offset by default) - var closePrice = Close(); - - // Show the alert window with some info. - if (closePrice ]]> mae.GetValue(0, 0)) - Alert($"The current close price is higher than 'Upper Band' line of MAE indicator"); - else if (closePrice mae.GetValue(0, 1)) - Alert($"The current close price is lower than 'Lower Band' line of MAE indicator"); - } - } - } - - - Period of MA for envelopes. - Sources prices for MA. - Type of moving average. - Upband deviation in %. - Downband deviation in %. - - - - - - Returns an instance of the Parabolic Time/Price System (SAR) indicator. - SAR indicator helps to define the direction of the prevailing trend and the moment to close positions opened during the reversal. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Parabolic Time/Price System example. - /// ]]> - public class SAR : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Step of parabolic SAR system", 0, 2)] - public double Step = 0.02; - - [InputParameter("Maximum value for the acceleration factor", 1, 1)] - public double Maximum = 0.2; - - // Holds SAR's smoothing values. - private Indicator sar; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public SAR() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "SAR"; - Description = "Parabolic Time/Price System example"; - - // Defines line on demand with particular parameters. - AddLineSeries("SAR", Color.Firebrick, 4, LineStyle.DotChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "SAR (" + Step.ToString() + ": " + Maximum.ToString() + ")"; - // Creates an instance of the proper indicator (SAR) from the default indicators list. - sar = Core.Instance.IndicatorManager.BuiltIn.SAR(Step, Maximum); - // Adds an auxiliary (SAR) indicator to the current one (SAR Example). - // This will let inner indicator (SAR) to be calculated in advance to the current one (SAR Example). - AddIndicator(sar); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(sar.GetValue()); - } - } - } - - - Step of parabolic SAR system - Maximum value for the acceleration factor - - - - - - Gets the AO (Awesome Oscillator) indicator. - The 'AO' indicator determines market momentum. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestAO : Indicator - { - private Indicator ao; - - public TestAO() - : base() - { - // Defines indicator's name and description. - Name = "Test AO"; - Description = "Example of using built-in AO indicator"; - - // Define two lines (on sub window) with particular parameters - AddLineSeries("AO", Color.Gray, 3, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestAO"; - - // Get 'AO' indicator from built-in indicator collection. - ao = HistoricalData.BuiltIn.AO(); - } - - public override void OnUpdate(UpdateArgs args) - { - // Get AO indicator value. - var aoValue = ao.GetValue(); - - // The AO has fixed periods (9 and 34) in own calculation. - // We check, if 'aoValue' is 'NaN' (That's mean, at this moment, the 'Count' isn't enough for correct calculation of AO) - // then we skip our logic below. - if (aoValue == double.NaN) - return; - - // Set values to 'AO' line buffer. - SetValue(aoValue); - - } - } - } - - - - - - - Gets the CMO (Chande Momentum Oscillator) indicator. - The CMO calculates the dividing of difference between the sum of all recent gains and the sum of all recent losses by the sum of all price movement over the period. - - - - using TradingPlatform.BusinessLayer; - - namespace Example - { - public class TestCMO : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("Period of MA for envelopes", 0, 1, 999, 1, 0)] - public int Period = 8; - - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for MA", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - private Indicator cmo; - - private LineLevel upLevel; - private LineLevel downLevel; - - public TestCMO() - : base() - { - // Defines indicator's name and description. - Name = "Test CMO"; - Description = "Example of using built-in CMO indicator"; - } - - public override void Init() - { - /// Serves for an identification of related indicators with different parameters. - ShortName = "TestCMO (" + Period + ":" + SourcePrice + ")"; - - // Get 'CMO' indicator from built-in indicator collection. - cmo = HistoricalData.BuiltIn.CMO(Period, SourcePrice); - - // Get 'CMO' levels, if indicator was created. - if (cmo null) - { - upLevel = cmo.LinesLevels[0]; - downLevel = cmo.LinesLevels[1]; - } - } - - public override void OnUpdate(UpdateArgs args) - { - // Call the calculation below, only on HistoricalBar of NewBar. - if (args.Reason UpdateReason.NewTick) - return; - - // Check if we got 'CMO' levels. - if (upLevel null downLevel null) - return; - - // Get current 'CMO' value. - var cmoValue = cmo.GetValue(); - - // Show an alert window with some info. - if (cmoValue ]]> upLevel.Level) - Alert($"{Name}. The CMO value is higher than {upLevel.Name} level."); - else if (cmoValue downLevel.Level) - Alert($"{Name}. The CMO value is lower than {downLevel.Name} level."); - } - } - } - - - Period of MA for envelopes. - Sources prices for MA. - - - - - - Returns an instance of the ZigZag indicator. - ZigZag is a trend following indicator that is used to predict when a given symbol's momentum is reversing. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// - /// ZigZag example. - /// - public class ZZ : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Percent Deviation", 0, 0.01, 1.5, 0.01, 2)] - public double deviation = 1; - - // Holds ZigZag's smoothing values. - private Indicator zz; - - #endregion - - /// - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// - public ZZ() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "ZigZag"; - Description = "ZigZag example"; - - // Defines line on demand with particular parameters. - AddLineSeries("ZZ'Line", Color.DarkOrange, 2, LineStyle.DotChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "ZZ (" + deviation.ToString() + ")"; - // Creates an instance of the proper indicator (ZZ) from the default indicators list. - zz = Core.Instance.IndicatorManager.BuiltIn.ZZ(deviation); - // Adds an auxiliary (ZZ) indicator to the current one (ZZ Example). - // This will let inner indicator (ZZ) to be calculated in advance to the current one (ZZ Example). - AddIndicator(zz); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(zz.GetValue()); - } - } - } - - - Percent Deviation - - - - - - Gets the Aroon indicator. - Reveals the beginning of a new trend and determines how strong it is - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class AroonTest : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Aroon Period", 0, 1, 999, 1, 0)] - public int Period = 14; - #endregion Parameters - - private Indicator Aroon; - - public AroonTest() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "AroonTest"; - Description = "Example of using built-in Aroon indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("Up line", Color.Red, 2, LineStyle.SimpleChart); - AddLineSeries("Down line", Color.CadetBlue, 2, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "Arron ("+Period.ToString()+")"; - // Get 'Arron' indicator from built-in indicator collection. - Aroon = Core.Instance.IndicatorManager.BuiltIn.AROON(Period); - AddIndicator(Aroon); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (CountPeriod) - return; - - // Get values from 'Aroon' indicator lines. - var highestValue = Aroon.GetValue(0, 0); - var lowestValue = Aroon.GetValue(0, 1); - - // Set values to the 'AroonTest' buffers ('Highest' and 'Lowest' lines). - SetValue(highestValue, 0, 0); - SetValue(lowestValue, 0, 1); - } - } - } - - - Aroons period - - - - - - Returns an instance of the Standart Deviation (SD) indicator. - The SD shows the difference of the volatility value from the average one. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Standard Deviation example. - /// ]]> - public class SD : Indicator - { - #region Parameters - - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for MA", 0, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period", 2, 1, 999, 1, 0)] - public int Period = 20; - - // Holds SD's smoothing values. - private Indicator sd; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public SD() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Standard Deviation"; - Description = "Standard Deviation example"; - - // Defines line on demand with particular parameters. - AddLineSeries("SD'Line", Color.Blue, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "SD (" + Period.ToString() + ": " + SourcePrice.ToString() + ": " + MAType.ToString() + ")"; - // Creates an instance of the proper indicator (SD) from the default indicators list. - sd = Core.Instance.IndicatorManager.BuiltIn.SD(Period, SourcePrice, MAType); - // Adds an auxiliary (SD) indicator to the current one (SD Example). - // This will let inner indicator (SD) to be calculated in advance to the current one (SD Example). - AddIndicator(sd); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(sd.GetValue()); - } - } - } - - - Period of indicator - Sources prices for MA - Type of Moving Average - - - - - - Gets the MACD (Moving Average Convergence/Divergence) indicator. - The MACD is a trend-following momentum indicator that shows the relationship between two moving averages of prices. - - - - using TradingPlatform.BusinessLayer; - using System.Linq; - - namespace Example - { - public class TestMACD : Indicator - { - // Display input parameters as input fields. - [InputParameter("Period of fast EMA", 0, 1, 999, 1, 0)] - public int FastPeriod = 12; - - [InputParameter("Period of slow EMA", 1, 1, 999, 1, 0)] - public int SlowPeriod = 26; - - [InputParameter("Period of signal EMA", 2, 1, 999, 1, 0)] - public int SignalPeriod = 9; - - private int maxPeriod; - private Indicator macd; - - public TestMACD() - : base() - { - // Defines indicator's name and description. - Name = "Test MACD"; - Description = "Example of using built-in MACD indicator"; - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestMACD (" + FastPeriod + ":" + SlowPeriod + ":" + SignalPeriod + ")"; - - // Find the max period. - maxPeriod = Enumerable.Max(new int[] { FastPeriod, SlowPeriod, SignalPeriod }); - - // Get MACD indicator from built-in indicator collection and add it to the current one as auxiliary. - macd = Core.Instance.IndicatorManager.BuiltIn.MACD(FastPeriod, SlowPeriod, SignalPeriod); - AddIndicator(macd); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip the history. Start calculation only on real-time data (newBar/newTick). - if (args.Reason UpdateReason.HistoricalBar) - return; - - // Get the current and previoud signal line values of MACD indicator (1 line index). - var currSignal = macd.GetValue(0, 1); - var prevSignal = macd.GetValue(1, 1); - - // Show an alert window with some info. - if (prevSignal 0d currSignal ]]> 0d) - Alert("The 'Signal' line crosses of zero line from bottom to top."); - else if (prevSignal ]]> 0d currSignal 0d) - Alert("The 'Signal' line crosses of zero line from top to bottom."); - } - } - } - - - Period of fast EMA. - Period of slow EMA. - Period of signal EMA. - - - - - - Returns an instance of the Kairi Relative Index (KRI) indicator. - KRI calculates deviation of the current price from its simple moving average as a percent of the moving average. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Kairi Relative Index example. - /// ]]> - public class KRI : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period", 2, 1, 999, 1, 0)] - public int Period = 20; - - // Holds KRI's values. - private Indicator kri; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public KRI() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Kairi Relative Index"; - Description = "Kairi Relative Index example"; - - // Defines line on demand with particular parameters. - AddLineSeries("SD'Line", Color.Blue, 1, LineStyle.SimpleChart); - AddLineLevel(0, "0'Line", Color.Gray, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "KRI (" + Period.ToString() + ")"; - // Creates an instance of the proper indicator (KRI) from the default indicators list. - kri = Core.Instance.IndicatorManager.BuiltIn.KRI(Period); - // Adds an auxiliary (KRI) indicator to the current one (KRI Example). - // This will let inner indicator (KRI) to be calculated in advance to the current one (KRI Example). - AddIndicator(kri); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(kri.GetValue()); - } - } - } - - - - - - - - - Returns an instance of the Bollinger Bands Flat (BBF) indicator. - The BBF provides the same data as BB, but drawn in separate field and easier to recognize whether price is in or out of the band. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Bollinger Bands Flat example. - /// ]]> - public class BBF : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period", 0, 1, 999, 1, 0)] - public int Period = 9; - - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for MA", 2, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Deviation", 3, 0.01, 3, 0.01, 2)] - public double Deviation = 1.5; - - // Holds BBF's values. - private Indicator bbf; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public BBF() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Bollinger Bands Flat"; - Description = "Bollinger Bands Flat example"; - - // Defines line on demand with particular parameters. - AddLineSeries("+SD", Color.Red, 1, LineStyle.SimpleChart); - AddLineSeries("-SD", Color.Red, 1, LineStyle.SimpleChart); - AddLineSeries("BBF'Line", Color.FromArgb(0, 51, 252), 1, LineStyle.SimpleChart); - AddLineLevel(0, "0'Line", Color.Aqua, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "BBF (" + Period.ToString() + ")"; - // Creates an instance of the proper indicator (BBF) from the default indicators list. - bbf = Core.Instance.IndicatorManager.BuiltIn.BBF(Period, Deviation, SourcePrice, MAType); - // Adds an auxiliary (BBF) indicator to the current one (BBF Example). - // This will let inner indicator (BBF) to be calculated in advance to the current one (BBF Example). - AddIndicator(bbf); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets relevant values for displaying on the chart. - for (int i = 0; i bbf.LinesSeries.Length; i++) - { - SetValue(bbf.GetValue(0,i),0,i); - } - } - } - } - - - Period - Deviation - Sources prices for MA - Type of Moving Average - - - - - - Gets the ROC (Rate of Change) indicator. - The ROC shows the speed at which price is changing. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestROC : Indicator - { - // Displays 'Period' input parameter as input field. - [InputParameter("Period of momentum", 0, 1, 999, 1, 0)] - public int Period = 20; - - private Indicator roc; - private LineLevel zeroLevel; - - public TestROC() - : base() - { - // Serves for an identification of related indicators. - Name = "Test ROC"; - Description = "Example of using built-in ROC indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("Signal", Color.DodgerBlue, 5, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestROC (" + Period + ")"; - - // Get ROC indicator from built-in indicator collection - roc = Core.Instance.IndicatorManager.BuiltIn.ROC(Period); - - // Get an instance of level line from ROC indicator. - zeroLevel = roc.LinesLevels[0]; - - // Attach the 'ROC' indicator to the current 'TestROC'. - AddIndicator(roc); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Start the calculation only on HistoricalBar or NewBar. - if (args.Reason UpdateReason.NewTick) - return; - - // Get current and previous values of ROC indicator. - var currROC = roc.GetValue(0); - var prevROC = roc.GetValue(1); - - // Assign 0 to a signal variable by default . - var signal = 0; - - // Change the signal value if the crossing of 'ROC' indicator with zero level was happened. - if (currROC ]]> zeroLevel.Level prevROC zeroLevel.Level) - signal = 1; - else if (currROC zeroLevel.Level prevROC ]]> zeroLevel.Level) - signal = -1; - - // Set signal value to a 'Signal' line buffer. - SetValue(signal); - } - } - } - - - Period of momentum. - - - - - - Gets the Momentum indicator. - Momentum compares where the current price is in relation to where the price was in the past. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - namespace Example - { - public class TestMomentum : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Momentum Period", 0, 1, 999, 1, 0)] - public int Period = 20; - #endregion Parameters - - private Indicator Momentum; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestMomentum() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestMomentum"; - Description = "Example of using built-in Momentum indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("Signal", Color.DodgerBlue, 5, LineStyle.HistogrammChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "Momentum ("+Period.ToString()+")"; - // Get 'Momentum' indicator from built-in indicator collection. - Momentum = Core.Instance.IndicatorManager.BuiltIn.Momentum(Period,PriceType.Close); - AddIndicator(Momentum); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get values from 'Momentum' indicator lines. - var MomentumNew = Momentum.GetValue(); - if(MomentumNew>0) - Print("Upward movement"); - else - Print("Downward movement"); - } - } - } - - - Period for Momentum - Sources prices for Momentum - - - - - - Gets the %R Larry Williams. - Uses Stochastic to determine overbought and oversold levels. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestRLW : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("RLW Period", 0, 1, 999, 1, 0)] - public int Period = 20; - #endregion Parameters - - private Indicator RLW; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestRLW() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestRLW"; - Description = "Example of using built-in RLW indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries(); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "RLW ("+Period.ToString()+")"; - // Get 'RLW' indicator from built-in indicator collection. - RLW = Core.Instance.IndicatorManager.BuiltIn.RLW(Period); - AddIndicator(RLW); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get values from 'RLWNew' indicator lines. - var RLWNew = RLW.GetValue(); - if(args.Reason != UpdateReason.NewTick RLWNew]]>70) - Print("Upward movement"); - else if(args.Reason != UpdateReason.NewTick RLWNew 20) - Print("Downward movement"); - } - } - } - - - Period for Momentum - - - - - - Returns an instance of the Price Oscillator (PO) indicator. - PO calculates the variation between price moving averages. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Price Oscillator example. - /// ]]> - public class PO : Indicator - { - #region Parameters - - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Moving Average", 0, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - [InputParameter("Sources prices for MA", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period of MA1", 2)] - public int MAPeriod1 = 2; - - [InputParameter("Period of MA2", 3)] - public int MAPeriod2 = 25; - - // Holds PO's values. - private Indicator po; - - #endregion - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public PO() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Price Oscillator"; - Description = "Price Oscillator example"; - - // Defines line on demand with particular parameters. - AddLineSeries("PO'Line", Color.Blue, 1, LineStyle.SimpleChart); - AddLineLevel(0, "0'Line", Color.Gray, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "PO (" + MAPeriod1.ToString() + ": " + MAPeriod2.ToString() + ": " + SourcePrice.ToString() + ": " + MAType.ToString() + ")"; - // Creates an instance of the proper indicator (PO) from the default indicators list. - po = Core.Instance.IndicatorManager.BuiltIn.PO(MAPeriod1, MAPeriod2, SourcePrice, MAType); - // Adds an auxiliary (PO) indicator to the current one (PO Example). - // This will let inner indicator (PO) to be calculated in advance to the current one (PO Example). - AddIndicator(po); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(po.GetValue()); - } - } - } - - - Period of MA1 - Period of MA2 - Sources prices for MA - Type of Moving Average - - - - - - Gets the OsMA (Moving Average of Oscillator) indicator. - The OsMA reflects the difference between an oscillator (MACD) and its moving average (signal line). - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - using System.Linq; - - namespace Example - { - public class TestOsMA : Indicator - { - // Display input parameters as input fields. - [InputParameter("Period of fast EMA", 0, 1, 999, 1, 0)] - public int FastPeriod = 12; - - [InputParameter("Period of slow EMA", 1, 1, 999, 1, 0)] - public int SlowPeriod = 26; - - [InputParameter("Period of signal EMA", 2, 1, 999, 1, 0)] - public int SignalPeriod = 9; - - private int maxPeriod; - private Indicator osma; - - public TestOsMA() - : base() - { - // Defines indicator's name and description. - Name = "Test OsMA"; - Description = "Example of using built-in OsMA indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("OsMA", Color.Orange, 4, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestOsMA (" + FastPeriod + ":" + SlowPeriod + ":" + SignalPeriod + ")"; - - // Find the max period. - maxPeriod = Enumerable.Max(new int[] { FastPeriod, SlowPeriod, SignalPeriod }); - - // Get OsMA indicator from built-in indicator collection and add it to the current one as auxiliary. - osma = Core.Instance.IndicatorManager.BuiltIn.OsMA(FastPeriod, SlowPeriod, SignalPeriod); - AddIndicator(osma); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip max period for correct calculation. - if (Count maxPeriod) - return; - - // Get value from OsMA indicator. - var value = osma.GetValue(0, 0); - - // Set value to the 'OsMA' line buffer. - SetValue(value); - } - } - } - - - Period of fast EMA. - Period of slow EMA. - Period of signal EMA. - - - - - - Gets On Balance Volume. - On Balance Volume (OBV) measures buying and selling pressure as a cumulative indicator that adds volume on up days and subtracts volume on down days. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestOBV : Indicator - { - #region Paramaters - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for OBV", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - #endregion Parameters - - private Indicator OBV; - - public TestOBV() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestOBV"; - Description = "Example of using built-in OBV indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries(); - } - public override void Init() - { - ShortName = "OBV ("+SourcePrice.ToString()+")"; - // Get 'OBV' indicator from built-in indicator collection. - OBV = Core.Instance.IndicatorManager.BuiltIn.OBV(SourcePrice); - AddIndicator(OBV); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count 1) - return; - - // Get values from 'OBV' indicator lines. - var OBVNew = OBV.GetValue(); - SetValue(OBVNew); - } - } - } - - - Sources prices for OBV - - - - - - Returns an instance of the Positive Volume Index (PVI) indicator. - The PVI value changes on the periods in which value of volume has increased in comparison with the previous period. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Positive Volume Index example. - /// ]]> - public class PVI : Indicator - { - #region Parameters - - // Displays Input Parameter as dropdown list. - [InputParameter("Source price", 0, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - #endregion - - // Holds PVI's values. - private Indicator pvi; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public PVI() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Positive Volume Index"; - Description = "Positive Volume Index example"; - - // Defines line on demand with particular parameters. - AddLineSeries("PVI'Line", Color.Blue, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "PVI (" + SourcePrice.ToString() + ")"; - // Creates an instance of the proper indicator (PVI) from the default indicators list. - pvi = Core.Instance.IndicatorManager.BuiltIn.PVI(SourcePrice); - // Adds an auxiliary (PVI) indicator to the current one (PVI Example). - // This will let inner indicator (PVI) to be calculated in advance to the current one (PVI Example). - AddIndicator(pvi); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(pvi.GetValue()); - } - } - } - - - - - - - - - Returns an instance of the Volume indicator. - Volume allows to confirm the strength of a trend or to suggest about it's weakness. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Volume example. - /// ]]> - public class Volume : Indicator - { - // Holds Volume's values. - private Indicator volume; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public Volume() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Volume"; - Description = "Volume example"; - - // Defines line on demand with particular parameters. - AddLineSeries("Volume'Line", Color.Gray, 1, LineStyle.HistogrammChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "Volume"; - // Creates an instance of the proper indicator (Volume) from the default indicators list. - volume = Core.Instance.IndicatorManager.BuiltIn.Volume(); - // Adds an auxiliary (Volume) indicator to the current one (Volume Example). - // This will let inner indicator (Volume) to be calculated in advance to the current one (Volume Example). - AddIndicator(volume); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(volume.GetValue()); - } - } - } - - - - - - - - Gets the MFI(Money Flow Index) indicator. - The MFI(Money Flow Index) is an oscillator that uses both price and volume to measure buying and selling pressure. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestMFI : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("MFI Period", 0, 1, 999, 1, 0)] - public int Period = 14; - - private Indicator mfi; - private LineLevel upLevel; - private LineLevel downLevel; - - public TestMFI() - : base() - { - // Serves for an identification of related indicators. - Name = "Test MFI"; - Description = "Example of using built-in MFI indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("MFI", Color.Orange, 5, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestMFI (" + Period + ")"; - - // Get MFI indicator from built-in indicator collection - mfi = Core.Instance.IndicatorManager.BuiltIn.MFI(Period); - - // Get an instance of level lines from MFI indicator. - upLevel = mfi.LinesLevels[0]; - downLevel = mfi.LinesLevels[1]; - - // Attach the 'MFI' indicator to the current 'TestMFI'. - AddIndicator(mfi); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Start the calculation only on HistoricalBar or NewBar. - if (args.Reason UpdateReason.NewTick) - return; - - // Get current and previous values of MFI indicator. - var currMFI = mfi.GetValue(0); - var prevMFI = mfi.GetValue(1); - - // Assign 0 to a signal variable by default . - var signal = 0; - - // Change the signal value if the crossing of 'ROC' indicator with zero level was happened. - if (currMFI ]]> upLevel.Level prevMFI upLevel.Level) - signal = 1; - else if (currMFI downLevel.Level prevMFI ]]> downLevel.Level) - signal = -1; - - // Set signal value to a 'Signal' line buffer. - SetValue(signal); - } - } - } - - - Period of MFI. - - - - - - Returns an instance of the Acceleration/Deceleration Oscillator (AC). - AC measures the acceleration and deceleration of the current momentum. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Acceleration Oscillator example. - /// ]]> - public class AC : Indicator - { - // Holds AC's values. - private Indicator ac; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public AC() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Acceleration Oscillator"; - Description = "Acceleration Oscillator example"; - - // Defines line on demand with particular parameters. - AddLineSeries("AC'Line", Color.Gray, 1, LineStyle.HistogrammChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "AC"; - // Creates an instance of the proper indicator (AC) from the default indicators list. - ac = Core.Instance.IndicatorManager.BuiltIn.AC(); - // Adds an auxiliary (AC) indicator to the current one (AC Example). - // This will let inner indicator (AC) to be calculated in advance to the current one (AC Example). - AddIndicator(ac); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(ac.GetValue()); - } - } - } - - - - - - - - Gets the Average True Range (ATR) indicator. - The ATR measures of market volatility. - - - - using TradingPlatform.BusinessLayer; - using System; - - namespace Example - { - public class TestATR : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("Period", 0, 1, 999, 1, 0)] - public int Period = 20; - - // Displays Input Parameter as input field. - [InputParameter("Period of Moving Average (ATR)", 1, 1, 999, 1, 0)] - public int AtrPeriod = 13; - - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Moving Average (ATR)", 2, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Smoothed", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - private Indicator atr; - private int maxPeriod; - - public TestATR() - : base() - { - // Defines indicator's name and description. - Name = "TestATR"; - Description = "Example of using built-in ATR indicator"; - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "My indicator ("+ Period + ":" + AtrPeriod + ":" + MAType.ToString() + ")"; - - // Get ATR indicator from built-in indicator collection. - atr = Core.Instance.IndicatorManager.BuiltIn.ATR(AtrPeriod, MAType); - - maxPeriod = Math.Max(Period, AtrPeriod); - - // Add auxiliary ATR indicator to the current one. - AddIndicator(atr); - } - - public override void OnUpdate(UpdateArgs args) - { - // Launch calculation every NewBar only. - if (args.Reason UpdateReason.NewBar) - return; - - // Skip max period. - if (Count maxPeriod) - return; - - // Get the highest and lowest values of ATR on the interval. - var highestATR = GetHighestATR(0, Period); - var lowestATR = GetLowestATR(0, Period); - - // Show alert window with usefull information. - Alert($"The highest ATR value on the interval is : {highestATR}\n" + - $"The lowest ATR value on the interval is : {lowestATR}"); - } - - private double GetHighestATR(int startOffset, int count) - { - // Find the highest value of ATR indicator on the specific interval. - int maxValueOffset = startOffset; - for (int i = 0; i count; i++) - { - if (atr.GetValue(maxValueOffset) atr.GetValue(startOffset + i)) - maxValueOffset = startOffset + i; - } - return maxValueOffset; - } - - private double GetLowestATR(int startOffset, int count) - { - // Find the lowest value of ATR indicator on the specific interval. - int minValueOffset = startOffset; - for (int i = 0; i count; i++) - { - if (atr.GetValue(minValueOffset) ]]> atr.GetValue(startOffset + i)) - minValueOffset = startOffset + i; - } - return minValueOffset; - } - } - } - - - - Period of Moving Average. - Type of Moving Average - - - - - Returns an instance of the Kaufman Adaptive Moving Average (KAMA) indicator. - KAMA is an exponential style average with a smoothing that varies according to recent data. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Kaufman Adaptive Moving Average example. - /// ]]> - public class KAMA : Indicator - { - #region Parameters - - // Defines initial parameters. - [InputParameter("Period", 0, 1, 9999)] - public int periodAMA = 10; - - [InputParameter("#Fast", 1, 1, 500, 1)] - public double nfast = 2.0; - - [InputParameter("#Slow", 2, 1, 500, 1)] - public double nslow = 30.0; - - [InputParameter("G", 3, 1, 10, 0.1)] - public double G = 2.0; - - [InputParameter("dK", 4, 1, 10, 0.1)] - public double dK = 2.0; - - // Displays Input Parameter as dropdown list. - [InputParameter("Sources prices for MA", 5, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Median", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - // Displays Input Parameter as dropdown list. - [InputParameter("AMA Trend Type", 6, new object[] { - "Fixed", AMATrendType.Fixed, - "Average", AMATrendType.Average } - )] - public AMATrendType AMA_Trend_Type; - - #endregion - - // Holds KAMA's values. - private Indicator kama; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public KAMA() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Kaufman Adaptive Moving Average example"; - Description = "Kaufman Adaptive Moving Average example"; - - // Defines line on demand with particular parameters. - AddLineSeries("KAMA'Line", Color.Gray, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "KAMA (" + periodAMA.ToString() + ": " + nfast.ToString() + ": " + nslow.ToString() + ": " + G.ToString() + ": " + dK.ToString() + ")"; - // Creates an instance of the proper indicator (KAMA) from the default indicators list. - kama = Core.Instance.IndicatorManager.BuiltIn.KAMA(periodAMA,nfast, nslow, G, dK, SourcePrice, AMA_Trend_Type); - // Adds an auxiliary (KAMA) indicator to the current one (KAMA Example). - // This will let inner indicator (KAMA) to be calculated in advance to the current one (KAMA Example). - AddIndicator(kama); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(kama.GetValue()); - } - } - } - - - Period - Fast factor - Slow factor - G coefficient - dK coefficient - Sources prices for MA - AMA Trend Type - - - - - - Returns an instance of the Qstick indicator. - The Qstick is a moving average that shows the difference between the prices at which an issue opens and closes. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Qstick example. - /// ]]> - public class Qstick : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period", 0, 1, 999, 0, 0)] - public int Period = 20; - - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - #endregion - - // Holds Qstick's values. - private Indicator qstick; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public Qstick() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Qstick example"; - Description = "Qstick example"; - - // Defines line on demand with particular parameters. - AddLineSeries("Qstick'Line", Color.Gray, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "Qstick (" + Period.ToString() + ": " + MAType.ToString() + ")"; - // Creates an instance of the proper indicator (Qstick) from the default indicators list. - qstick = Core.Instance.IndicatorManager.BuiltIn.Qstick(Period, MAType); - // Adds an auxiliary (Qstick) indicator to the current one (Qstick Example). - // This will let inner indicator (Qstick) to be calculated in advance to the current one (Qstick Example). - AddIndicator(qstick); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets value for displaying on the chart. - SetValue(qstick.GetValue()); - } - } - } - - - - - - - - - - Get the Swing Index (SI) indicator. - The SI is used to confirm trend line breakouts on price charts. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestSI : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("Divider", 0, 0.1, 9999.0, 0.1, 1)] - public double Divider = 300.0; - - [InputParameter("The interval for calculation of percentile", 1, 1, 999, 1, 0)] - public int PercInterval = 100; - - private Indicator si; - - public TestSI() - : base() - { - // Defines indicator's name and description. - Name = "Test SI"; - Description = "Example of using built-in SI indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("Percentile", Color.HotPink, 1, LineStyle.SimpleChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = $"TestSI (" + Divider + ":"+ PercInterval +")"; - - // Get SI indicator from built-in indicator collection. - si = Core.Instance.IndicatorManager.BuiltIn.SI(Divider); - - // Add auxiliary SI indicator to the current one. - AddIndicator(si); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count PercInterval) - return; - - // Get a current SI value. - double siValue = si.GetValue(); - - // Calculate a percentile of current SI value. - var percentile = CalculatePercentile(0, PercInterval, siValue); - - // Set value to "Percentile" line buffer. - SetValue(percentile, 0, 0); - } - - private double CalculatePercentile(int startOffset, int inteval, double value) - { - // Calculate the count of all SI values, - // which are equal or less than the current SI value on an interval. - double count = 0d; - if (inteval 0) - return 0d; - - for (int i = startOffset; i inteval; i++) - { - if (si.GetValue(i) value) - count = count + 1.0; - } - return count / inteval * 100d; - } - } - } - - - The divider. - - - - - - Get the True Strength Index (TSI) indicator. - - The TSI is a variation of the Relative Strength Indicator which uses a doubly-smoothed - EMA of price momentum to eliminate choppy price changes and spot trend changes. - - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestTSI : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("First MA period", 0, 1, 999, 1, 0)] - public int FirstPeriod = 5; - - // Displays Input Parameter as input field. - [InputParameter("Second MA period", 1, 1, 999, 1, 0)] - public int SecondPeriod = 8; - - [InputParameter("The interval for calculation of percentile", 2, 1, 999, 1, 0)] - public int PercInterval = 100; - - private Indicator tsi; - - public TestTSI() - : base() - { - // Defines indicator's name and description. - Name = "Test TSI"; - Description = "Example of using built-in TSI indicator"; - - // Defines line on demand with particular parameters. - AddLineSeries("Percentile", Color.Orange, 1, LineStyle.HistogrammChart); - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestTSI (" + FirstPeriod + ":" + SecondPeriod + ":" + PercInterval + ")"; - - // Get TSI indicator from built-in indicator collection. - tsi = Core.Instance.IndicatorManager.BuiltIn.TSI(FirstPeriod, SecondPeriod); - - // Add auxiliary TSI indicator to the current one. - AddIndicator(tsi); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count PercInterval) - return; - - // Get a current TSI value. - double tsiValue = tsi.GetValue(); - - // Calculate a percentile of current TSI value. - var percentile = CalculatePercentile(0, PercInterval, tsiValue); - - // Set value to "Percentile" line buffer. - SetValue(percentile, 0, 0); - } - - private double CalculatePercentile(int startOffset, int inteval, double value) - { - // Calculate the count of all TSI values, - // which are equal or less than the current TSI value on an interval. - double count = 0d; - if (inteval 0) - return 0d; - - for (int i = startOffset; i inteval; i++) - { - if (tsi.GetValue(i) value) - count = count + 1.0; - } - return count / inteval * 100d; - } - } - } - - - First MA period. - Second MA period. - - - - - - Returns an instance of the Average Directional Index (ADX) indicator. - The ADX determines the strength of a prevailing trend. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// ADX example. - /// ]]> - public class ADX : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period", 0, 1, 999, 0, 0)] - public int Period = 20; - - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - #endregion - - // Holds ADX's values. - private Indicator adx; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public ADX() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "ADX example"; - Description = "ADX example"; - - // Defines line on demand with particular parameters. - AddLineSeries("ADX'Line", Color.Green, 1, LineStyle.SimpleChart); - AddLineSeries("+DI'Line", Color.Blue, 1, LineStyle.SimpleChart); - AddLineSeries("-DI'Line", Color.Red, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "ADX (" + Period.ToString() + ": " + MAType.ToString() + ")"; - // Creates an instance of the proper indicator (ADX) from the default indicators list. - adx = Core.Instance.IndicatorManager.BuiltIn.ADX(Period, MAType); - // Adds an auxiliary (ADX) indicator to the current one (ADX Example). - // This will let inner indicator (ADX) to be calculated in advance to the current one (ADX Example). - AddIndicator(adx); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets values for the displaying on the chart. - for (int i = 0; i adx.LinesSeries.Length; i++) - { - SetValue(adx.GetValue(0,i),0,i); - } - } - } - } - - - Period - Type of Moving Average - - - - - - Returns an instance of the Keltner Channel indicator. - Keltner Channels are volatility-based envelopes set above and below an exponential moving average. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// Keltner example. - /// ]]> - public class Keltner : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Sources prices for MA", 0, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType SourcePrice = PriceType.Close; - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - // Displays Input Parameter as dropdown list. - [InputParameter("Period of MA for Keltner's Channel", 2, 1, 9999, 1)] - public int Period = 5; - - // Displays Input Parameter as dropdown list. - [InputParameter("Coefficient of channel's width", 3, 1, 100)] - public double Offset = 2; - - #endregion - - // Holds Keltner's values. - private Indicator keltner; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public Keltner() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "Keltner example"; - Description = "Keltner example"; - - // Defines line on demand with particular parameters. - AddLineSeries("MA'Line", Color.Coral, 1, LineStyle.SimpleChart); - AddLineSeries("+ATR'Line", Color.Red, 1, LineStyle.SimpleChart); - AddLineSeries("-ATR'Line", Color.Purple, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "Keltner (" + Period.ToString() + ": " + Offset.ToString() + ": " + SourcePrice.ToString() + ": " + MAType.ToString() + ")"; - // Creates an instance of the proper indicator (Keltner) from the default indicators list. - keltner = Core.Instance.IndicatorManager.BuiltIn.Keltner(Period, Offset, SourcePrice, MAType); - // Adds an auxiliary (Keltner) indicator to the current one (Keltner Example). - // This will let inner indicator (Keltner) to be calculated in advance to the current one (Keltner Example). - AddIndicator(keltner); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets values for the displaying on the chart. - for (int i = 0; i keltner.LinesSeries.Length; i++) - { - SetValue(keltner.GetValue(0,i),0,i); - } - } - } - } - - - Period of MA for Keltner's Channel - Coefficient of channel's width - Sources prices for MA - Type of Moving Average - - - - - - Returns an instance of the Percentage Price Oscillator (PPO). - Percentage Price Oscillator is a momentum indicator. Signal line is EMA of PPO. Formula: (FastEMA-SlowEMA)/SlowEMA. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace IndicatorExample - { - /// ]]> - /// PPO example. - /// ]]> - public class PPO : Indicator - { - #region Parameters - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Fast EMA Period", 0)] - public int fastEmaPeriod = 12; - - [InputParameter("Slow EMA Period", 1)] - public int slowEmaPeriod = 26; - - [InputParameter("Signal EMA Period", 2)] - public int signalEmaPeriod = 9; - - #endregion - - // Holds PPO's values. - private Indicator ppo; - - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public PPO() - : base() - { - // Defines indicator's group, name and description. - Group = "Custom"; - Name = "PPO example"; - Description = "PPO example"; - - // Defines line on demand with particular parameters. - AddLineSeries("PPO'Line", Color.SkyBlue, 2, LineStyle.SimpleChart); - AddLineSeries("Signal'Line", Color.Red, 1, LineStyle.SimpleChart); - } - - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) updates. - /// ]]> - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "PPO (" + fastEmaPeriod.ToString() + ": " + slowEmaPeriod.ToString() + ": " + signalEmaPeriod.ToString() + ")"; - // Creates an instance of the proper indicator (PPO) from the default indicators list. - ppo = Core.Instance.IndicatorManager.BuiltIn.PPO(fastEmaPeriod, slowEmaPeriod, signalEmaPeriod); - // Adds an auxiliary (PPO) indicator to the current one (PPO Example). - // This will let inner indicator (PPO) to be calculated in advance to the current one (PPO Example). - AddIndicator(ppo); - } - - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Sets values for the displaying on the chart. - for (int i = 0; i ppo.LinesSeries.Length; i++) - { - SetValue(ppo.GetValue(0,i),0,i); - } - } - } - } - - - Fast EMA Period - Slow EMA Period - Signal EMA Period - - - - - - Gets the Stochastic Slow. - Shows the location of the current close relative to the high/low range over a set number of periods (Slow). - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - namespace Example - { - public class TestStochastic : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Stochastic Period", 0, 1, 999, 1, 0)] - public int Period = 20; - [InputParameter("Smooth Period", 0, 1, 999, 1, 0)] - public int Smooth = 3; - [InputParameter("DoubleSmooth Period", 0, 1, 999, 1, 0)] - public int DoubleSmooth = 6; - #endregion Parameters - - private Indicator Stoch; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestStochastic() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestStochastic"; - Description = "Example of using built-in Stochastic indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("Stochastic", Color.Green, 1, LineStyle.SimpleChart); - AddLineSeries("Stochastic Smoothed", Color.LightSkyBlue, 1, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "TestStochastic " + Period.ToString(); - // Get 'Stochastic' indicator from built-in indicator collection. - Stoch = Core.Instance.IndicatorManager.BuiltIn.Stochastic(Period, Smooth, DoubleSmooth, MaMode.LWMA); - AddIndicator(Stoch); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get values from 'Stoch' indicator lines. - var StochNew = Stoch.GetValue(); - var StochNewMA = Stoch.GetValue(0,1); - SetValue(StochNew); - SetValue(StochNewMA,0,1); - } - } - } - - - Period - Smoothing - Double smoothing - Moving type - - - - - - Gets the Stochastic x Relative Strength Index. - StochRSI is an oscillator that measures the level of RSI relative to its range. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestStochRSI : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Stochastic Period", 0, 1, 999, 1, 0)] - public int Period = 20; - [InputParameter("Smooth Period", 0, 1, 999, 1, 0)] - public int Smooth = 3; - [InputParameter("DoubleSmooth Period", 0, 1, 999, 1, 0)] - public int DoubleSmooth = 6; - #endregion Parameters - - private Indicator StochRSI; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestStochRSI() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestStochasticxRSI"; - Description = "Example of using built-in Stochastic x Relative Strength Index indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("Stochastic", Color.Green, 1, LineStyle.SimpleChart); - AddLineSeries("Stochastic Smoothed", Color.LightSkyBlue, 1, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "StochasticxRSI"+ "("+Period+")"; - // Get 'StochasticxRSI' indicator from built-in indicator collection. - StochRSI = Core.Instance.IndicatorManager.BuiltIn.StochasticxRSI(Period, Smooth, DoubleSmooth); - AddIndicator(StochRSI); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get values from 'StochasticxRSI' indicator lines. - var StochNew = StochRSI.GetValue(); - var StochNewMA = StochRSI.GetValue(0,1); - SetValue(StochNew); - SetValue(StochNewMA,0,1); - } - } - } - - - Period - Smoothing - Double smoothing - - - - - - Gets the Ichimoku. - Enables to quickly discern and filter 'at a glance' the low-probability trading setups from those of higher probability. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestICH : Indicator - { - #region Paramaters - // Defines the 'Period' parameter as input field (where 'min' is 1 and 'max' is 999). - [InputParameter("Tenkan Sen", 0, 1, 999, 1, 0)] - public int TenkanPeriod = 9; - - [InputParameter("Kijun Sen", 1, 1, 999, 1, 0)] - public int KijunPeriod = 26; - - [InputParameter("Senkou Span B", 2, 1, 999, 1, 0)] - public int SenkouSpanB = 52; - #endregion Parameters - - private Indicator ICH; - /// ]]> - ///Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestICH() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestICH"; - Description = "Example of using built-in Ichimoku indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("Tenkan Sen", Color.Green, 1, LineStyle.SimpleChart); - AddLineSeries("Kijun Sen", Color.LightSkyBlue, 1, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "TestICH :Tenkan" + TenkanPeriod.ToString() + " vs Kijun" + KijunPeriod.ToString(); - // Get 'ICH' indicator from built-in indicator collection. - ICH = Core.Instance.IndicatorManager.BuiltIn.ICH(TenkanPeriod, KijunPeriod, SenkouSpanB); - AddIndicator(ICH); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Get values from 'ICH' indicator lines. - var Tenkan = ICH.GetValue(); - var Kijun = ICH.GetValue(0,1); - SetValue(Tenkan); - SetValue(Kijun, 0,1); - } - } - } - - - Tenkan Period - Kijun Period - Senkou Span B - - - - - - Gets the Directional Movement Index(DMI) indicator. - The DMI іdentifies whether there is a definable trend in the market. - - - - using TradingPlatform.BusinessLayer; - - namespace Example - { - public class TestDMI : Indicator - { - // Displays Input Parameter as input field. - [InputParameter("Period of DMI", 0, 1, 999, 1, 0)] - public int Period = 13; - - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Moving Average", 1, new object[] { - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode MAType = MaMode.SMA; - - private Indicator dmi; - - public TestDMI() - : base() - { - // Defines indicator's name and description. - Name = "Test DMI"; - Description = "Example of using built-in DMI indicator"; - Group = "Test"; - } - - public override void Init() - { - // Serves for an identification of related indicators with different parameters. - ShortName = "TestDMI (" + Period + ":" + MAType.ToString() + ")"; - - // Get DMI and two MA indicators from built-in indicator collection. - dmi = Core.Instance.IndicatorManager.BuiltIn.DMI(Period, MAType); - - // Add auxiliary DMI indicator to the current one. - AddIndicator(dmi); - } - - public override void OnUpdate(UpdateArgs args) - { - // Skip all historical bar and start calculation only when a NewBar comes. - if (args.Reason == UpdateReason.HistoricalBar || args.Reason == UpdateReason.NewTick) - return; - - // Skip some period for correct calculation. - if (Count Period) - return; - - // Get "Plus" and "Minus" line values from the DMI indicator. - double plus = dmi.GetValue(0, 0); - double minus = dmi.GetValue(0, 1); - - string upperLineName = string.Empty; - - // Get the name of upper line. - if (plus ]]> minus) - upperLineName = dmi.LinesSeries[0].Name; - else if (plus minus) - upperLineName = dmi.LinesSeries[1].Name; - - // Show the alert window with some info. - Alert("At this moment, the upper line is : " + upperLineName); - } - } - } - - - Period of Moving Average. - Type of Moving Average. - - - - - - Gets the Alligator. - Three moving averages with different colors, periods and calculation methods. - - - - using TradingPlatform.BusinessLayer; - using System.Drawing; - - namespace Example - { - public class TestAlligator : Indicator - { - #region Paramaters - // Displays Input Parameter as dropdown list. - [InputParameter("Type of Jaw Moving Average", 0, new object[]{ - "Simple", MaMode.SMA, - "Exponential", MaMode.EMA, - "Modified", MaMode.SMMA, - "Linear Weighted", MaMode.LWMA} - )] - public MaMode JawMAType = MaMode.SMA; - - [InputParameter("Source price for Jaw Moving Average", 1, new object[] { - "Close", PriceType.Close, - "Open", PriceType.Open, - "High", PriceType.High, - "Low", PriceType.Low, - "Typical", PriceType.Typical, - "Medium", PriceType.Median, - "Weighted", PriceType.Weighted} - )] - public PriceType JawSourcePrice = PriceType.Close; - - // Displays Input Parameter as input field (or checkbox if value type is bolean). - [InputParameter("Period of Jaw Moving Average", 0, 2, 999, 1, 0)] - public int JawMAPeiod = 13; - #endregion Parameters - - private Indicator Alligator; - /// ]]> - /// Indicator's constructor. Contains general information: name, description, LineSeries etc. - /// ]]> - public TestAlligator() - : base() - { - // Serves for an identification of related indicators with different parameters. - Name = "TestAlligator"; - Description = "Example of using built-in Alligator indicator"; - - // Define two lines (on main window) with particular parameters - AddLineSeries("JAW", Color.Green, 1, LineStyle.SimpleChart); - AddLineSeries("LIPS", Color.LightSkyBlue, 1, LineStyle.SimpleChart); - } - /// ]]> - /// This function will be called after creating an indicator as well as after its input params reset or chart (symbolor timeframe) update - /// ]]> - public override void Init() - { - ShortName = "TestAlligator :JawMAPeiod" + JawMAPeiod.ToString(); - // Get 'Alligator' indicator from built-in indicator collection. Reset only jaw params, the rest is by default. - Alligator = Core.Instance.IndicatorManager.BuiltIn.Alligator(JawMAType, JawSourcePrice, JawMAPeiod, 0, MaMode.SMA,PriceType.Close,8,0, MaMode.SMA, PriceType.Close, 5, 0); - AddIndicator(Alligator); - } - /// ]]> - /// Calculation entry point. This function is called when a price data updates. - /// Will be runing under the HistoricalBar mode during history loading. - /// Under NewTick during realtime. - /// Under NewBar if start of the new bar is required. - /// ]]> - /// Provides data of updating reason and incoming price.]]> - public override void OnUpdate(UpdateArgs args) - { - // Get values from 'Alligator' indicator lines. - var Jaw = Alligator.GetValue(); - var Lips = Alligator.GetValue(0,2); - SetValue(Jaw); - SetValue(Lips, 0,1); - } - } - } - - - Type of Jaw Moving Average. - SourcePrice of Jaw Moving Average. - Period of Jaw Moving Average. - Shift of Jaw Moving Average. - Period of Moving Average. - Type of Moving Average. - Period of Moving Average. - Type of Moving Average. - Period of Moving Average. - Type of Moving Average. - Period of Moving Average. - Type of Moving Average. - - - - - - Base class for all indicators. - - - - - Short name of indicator - - - - - Access to current Symbol of indicator - - - - - Amount of items in internal buffers - - - - - Represent access to current used historical data. - - - - - Represent access indicator series - - - - - - - - - - Specified, whether indicator should use main or additional window on the chart - - - - - Specified, whether indicator should draw on chart background by default. - - - - - Precision amount for formatting price (the count of digits after decimal point); By default = -1, which means to use precision from indicator's symbol - - - - - Indicator's settings - - - - - Represent access to the chart, that created indicator - - - - - Recalculate indicator - - - - - - - - - - - Sets the value of indicator into internal buffer - - Value - Index of indicator line - Offset value - - - - Gets the value of indicator from internal buffer - - Offset value - Index of indicator line - Offset start point - - - - - Set line break point. - - Offset value - Index of indicator line - Offset start point - - - - Remove line break point. - - Offset value - Index of indicator line - Offset start point - - - - Check if the point is a break point. - - Offset value - Index of indicator line - Offset start point - - - - Gets the price from historical data - - - - - - - - Get Bid price - - Offset value - - - - - Get Ask price - - Offset value - - - - - Get Last price - - Offset value - - - - - Get Open price - - Offset value - - - - - Get High price - - Offset value - - - - - Get Low price - - Offset value - - - - - Get Close price - - Offset value - - - - - Get Median price - - Offset value - - - - - Get Typical price - - Offset value - - - - - Get Weighted price - - Offset value - - - - - Get Volume - - Offset value - - - - - Formatting price, using precision from assigned symbol or Digits value if specified - - Price value - - - - - Marks cloud begin between two line series with specific color - - First line series index - Second line series index - Cloud color - Offset - - - - Marks cloud end between two line series with specific color - - First line series index - Second line series index - Cloud color - Offset - - - - Using IndicatorLineMarker class you can mark by color or icon any point of your indicator's line. - - - - - Color of the marker - - - - - Icon that will be drawn above the indicator line - - - - - Icon that will be drawn beyond the indicator line - - - - - Constructor for IndicatorLineMarker - - - - - - - - Constructor for IndicatorLineMarker - - - - - Different type of icons for Indicator marker - - - - - Sets the bar number (from the data beginning) from which the drawing of the given indicator line must start; - - - - - Time shift of indicator's line - - - - - Redraws parts of indicator's line within the interval set by offset - - - - - Removes redrawn parts of indicator's line within the interval set by offset - - - - - - - - - - Fully clears markers from line - - - - - Use this attribute to mark input parameters of your script. You will see them in the settings screen on adding - - - - - Displayed name of input parameter - - - - - Sort index for input paramter - - - - - Minimal value for numeric input parameters - - - - - Maximal value for numeric input parameters - - - - - Increment value for numeric input parameters - - - - - Decimal palces for numeric input parameters - - - - - List of predefined values - - - - - Event occurred when write a new log - - - - - Get logs from the strategy for specified date range - - - - - - - - Write log message - - - - - - - The base class for strategies - - - - - Unique ID of the strategy - - - - - The current state of the strategy - - - - - Event occured when strategy write a new log - - - - - Event occured if any of strategy settings was changed - - - - - Run strategy - - - - - Stop strategy - - - - - Remove the strategy - - - - - Get current metrics from the strategy - - - - - - Get logs from the strategy for specified date range - - - - - - - - Write log message - - - - - - - Gets or sets a value indicating whether the event was handled. - true to bypass the control's default handling; otherwise, false to also pass the event along to the default control handler. - - - - - http://burtleburtle.net/bob/hash/doobs.html - - - - - Defines quote parameters for subscribtion - - - - - Symbol Id - - - - - Quote type - - - - - SubscribeQuotesParameters constructor - - - - - Id of the order - - - - - SettingItem cast type - - - - - SettingItem state - - - - - Specifies the DatePicker time format. - - - - - Date only - - - - - Date and time - - - - - Time only - - - - - Time with seconds - - - - - Typecasts setting as TabControl item - - - - - Typecasts setting as GroupBox item - - - - - Typecasts setting as AccountLookup item - - - - - Typecasts setting as Button item - - - - - Typecasts setting as CheckBox item - - - - - Typecasts setting as CheckBox item - - - - - Typecasts setting as Color item - - - - - Typecasts setting as DateTimePicker item - - - - - Typecasts setting as NumericUpDown item - - - - - Typecasts setting as NumericUpDown item - - - - - Typecasts setting as AccountLookup item - - - - - Typecasts setting as Password item - - - - - Typecasts setting as Period item - - - - - Typecasts setting as ComboBox item - - - - - Typecasts setting as TextBox item - - - - - Typecasts setting as SymbolLookup item - - - - - Typecasts setting as TextBox item - - - - - - - - - - Агрегація, що буде використовуватись як дефолтна для "TimeFrameScreen". - Повинна відповідати агрегації чарта. - - - - - Quote type for subscribtion dictum - - - - - Level 1 quote - - - - - Level 2 quote - - - - - Last - - - - - Mark price - - - - - Trading operation state - - - - - Combines intersecting intervals - - - - - Get all settings or particular settings by provided hierarchy path - - - - - Write info log message - - - - - - Write trading log message - - - - - - Write error log message - - - - - - Variable lifetime - - - - - The variable will be removed on exit - - - - - The variable will be written to file - - - - - Global variable entry - - - - - Variable name - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - List<GlobalVariable> global_List=new List<GlobalVariable>(); - - public override void Init() - { - if(GlobalVariablesManager.Count()>0) - { - global_List=GlobalVariablesManager.GetGlobalVariablesList(); - foreach (var el in global_List) - { - Print(el.Name); - Print(el.Value); - } - } - } - } - } - - - - - - - Variable value - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - List<GlobalVariable> global_List=new List<GlobalVariable>(); - public override void Init() - { - if(GlobalVariablesManager.Count()>0) - { - global_List=GlobalVariablesManager.GetGlobalVariablesList(); - foreach (var el in global_List) - { - Print(el.Name); - Print(el.Value); - } - } - } - } - } - - - - - - - Initializes new variable - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - List<GlobalVariable> global_List=new List<GlobalVariable>(); - public override void Init() - { - if(GlobalVariablesManager.Count()>0) - { - global_List=GlobalVariablesManager.GetGlobalVariablesList(); - foreach (var el in global_List) - { - //Simplified way to retrieve global variable value - el.GlobalVariable("new_global_variable_period", period) - - //However, to obtain certain variable, which belongs to indicator/strategy and to avoid unexpected erasing of data the best practice is to provide to a key holder multiple details such as name, params, hashed password etc. Follow SetValue() example. - } - } - } - } - } - - - - Variable name - Variable value - - - - - Sets variable value to a global storage - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - GlobalVariablesManager(){ - base.ProjectName = "GlobalVariablesManager"; - base.Password=GetHashedPassword(ProjectName); - } - - [InputParameter("Period", 0, 1, 9999)] - public int period = 5; - - public override void OnQuote() - { - //Simplified way to store a global variable - - GlobalVariablesManager.SetValue("global_variable_period", period, VariableLifetime.SaveSession); - - //However, to indicate any variable belongs to certain indicator/strategy and to avoid unexpected erasing of data the best practice is to provide to a key holder multiple details such as name, params, hashed password etc. - - GlobalVariablesManager.SetValue("global_variable_period" +Symbols.Current.Name+period+Password, period, VariableLifetime.SaveSession); - } - } - } - - - - Variable name - New value - Variable lifetime - - - - Removes specified variable from global storage - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - public override void Init() - { - //Simplified way to remove a global variable - - GlobalVariablesManager.Remove("global_variable_period"); - - //However, to remove certain variable, which belongs to indicator/strategy and to avoid unexpected erasing of data the best practice is to provide to a key holder multiple details such as name, params, hashed password etc. Follow SetValue() example. - } - } - } - - - - Variable name - - - - Returns variables' count in global storage - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - public override void Init() - { - if(GlobalVariablesManager.Count()>0) - { - Print("Your session obtains "+GlobalVariablesManager.Count()+" global variables"); - } - } - } - } - - - - - - - - Removes all variables from global storage - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - public override void Init() - { - GlobalVariablesManager.RemoveAll(); - - if(GlobalVariablesManager.Count()==0) - { - Print("Your session does not have any global variables"); - } - } - } - } - - - - - - - Check if variable with specified name exists in global storage - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - public override void Init() - { - //Simplified way to check an existance of a global variable - - if(GlobalVariablesManager.Exists("global_variable_period")) - Print("Your session has this global variable"); - else - GlobalVariablesManager.SetValue("global_variable_period"); - - //However, to obtain certain variable, which belongs to indicator/strategy and to avoid unexpected erasing of data the best practice is to provide to a key holder multiple details such as name, params, hashed password etc. Follow SetValue() example. - } - } - } - - - - Variable name - - - - - Returns variable value by name - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - public override void Init() - { - //Simplified way to retrieve global variable value - - if(GlobalVariablesManager.Exists("global_variable_period")) - //Always perform a type casting before assigning any variable from global storage - period = (int)GlobalVariablesManager.GetValue("global_variable_period"); - - //However, to obtain certain variable, which belongs to indicator/strategy and to avoid unexpected erasing of data the best practice is to provide to a key holder multiple details such as name, params, hashed password etc. Follow SetValue() example. - } - } - } - - - - Variable name - Variable value - - - - Performs a variable assigning from a global storage if such name exists in a scope - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - public override void Init() - { - int new_period; - - //Simplified way to retrieve global variable value - - if(GlobalVariablesManager.TryGetValue("global_variable_period")) - Print("New variable is assigned from globals: " + new_period); - if(new_period==period) - Print("Matching, no need to re-assign globals: "); - else - GlobalVariablesManager.SetValue("global_variable_period", period, VariableLifetime.SaveSession); - - //However, to obtain certain variable, which belongs to indicator/strategy and to avoid unexpected erasing of data the best practice is to provide to a key holder multiple details such as name, params, hashed password etc. Follow SetValue() example. - } - } - } - - - - Variable name - Variable value - True if variable exists - - - - Saves all serializable variables to disk - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - Connection myConnection = Connection.CurrentConnection; - public override void OnQuote() - { - if(myConnection.Status==Disconnected) - GlobalVariablesManager.Flush(); - } - } - } - - - - - - - Returns all global variables as list - - - - - using System; - using System.Text; - using PTLRuntime.NETScript; - - namespace GlobalVariablesManager - { - public class GlobalVariablesManager : NETIndicator - { - List <GlobalVariable>global_List=new List<GlobalVariable>(); - public override void Init() - { - if(GlobalVariablesManager.Count()>0) - global_List=GlobalVariablesManager.GetGlobalVariablesList(); - - foreach (var el in global_List) - { - Print(el.Name); - } - } - } - } - - - - Collection of global variables - - - - Object is non-serializable - - - - - Object too big - - - - - Get all available custom resources - - - - - Get custom resource stream by name - - - - - Check whether specified items was hidden by branding specification - - - - - - Current logging level - - - - - Sets logs with custom messag, logging level, connection name - - - - - Sets logs with exception and custom message (optional), logging level, connection name - - - - - Sets logs with objects inherited from ILoggable interface,logging level, connection name - - - - - Sets a log level in case of deep debug - - - - - Remove a log level if one has not needed already - - - - - Все параметры, которые могут использоваться при отправке email - - - - - Отправит сообщение по E-mail - - - - - - - - - - Чисто, як маркер для парсера xgettext.exe - - - - - - - Check, whether current translation equal to hidden - - - - - - - - - - - - - - - - - - - - - - - Allows to save Symbols into named lists - - - - - from: - http://www.codeguru.com/csharp/csharp/cs_date_time/timeroutines/article.php/c4207/C-SNTP-Client.htm - +++ добавлен диспозе, подправлен ToString(), убран лишний метод. - +++ ReceiveTimeoutбSendTimeout - - NTPClient is a C# class designed to connect to time servers on the Internet. - The implementation of the protocol is based on the RFC 2030. - - Public class members: - - LeapIndicator - Warns of an impending leap second to be inserted/deleted in the last - minute of the current day. (See the _LeapIndicator enum) - - VersionNumber - Version number of the protocol (3 or 4). - - Mode - Returns mode. (See the _Mode enum) - - Stratum - Stratum of the clock. (See the _Stratum enum) - - PollInterval - Maximum interval between successive messages. - - Precision - Precision of the clock. - - RootDelay - Round trip time to the primary reference source. - - RootDispersion - Nominal error relative to the primary reference source. - - ReferenceTimestamp - The time at which the clock was last set or corrected. - - OriginateTimestamp - The time at which the request departed the client for the server. - - ReceiveTimestamp - The time at which the request arrived at the server. - - Transmit Timestamp - The time at which the reply departed the server for client. - - RoundTripDelay - The time between the departure of request and arrival of reply. - - LocalClockOffset - The offset of the local clock relative to the primary reference - source. - - Initialize - Sets up data structure and prepares for connection. - - Connect - Connects to the time server and populates the data structure. - - IsResponseValid - Returns true if received data is valid and if comes from - a NTP-compliant time server. - - ToString - Returns a string representation of the object. - - ----------------------------------------------------------------------------- - Structure of the standard NTP header (as described in RFC 2030) - 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - |LI | VN |Mode | Stratum | Poll | Precision | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Root Delay | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Root Dispersion | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Reference Identifier | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - | Reference Timestamp (64) | - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - | Originate Timestamp (64) | - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - | Receive Timestamp (64) | - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - | Transmit Timestamp (64) | - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Key Identifier (optional) (32) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | | - | | - | Message Digest (optional) (128) | - | | - | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - ----------------------------------------------------------------------------- - - NTP Timestamp Format (as described in RFC 2030) - 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Seconds | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Seconds Fraction (0-padded) | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - - - - - Connect to the time server - - - - - метод для определения рассинхнона - - рассинхрон с первым из серверов времени к которому достучались - - - - Defines a trading operation respond bundle - - - - - Respond operation state - - - - - Respond message - - - - - Respond order id - - - - - Provides VA calculation parameters - - - - - Provides VA calculation request per - - - - - Summary calculated Volume info - - - - - Volume info for each price - - - - - Fire in case of price level was added or existing was updated - - - - - Represent item with Volume Analysis calculation results - - - - - Volume Analysis calculations - - - - - Calculate volume profile for requested time range - - - - - Calculate volume profile for each bar in History Data - - - - - Calculate volume profile for requested time range - - - - - Calculate volume profile for each bar in History Data - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Source/Basics/TSeries.cs b/Source/Basics/TSeries.cs index 2fcb13e9..586c31af 100644 --- a/Source/Basics/TSeries.cs +++ b/Source/Basics/TSeries.cs @@ -1,6 +1,5 @@ namespace QuanTAlib; using System; -using System.Linq; /* TSeries is the cornerstone of all QuanTAlib classess. @@ -10,7 +9,6 @@ TSeries is the cornerstone of all QuanTAlib classess. - includes Length property (to mimic array's method) - includes publishing and subscribing methods that attach to events - - uses Linq only for two transmutations - needs to be refactored out eventually (for speed) */ public class TSeries : System.Collections.Generic.List<(DateTime t, double v)> @@ -23,12 +21,22 @@ public class TSeries : System.Collections.Generic.List<(DateTime t, double v)> // when asked for a (DateTime), return the DateTime part of the last tuple on the list public static implicit operator DateTime(TSeries l) => l[l.Count - 1].t; + + //convert from tuple List(t,v) to single List(DateTime) + public System.Collections.Generic.List t { + get { System.Collections.Generic.List TList = new(); + for (int i = 0; i < this.Count; i++) { TList.Add(this[i].t); } + return TList; + } + } - public System.Collections.Generic.List t => - this.Select(x => (DateTime)x.t).ToList(); - - public System.Collections.Generic.List v => - this.Select(x => (double)x.v).ToList(); + //convert from tuple List(t,v) to single List(double) + public System.Collections.Generic.List v { + get { System.Collections.Generic.List VList = new(); + for (int i = 0; i < this.Count; i++) { VList.Add(this[i].v); } + return VList; + } + } public int Length => this.Count; diff --git a/Source/Indicators/JMA_Series.cs b/Source/Indicators/JMA_Series.cs index 2cf373b9..4a9068c2 100644 --- a/Source/Indicators/JMA_Series.cs +++ b/Source/Indicators/JMA_Series.cs @@ -27,8 +27,7 @@ public class JMA_Series : Single_TSeries_Indicator private double prev_ma1, prev_det0, prev_det1, prev_jma, bsmax, bsmin; private double o_prev_ma1, o_prev_det0, o_prev_det1, o_prev_jma, o_bsmax, o_bsmin; - private readonly double pr, pow1, len2, beta, rvolty; - private readonly int _l; + private readonly double pr, pow1, len2, beta, rvolty, _l; public JMA_Series(TSeries source, int period, double phase = 0.0, bool useNaN = false) : base(source, period, useNaN) { @@ -47,11 +46,11 @@ public class JMA_Series : Single_TSeries_Indicator if (base._data.Count > 0) { base.Add(base._data); } } - public override void Add((System.DateTime t, double v) d, bool update) + public override void Add((System.DateTime t, double v) TValue, bool update) { if (this.Count == 0) { - this.prev_ma1 = this.prev_jma = d.v; + this.prev_ma1 = this.prev_jma = TValue.v; this.bsmax = this.bsmin = this.prev_det0 = this.prev_det1 = 0; } @@ -74,8 +73,8 @@ public class JMA_Series : Single_TSeries_Indicator this.o_bsmin = this.bsmin; } - double hprice = d.v; - double lprice = d.v; + double hprice = TValue.v; + double lprice = TValue.v; for (int i = 0; i <= Math.Min(9, this._data.Count - 1); i++) { var _item = this._data[this._data.Count - 1 - i].v; @@ -139,11 +138,11 @@ public class JMA_Series : Single_TSeries_Indicator double alpha = Math.Pow(this.beta, pow); // 1st stage - preliminary smoothing by adaptive EMA - double ma1 = d.v * (1 - alpha) + this.prev_ma1 * alpha; + double ma1 = TValue.v * (1 - alpha) + this.prev_ma1 * alpha; this.prev_ma1 = ma1; // 2nd stage - one more preliminary smoothing by Kalman filter - double det0 = (d.v - ma1) * (1 - this.beta) + this.prev_det0 * this.beta; + double det0 = (TValue.v - ma1) * (1 - this.beta) + this.prev_det0 * this.beta; this.prev_det0 = det0; double ma2 = ma1 + (this.pr * det0); @@ -155,7 +154,7 @@ public class JMA_Series : Single_TSeries_Indicator this.prev_jma = jma; (System.DateTime t, double v) result = - (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : jma); + (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : jma); base.Add(result, update); }