diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
index 27ae0e75..00000000
--- a/.editorconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-# Top-most EditorConfig file
-root = true
-
-[*.{cs,vb}]
-# Suppress S3776 (Cognitive Complexity)
-dotnet_diagnostic.S3776.severity = none
-# Suppress CA1416 (Platform Compatibility)
-dotnet_diagnostic.CA1416.severity = none
\ No newline at end of file
diff --git a/.github/TradingPlatform.BusinessLayer-Miha’s MacBook Pro.dll b/.github/TradingPlatform.BusinessLayer-Miha’s MacBook Pro.dll
deleted file mode 100644
index 11c3b4e3..00000000
Binary files a/.github/TradingPlatform.BusinessLayer-Miha’s MacBook Pro.dll and /dev/null differ
diff --git a/.github/TradingPlatform.BusinessLayer.dll b/.github/TradingPlatform.BusinessLayer.dll
index 704cc7ff..0a324bcb 100644
Binary files a/.github/TradingPlatform.BusinessLayer.dll and b/.github/TradingPlatform.BusinessLayer.dll differ
diff --git a/.github/TradingPlatform.BusinessLayer.xml b/.github/TradingPlatform.BusinessLayer.xml
new file mode 100644
index 00000000..47ebf0f0
--- /dev/null
+++ b/.github/TradingPlatform.BusinessLayer.xml
@@ -0,0 +1,6610 @@
+
+
+
+ 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 account 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 drawingsCollection
+
+
+
+
+ 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
+
+
+
+
+ The SettingsChanged event occurs when any settings were changed
+
+
+
+
+ The AccountChanged event occurs when the account was changed
+
+
+
+
+ Access to the chart drawingsCollection collection
+
+
+
+
+ Add chart drawing to the collection
+
+
+
+
+
+ Remove specified chart drawing from collection
+
+
+
+
+
+ Get chart drawing by ID
+
+
+
+
+
+
+ Get all chart drawingsCollection 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
+
+
+
+
+ Gets Positions list
+
+
+
+
+ Gets Closed Positions list
+
+
+
+
+ Gets Corporate Actions list
+
+
+
+
+ Gets Report Types list
+
+
+
+
+ Gets s list
+
+
+
+
+ Vendor connection respond bundle
+
+
+
+
+ The connection status
+
+
+
+
+ The respond message
+
+
+
+
+ Ping state dictum
+
+
+
+
+ Ping signals connected
+
+
+
+
+ Ping signals disconnected
+
+
+
+
+ The asset formatting description.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The asset id.
+ The value.
+ If true, add currency name.
+
+
+
+ Mediates a history meta data with available data types and intervals on vendor side
+
+
+
+
+ History data types
+
+
+
+
+ History intervals
+
+
+
+
+ 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 non fixed 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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Get VWAP value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Снапшот для эмулятора
+
+
+
+
+ Текущая версия для сериализации. Если что-то меняем и нужно делать поддержку старого формата
+ можно использовать версию.
+
+
+
+
+ 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.
+
+
+
+
+
+ The account operation.
+
+
+
+
+ Gets the name.
+
+
+
+
+ Gets the button text.
+
+
+
+
+ Gets the settings.
+
+
+
+
+
+
+ The settings.
+
+
+
+ Builds the confirmation.
+
+ The settings.
+ A string.
+
+
+
+
+
+ The settings.
+
+
+
+ Compare to.
+
+ The obj.
+ An int.
+
+
+
+ The additional info collection.
+
+
+
+
+ Gets the count.
+
+
+
+
+ Gets the items.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The items.
+
+
+
+ Try get item.
+
+ The api key.
+ The item.
+ A bool.
+
+
+
+ Gets the enumerator.
+
+ ]]>
+
+
+
+ Tos the string.
+
+ A string.
+
+
+
+ The comparing type.
+
+
+
+
+ The additional info item formating type.
+
+
+
+
+ The additional info item.
+
+
+
+
+ ключ для апи, обязательно для заполнения и должен быть уникальным
+
+
+
+
+ Gets or Sets the group info.
+
+
+
+
+ Gets or Sets the sort index.
+
+
+
+
+ Gets or Sets the name key.
+
+
+
+
+ Gets or Sets the tool tip key.
+
+
+
+
+ Gets or Sets the data type.
+
+
+
+
+ Gets or Sets the value.
+
+
+
+
+ Gets or Sets a value indicating whether hidden.
+
+
+
+
+ Gets or Sets the formating type.
+
+
+
+
+ используется в связке с AccountAdditionalInfoItemFormatingType.CustomAsset для форматирования в заданном ассете
+
+
+
+
+ Gets or Sets a value indicating whether visible.
+
+
+
+
+ Gets or Sets a value indicating whether is link.
+
+
+
+
+ Gets or Sets the editing info.
+
+
+
+
+ Gets or Sets the formatting description.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+
+
+ The item.
+
+
+
+
+
+ An object.
+
+
+
+ To the XML element.
+
+ A XElement.
+
+
+
+ From the XML element.
+
+ The element.
+ The deserialization info.
+
+
+
+ To the string.
+
+ A string.
+
+
+
+ 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.
+
+
+
+
+ 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
+
+
+
+
+ Gets Exchange id 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 derivative underlier symbol id
+
+
+
+
+ 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 quote asset 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
+
+
+
+
+ List of all available history types
+
+
+
+
+ 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
+
+
+
+
+ The symbols list manager.
+
+
+
+
+ Gets the count.
+
+
+
+
+ Gets or Sets the settings.
+
+
+
+
+ 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
+
+
+
+
+ Gets all Positions which are belong to this connection
+
+
+
+
+ Gets all Closed Positions 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 Account operations which are available on this connection
+
+
+
+
+ Gets all Tradins signals 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 access 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
+
+
+
+
+ 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. Otherwise returns empty list
+ >
+
+
+
+ Gets all available s from open connections. Otherwise returns empty list
+ >
+
+
+
+ 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
+
+
+
+
+ Gets collection of by given parameters
+
+
+
+
+
+
+
+ Gets collection of by given parameters and callback
+
+
+
+
+
+
+
+
+ Will be triggered when new occured
+
+
+
+
+ Will be triggered when new added
+
+
+
+
+ Gets collection of by given parameters
+
+
+
+
+
+
+
+ Places with given request parameters
+
+
+
+
+
+
+ Places multiple s 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
+
+
+
+
+
+ Will be triggered when created/chenged/removed
+
+
+
+
+ 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
+
+
+
+
+ Gets array of attached indicators
+
+
+
+
+ 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,
+
+
+
+
+
+
+ Creates HistoryItemLast instance
+
+
+
+
+ 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,
+
+
+
+
+
+
+ Creates HistoryItemLast instance
+
+
+
+
+ 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
+
+
+
+
+
+
+ Compares by
+
+
+
+
+
+
+ Serialize into object
+
+
+
+
+
+ Deserialize from
+
+
+
+
+
+
+ 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
+
+
+
+
+ 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
+
+
+
+
+ The loopback http listener without kestrel.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The port.
+
+
+
+ Dispose
+
+
+
+
+ Wait for callback asynchronously.
+
+ The token.
+ ]]>
+
+
+
+ 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.
+
+ Period of Exponential Moving Average
+ Sources prices for MA
+ Calculation type
+
+
+
+ Gets the Linearly Weighted Moving Average
+ Linear Weighted Moving Average makes the most recent bar more important unlike SMA.
+
+ 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.
+
+ 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.
+
+ Moving average period
+ Type of the price
+ Calculation type
+
+
+
+
+ Gets the PPMA(Pivot Point Moving Average) indicator.
+ The 'PPMA' indicator uses the pivot point calculation as the input a simple moving average.
+
+ Period of PPMA indicator
+
+
+
+
+
+ Gets the MAS3 (3MASignal) indicator.
+ The 'MAS3' indicator offers buy and sell signals according to intersections of three moving averages.
+
+ 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'.
+
+ Period of moving average.
+ Type of price.
+ MA mode.
+ Calculation type
+
+
+
+
+
+ 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.
+
+ Period of MA for envelopes.
+ Value of confidence interval.
+ Sources prices for MA.
+ Type of moving average.
+ Calculation type
+
+
+
+
+ Gets the Commodity Channel Index.
+ Measures the position of price in relation to its moving average.
+
+ Period for CCI MA
+ Sources prices for CCI
+ MA mode for CCI
+ Calculation type
+
+
+
+
+ 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.
+
+ 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.
+
+ 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.
+
+ 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
+
+ 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.
+
+ RSI Period
+ Price Type
+ RSI Mode (Simple or Exponential)
+ MA Mode for smooth data
+ MA period for smooth data
+ Calculation type
+
+
+
+
+ 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.
+
+ Period of exponential moving average
+ Dynamic tracking factor
+ Source price type
+ Calculation type
+
+
+
+
+ Gets the MAE (Moving Average Envelope) indicator.
+ The 'MAE' indicator demonstrates a range of the prices discrepancy from a Moving Average.
+
+ Period of MA for envelopes.
+ Sources prices for MA.
+ Type of moving average.
+ Upband deviation in %.
+ Downband deviation in %.
+ Calculation type
+
+
+
+
+ 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.
+
+ Step of parabolic SAR system
+ Maximum value for the acceleration factor
+
+
+
+
+
+ Gets the AO (Awesome Oscillator) indicator.
+ The 'AO' indicator determines market momentum.
+
+
+
+
+
+ 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.
+
+ 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.
+
+ Percent Deviation
+
+
+
+
+
+ Gets the Aroon indicator.
+ Reveals the beginning of a new trend and determines how strong it is
+
+ Aroons period
+
+
+
+
+
+ Returns an instance of the Standart Deviation (SD) indicator.
+ The SD shows the difference of the volatility value from the average one.
+
+ Period of indicator
+ Sources prices for MA
+ Type of Moving Average
+ Calculation type
+
+
+
+
+ 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.
+
+ Period of fast EMA.
+ Period of slow EMA.
+ Period of signal EMA.
+ Calculation type
+
+
+
+
+ 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.
+
+
+
+
+
+
+
+ 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.
+
+ Period
+ Deviation
+ Sources prices for MA
+ Type of Moving Average
+ Calculation type
+
+
+
+
+ Gets the ROC (Rate of Change) indicator.
+ The ROC shows the speed at which price is changing.
+
+ Period of momentum.
+
+
+
+
+
+ Gets the Momentum indicator.
+ Momentum compares where the current price is in relation to where the price was in the past.
+
+ Period for Momentum
+ Sources prices for Momentum
+
+
+
+
+
+ Gets the %R Larry Williams.
+ Uses Stochastic to determine overbought and oversold levels.
+
+ Period for Momentum
+
+
+
+
+
+ Returns an instance of the Price Oscillator (PO) indicator.
+ PO calculates the variation between price moving averages.
+
+ Period of MA1
+ Period of MA2
+ Sources prices for MA
+ Type of Moving Average
+ Calculation type
+
+
+
+
+ Gets the OsMA (Moving Average of Oscillator) indicator.
+ The OsMA reflects the difference between an oscillator (MACD) and its moving average (signal line).
+
+ Period of fast EMA.
+ Period of slow EMA.
+ Period of signal EMA.
+ Calculation type
+
+
+
+
+ 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.
+
+ 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.
+
+
+
+
+
+
+
+ Returns an instance of the Volume indicator.
+ Volume allows to confirm the strength of a trend or to suggest about it's weakness.
+
+
+
+
+
+
+ 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.
+
+ Period of MFI.
+
+
+
+
+
+ Returns an instance of the Acceleration/Deceleration Oscillator (AC).
+ AC measures the acceleration and deceleration of the current momentum.
+
+
+
+
+
+
+ Gets the Average True Range (ATR) indicator.
+ The ATR measures of market volatility.
+
+
+ Period of Moving Average.
+ Type of Moving Average
+ Calculation type
+
+
+
+
+ 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.
+
+ Period
+ Fast factor
+ Slow factor
+ Sources prices for MA
+
+
+
+
+
+ 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.
+
+
+
+ Calculation type
+
+
+
+
+ Get the Swing Index (SI) indicator.
+ The SI is used to confirm trend line breakouts on price charts.
+
+ 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.
+
+
+ First MA period.
+ Second MA period.
+ Calculation type
+
+
+
+
+ Returns an instance of the Average Directional Index (ADX) indicator.
+ The ADX determines the strength of a prevailing trend.
+
+ Period
+ Type of Moving Average
+ Calculation type
+
+
+
+
+ Returns an instance of the Keltner Channel indicator.
+ Keltner Channels are volatility-based envelopes set above and below an exponential moving average.
+
+ Period of MA for Keltner's Channel
+ Coefficient of channel's width
+ Sources prices for MA
+ Type of Moving Average
+ Calculation type
+
+
+
+
+ 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.
+
+ Fast EMA Period
+ Slow EMA Period
+ Signal EMA Period
+ Calculation type
+
+
+
+
+ Gets the Stochastic Slow.
+ Shows the location of the current close relative to the high/low range over a set number of periods (Slow).
+
+ Period
+ Smoothing
+ Double smoothing
+ Moving type
+ Calculation type
+
+
+
+
+ Gets the Stochastic x Relative Strength Index.
+ StochRSI is an oscillator that measures the level of RSI relative to its range.
+
+ 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.
+
+ 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.
+
+ Period of Moving Average.
+ Type of Moving Average.
+ Calculation type
+
+
+
+
+ Gets the Alligator.
+ Three moving averages with different colors, periods and calculation methods.
+
+ 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.
+
+
+
+
+ Specified, whether indicator should participate into price auto scale system.
+
+
+
+
+ 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
+
+
+
+
+ Get Volume in quoting asset
+
+ Offset value
+
+
+
+
+ Get Ticks
+
+ Offset value
+
+
+
+
+ Get Open interest
+
+ Offset value
+
+
+
+
+ Get Funding rate
+
+ Offset value
+
+
+
+
+ Get Time
+
+ 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
+
+
+
+
+
+
+ Specifies constants that define which mouse button was pressed.
+
+
+
+
+ No mouse button was pressed.
+
+
+
+
+ The left mouse button was pressed.
+
+
+
+
+ The right mouse button was pressed.
+
+
+
+
+ The middle mouse button was pressed.
+
+
+
+
+ The first XButton was pressed.
+
+
+
+
+ The second XButton was pressed.
+
+
+
+
+ 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.
+
+
+
+
+ Defines quote parameters for subscribtion
+
+
+
+
+ Symbol Id
+
+
+
+
+ Quote type
+
+
+
+
+ SubscribeQuotesParameters constructor
+
+
+
+
+ Id of the order
+
+
+
+
+ Gets or Sets the groups.
+
+
+
+
+ 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
+
+
+
+
+ Cancel all pending s
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by and
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by and
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by , and
+
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by and
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by , and
+
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by and
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by , and
+
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all pending s by
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Close all s
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all s by and
+
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all s by and
+
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all positive s
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all positive s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all negative s
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Close all negative s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Reverse all s
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Reverse all s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Reverse all s by
+
+
+ the name of the initiator of the call (optional)
+ List of
+
+
+
+ Reverse by and
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+
+ Cancel all s and close all s
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all s and close all s by
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Cancel all s and close all s by and
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Modify SL to breakeven price
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Modify SL to breakeven price with certain additional offset
+
+
+ offset in ticks
+ the name of the initiator of the call (optional)
+
+
+
+ Modify SL to breakeven price
+
+
+ list of s that will be used for order placing
+ the name of the initiator of the call (optional)
+
+
+
+ Adjust SL/TP for given
+
+
+
+ the name of the initiator of the call (optional)
+
+
+
+ Adjust stop loss for given
+
+
+ list of s
+ initial stop loss parameters (optional)
+
+ the name of the initiator of the call (optional)
+
+
+
+
+ Adjust take profit for given
+
+
+ list of s
+ initial take profit parameters (optional)
+
+ the name of the initiator of the call (optional)
+
+
+
+
+ The allowed result.
+
+
+
+
+ Gets the status.
+
+
+
+
+ Gets the reason.
+
+
+
+
+ Get the allowed result.
+
+ An AllowedResult.
+
+
+
+ Gets the not allowed result.
+
+ The reason.
+ An AllowedResult.
+
+
+
+ The action wrapper.
+
+
+
+
+ Gets or Sets the items.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Froms the X element.
+
+ The element.
+ The deserialization info.
+
+
+
+ Tos the X element.
+
+ A XElement.
+
+
+
+ The aggressor flag calculator.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Collect bid ask.
+
+ The symbol.
+ The time ticks.
+ The bid.
+ The ask.
+
+
+
+ Calculate aggressor flag.
+
+ The symbol.
+ The time ticks.
+ The last.
+ An AggressorFlag.
+
+
+
+
+
+
+
+
+ Calculate aggressor flag.
+
+ The previous bid.
+ The previous ask.
+ The last.
+ An AggressorFlag.
+
+
+
+ The alert.
+
+
+
+
+ Gets or Sets the text.
+
+
+
+
+ Gets or Sets the symbol name.
+
+
+
+
+ Gets or Sets the connection name.
+
+
+
+
+ Gets or Sets the action on confirm.
+
+
+
+
+ Gets or Sets the name.
+
+
+
+
+ The alert data.
+
+
+
+
+ The name.
+
+
+
+
+ Gets or Sets the columns.
+
+
+
+
+ Gets or Sets the groups.
+
+
+
+
+ Gets or Sets the actions.
+
+
+
+
+ Gets or Sets a value indicating whether enabled.
+
+
+
+
+ Gets or Sets the table dictionary.
+
+
+
+
+ Gets or Sets a value indicating whether coloring is alert.
+
+
+
+
+ Gets or Sets a value indicating whether filter alert.
+
+
+
+
+ Gets or Sets a value indicating whether search alert.
+
+
+
+
+ Gets or Sets a value indicating whether to remove.
+
+
+
+
+ Gets or Sets the ID.
+
+
+
+
+ Gets or Sets the command sender.
+
+
+
+
+ Gets or Sets a value indicating whether need confirm trading.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ To the XML element.
+
+ A XElement.
+
+
+
+ From the XML element.
+
+ The element.
+ The deserialization info.
+
+
+
+ The arbitrage symbol.
+
+
+
+
+ Gets or Sets the index.
+
+
+
+
+ Gets the unique ID.
+
+
+
+
+ Gets the symbol id.
+
+
+
+
+ Gets or Sets a value indicating whether is selected.
+
+
+
+
+ Gets or Sets the symbol.
+
+
+
+
+ Gets or Sets the account.
+
+
+
+
+ Gets or Sets the commission.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Compare to.
+
+ The other.
+ An int.
+
+
+
+ Froms the X element.
+
+ The element.
+ The deserialization info.
+
+
+
+ Tos the X element.
+
+ A XElement.
+
+
+
+ The action buffered processor.
+
+
+
+
+ The action buffered processor with priority.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The threads count.
+
+
+
+ The buffered processor.
+
+
+
+
+
+ Gets the state.
+
+
+
+
+ Gets the queue depth.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The subject.
+
+
+
+ Wait all messages process.
+
+ The external token.
+
+
+
+ The buffered processor state.
+
+
+
+
+
+
+
+
+
+ Агрегація, що буде використовуватись як дефолтна для "TimeFrameScreen".
+ Повинна відповідати агрегації чарта.
+
+
+
+
+ https://stackoverflow.com/questions/3060381/datetime-addmonths-adding-only-month-not-days
+
+ Проблема:
+ (29 Feb).AddMonth(1) = 29 March
+
+
+
+
+ Defines advanced trading operation respond bundle
+
+
+
+
+ Respond operation state
+
+
+
+
+ Respond message
+
+
+
+
+ Respond value (optional)
+
+
+
+
+ Details of sub-operations
+
+
+
+
+ Get all available custom resources
+
+
+
+
+ Get custom resource stream by name
+
+
+
+
+ Check whether specified items was hidden by branding specification
+
+
+
+
+
+ The assembly loader.
+
+
+
+
+ Load types.
+
+ The folder name.
+ The target type.
+ The assembly name filter.
+ The search option.
+ If true, load in memory.
+ If true, allow loading references.
+ ]]>
+
+
+
+ Quote type for subscribtion dictum
+
+
+
+
+ Level 1 quote
+
+
+
+
+ Level 2 quote
+
+
+
+
+ Last
+
+
+
+
+ Mark price
+
+
+
+
+ Trading operation state
+
+
+
+
+ Complex trading operation state
+
+
+
+
+ The aggressor flag calculator extensions.
+
+
+
+
+ Collect bid ask.
+
+ The calculator.
+ The quote.
+
+
+
+ Calculate aggressor flag.
+
+ The calculator.
+ The last.
+ An AggressorFlag.
+
+
+
+ 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
+
+
+
+
+ Get Volume in quoting asset
+
+ Offset value
+
+
+
+
+ Get Ticks
+
+ Offset value
+
+
+
+
+ Get Open interest
+
+ Offset value
+
+
+
+
+ Get Funding rate
+
+ Offset value
+
+
+
+
+ Get Time
+
+ Offset value
+
+
+
+
+ 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
+
+
+
+
+ The application logger event.
+
+
+
+
+ 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/.github/workflows/main_automation.yml b/.github/workflows/main_automation.yml
index 2130d485..e45f7eb5 100644
--- a/.github/workflows/main_automation.yml
+++ b/.github/workflows/main_automation.yml
@@ -3,10 +3,10 @@ on:
workflow_dispatch:
push:
branches:
- - '*'
+ - main
pull_request:
branches:
- - '*'
+ - main
jobs:
build_test:
@@ -45,17 +45,6 @@ jobs:
#configFilePath: GitVersion.yml
updateAssemblyInfo: true
-############## Install Python
-
- - name: Install pandas-ta
- run: |
- sudo apt install python3.10
- sudo apt install python3.10-dev
- pip3 install numpy
- pip3 install pandas
- pip3 install pandas-ta
- python --version
-
############## Install more tools
- name: Install JDK11 for Sonar Scanner
@@ -84,21 +73,23 @@ jobs:
- name: Build Main branch of QuanTAlib DLL
if: ${{ github.ref != 'refs/heads/dev' }}
- run: dotnet build ./Calculations/Calculations.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.MajorMinorPatch }}
+ run: dotnet build ./lib/quantalib.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.MajorMinorPatch }}
- name: Build dev branch of QuanTAlib DLL
if: ${{ github.ref == 'refs/heads/dev' }}
- run: dotnet build ./Calculations/Calculations.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.FullSemVer }}
- - name: Build Indicators DLL
- run: dotnet build ./Indicators/Indicators.csproj --configuration Release --nologo
- - name: Build Strategies DLL
- run: dotnet build ./Strategies/Strategies.csproj --configuration Release --nologo
+ run: dotnet build ./lib/quantalib.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.FullSemVer }}
+ - name: Build Averages DLL
+ run: dotnet build ./quantower/Averages/Averages.csproj --configuration Release --nologo
+ - name: Build Statistics DLL
+ run: dotnet build ./quantower/Statistics/Statistics.csproj --configuration Release --nologo
+ - name: Build SyntheticVendor DLL
+ run: dotnet build ./SyntheticVendor/SyntheticVendor.csproj --configuration Release --nologo
- name: DotCover Test HTML
if: ${{ github.ref == 'refs/heads/dev' }}
- run: dotnet dotcover test Tests/Tests.csproj --dcReportType=HTML --dcoutput=./dotcover.html
+ run: dotnet dotcover test tests/tests.csproj --dcReportType=HTML --dcoutput=./dotcover.html
- name: DotCover Test XML
if: ${{ github.ref == 'refs/heads/dev' }}
- run: dotnet dotcover test Tests/Tests.csproj --dcReportType=DetailedXML --dcoutput=./dotcover.xml --verbosity=Detailed
+ run: dotnet dotcover test tests/tests.csproj --dcReportType=DetailedXML --dcoutput=./dotcover.xml --verbosity=Detailed
- name: Coverlet Test
if: ${{ github.ref == 'refs/heads/dev' }}
run: dotnet test -p:CollectCoverage=true --collect:"XPlat Code Coverage" --results-directory "./"
@@ -145,12 +136,13 @@ jobs:
release_name: ${{ steps.gitversion.outputs.SemVer }}
tag_name: prerelease
release_config: |
- Calculations/bin/Release/net6.0/QuanTAlib.dll
- Indicators/bin/Release/QuanTAlib_Indicators.dll
- Strategies/bin/Release/QuanTAlib_Strategies.dll
+ lib/bin/Release/QuanTAlib.dll
+ quantower/Averages/bin/Release/Averages.dll
+ quantower/Statistics/bin/Release/Statistics.dll
+ SyntheticVendor/bin/Release/SyntheticVendor.dll
- name: Push package to myget.org
- run: dotnet nuget push 'Calculations/bin/Release/QuanTAlib.*.nupkg'
+ run: dotnet nuget push 'lib/bin/Release/QuanTAlib.*.nupkg'
--api-key ${{ secrets.MYGET_DEPLOY_KEY_QUANTALIB }}
--source https://www.myget.org/F/quantalib/api/v2/package
--skip-duplicate
@@ -168,13 +160,14 @@ jobs:
release_name: ${{ steps.gitversion.outputs.MajorMinorPatch }}
tag_name: latest
release_config: |
- Calculations/bin/Release/net6.0/QuanTAlib.dll
- Indicators/bin/Release/QuanTAlib_Indicators.dll
- Strategies/bin/Release/QuanTAlib_Strategies.dll
+ lib/bin/Release/QuanTAlib.dll
+ quantower/Averages/bin/Release/Averages.dll
+ quantower/Statistics/bin/Release/Statistics.dll
+ SyntheticVendor/bin/Release/SyntheticVendor.dll
- name: Push package to nuget.org
if: ${{ github.ref == 'refs/heads/main' }}
- run: dotnet nuget push 'Calculations/bin/Release/QuanTAlib.*.nupkg'
+ run: dotnet nuget push 'lib/bin/Release/QuanTAlib.*.nupkg'
--api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate
diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
new file mode 100644
index 00000000..93975f32
--- /dev/null
+++ b/.github/workflows/sonarcloud.yml
@@ -0,0 +1,30 @@
+name: SonarCloud analysis
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+
+permissions:
+ pull-requests: read # allows SonarCloud to decorate PRs with analysis results
+
+jobs:
+ Analysis:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
+
+ - name: Analyze with SonarCloud
+ uses: SonarSource/sonarcloud-github-action@v2.0.2
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN
+ with:
+ # Additional arguments for the SonarScanner CLI
+ args: >
+ -Dsonar.projectKey=mihakralj_QuanTAlib
+ -Dsonar.organization=mihakralj
+ -Dsonar.sources=.
+ -Dsonar.verbose=false
diff --git a/.gitignore b/.gitignore
index 9413e591..dc4496da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
@@ -9,12 +9,6 @@
*.user
*.userosscache
*.sln.docstates
-.vscode/
-.fleet/
-*.deps.json
-.Sandbox/
-#.sonarlint/
-.DS_Store
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
@@ -29,6 +23,7 @@ mono_crash.*
[Rr]eleases/
x64/
x86/
+[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
@@ -67,6 +62,9 @@ project.lock.json
project.fragment.lock.json
artifacts/
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
# StyleCop
StyleCopReport.xml
@@ -92,6 +90,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
+*.tlog
*.vspscc
*.vssscc
.builds
@@ -143,6 +142,11 @@ _TeamCity*
.axoCover/*
!.axoCover/settings.json
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
# Visual Studio code coverage results
*.coverage
*.coveragexml
@@ -290,6 +294,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@@ -346,6 +361,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
+# Visual Studio History (VSHistory) files
+.vshistory/
+
# BeatPulse healthcheck temp database
healthchecksdb
@@ -354,5 +372,27 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
-dotCover.Output.dcvr
-/Tests/GlobalSuppressions.cs
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
\ No newline at end of file
diff --git a/.refactoring/base.cs b/.refactoring/base.cs
deleted file mode 100644
index e3e84b86..00000000
--- a/.refactoring/base.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-
-public struct TValue
-{
- public DateTime Timestamp { get; set; }
- public double Value { get; set; }
-
- public TValue(DateTime timestamp, double value)
- {
- Timestamp = timestamp;
- Value = value;
- }
-
- public override string ToString()
- {
- return $"[{this.Timestamp:yyyy-MM-dd HH:mm:ss}: {this.Value:F2}]";
- }
- public override bool Equals(object obj)
- {
- if (obj is TValue other)
- {
- return Timestamp == other.Timestamp && Value == other.Value;
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- return HashCode.Combine(Timestamp, Value);
- }
-}
-
-
-public struct TBar
-{
- public DateTime Timestamp { get; set; }
- public double Open { get; set; }
- public double High { get; set; }
- public double Low { get; set; }
- public double Close { get; set; }
- public double Volume { get; set; }
-
- public TBar(DateTime timestamp, double open, double high, double low, double close, double volume)
- {
- Timestamp = timestamp;
- Open = open;
- High = high;
- Low = low;
- Close = close;
- Volume = volume;
- }
-
- public override string ToString()
- {
- return $"[{this.Timestamp:yyyy-MM-dd HH:mm:ss}: O={this.Open:F2}, H={this.High:F2}, L={this.Low:F2}, C={this.Close:F2}, V={this.Volume:F2}]";
- }
-
- public override bool Equals(object obj)
- {
- if (obj is TBar other)
- {
- return Timestamp == other.Timestamp &&
- Open == other.Open &&
- High == other.High &&
- Low == other.Low &&
- Close == other.Close &&
- Volume == other.Volume;
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- return HashCode.Combine(Timestamp, Open, High, Low, Close, Volume);
- }
-}
-
-
-
-public class TValueEventArg : EventArgs
-{
- public T Data { get; }
- public bool IsClosed { get; }
- public bool IsHot { get; }
-
- public TValueEventArg(T data, bool isClosed, bool isHot)
- {
- Data = data;
- IsClosed = isClosed;
- IsHot = isHot;
- }
-}
\ No newline at end of file
diff --git a/.refactoring/test.dib b/.refactoring/test.dib
deleted file mode 100644
index 6c442688..00000000
--- a/.refactoring/test.dib
+++ /dev/null
@@ -1,92 +0,0 @@
-#!meta
-
-{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"name":"csharp"}]}}
-
-#!csharp
-
-#load "./base.cs"
-
-#!csharp
-
-TValue vv = new(DateTime.Now, 100);
-display(vv.ToString());
-
-#!csharp
-
-TBar bb = new();
-display(bb.ToString());
-
-#!csharp
-
-public class Emitter {
- private Random random = new Random();
- public event EventHandler> Pub;
- public void Emit() {
- DateTime now = DateTime.Now;
- double randomValue = random.NextDouble() * 100; // Generates a random number between 0 and 100
- TValue value = new TValue(now, randomValue);
-
- TValueEventArg eventArg = new TValueEventArg(value, true, true);
- OnValuePub(eventArg);
- }
- protected virtual void OnValuePub(TValueEventArg eventArg) {
- Pub?.Invoke(this, eventArg);
- }
-}
-
-public class BarEmitter
-{
- private Random random = new Random();
- public event EventHandler> Pub;
- private double lastClose = 100.0; // Starting price
-
- public void Emit()
- {
- double open = lastClose;
- double close = open * (1 + (random.NextDouble() - 0.5) * 0.02); // +/- 1% change
- double high = Math.Max(open, close) * (1 + random.NextDouble() * 0.005); // Up to 0.5% higher
- double low = Math.Min(open, close) * (1 - random.NextDouble() * 0.005); // Up to 0.5% lower
- double volume = random.NextDouble() * 1000000; // Random volume between 0 and 1,000,000
-
- TBar bar = new TBar(DateTime.Now, open, high, low, close, volume);
- lastClose = close;
-
- TValueEventArg eventArg = new TValueEventArg(bar, true, true);
- OnBarPub(eventArg);
- }
-
- protected virtual void OnBarPub(TValueEventArg eventArg)
- {
- Pub?.Invoke(this, eventArg);
- }
-}
-
-
-public class Listener
-{
- public void Sub(object sender, EventArgs e)
- {
- if (e is TValueEventArg tValueArg) {
- Console.WriteLine($"TValue: {tValueArg.Data.Value:F2}");
- } else if (e is TValueEventArg tBarArg) {
- Console.WriteLine($"TBar: o={tBarArg.Data.Open:F2}, v={tBarArg.Data.Volume:F2}");
- } else {
- Console.WriteLine($"Unknown type: {e.GetType().Name}");
- }
- }
-}
-
-#!csharp
-
-Emitter em1 = new();
-BarEmitter em2 = new();
-Listener list = new();
-
-em1.Pub += list.Sub;
-em2.Pub += list.Sub;
-
-// Emit 5 random values
-for (int i = 0; i < 3; i++) {
- em1.Emit();
- em2.Emit();
-}
diff --git a/Calculations/Basics/ADD_Series.cs b/Calculations/Basics/ADD_Series.cs
deleted file mode 100644
index 0588d216..00000000
--- a/Calculations/Basics/ADD_Series.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-ADD - adding TSeries+TSeries together, or TSeries+double, or double+TSeries
-
-Remarks:
- Most of scaffolding is packaged in abstracty class Pair_TSeries_Indicator.
-
- */
-
-public class ADD_Series : Pair_TSeries_Indicator
-{
- public ADD_Series(TSeries d1, TSeries d2 ) : base(d1, d2) {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
- public ADD_Series(TSeries d1, double dd2 ) : base(d1, dd2) {
- if (base._d1.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
- }
- public ADD_Series(double dd1, TSeries d2 ) : base(dd1, d2) {
- if (base._d2.Count > 0) { for (int i=0; i< base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
- }
-
- public override void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2, bool update)
- {
- (System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v+TValue2.v);
- if (update) { base[base.Count - 1] = result; } else { base.Add(result); }
- }
-}
diff --git a/Calculations/Basics/CORR_Series.cs b/Calculations/Basics/CORR_Series.cs
deleted file mode 100644
index f82d82de..00000000
--- a/Calculations/Basics/CORR_Series.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-CORR: Pearson's Correlation Coefficient
- PCC is a measure of linear correlation between two sets of data.
- It is the ratio between the covariance of two variables and the product of
- their standard deviations; it is essentially a normalized measurement of
- the covariance, such that the result always has a value between −1 and 1.
-
-Sources:
- https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
-
- */
-
-public class CORR_Series : Pair_TSeries_Indicator
-{
- public CORR_Series(TSeries d1, TSeries d2, int period, bool useNaN = false) : base(d1, d2, period, useNaN)
- {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
-
- private readonly System.Collections.Generic.List _x = new();
- private readonly System.Collections.Generic.List _xx = new();
- private readonly System.Collections.Generic.List _y = new();
- private readonly System.Collections.Generic.List _yy = new();
- private readonly System.Collections.Generic.List _xy = new();
-
- public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update)
- {
- Add_Replace_Trim(_x, TValue1.v, _p, update);
- Add_Replace_Trim(_xx, TValue1.v * TValue1.v, _p, update);
- Add_Replace_Trim(_y, TValue2.v, _p, update);
- Add_Replace_Trim(_yy, TValue2.v * TValue2.v, _p, update);
- Add_Replace_Trim(_xy, TValue1.v * TValue2.v, _p, update);
-
- double _sumx = _x.Sum();
- double _sumxx = _xx.Sum();
- double _sumy = _y.Sum();
- double _sumyy = _yy.Sum();
- double _sumxy = _xy.Sum();
-
- double _covar = (_sumxx - _sumx * _sumx / _p) * (_sumyy - _sumy * _sumy / _p);
- double _cor = (_covar != 0) ? (_sumxy - _sumx * _sumy / _p) / Math.Sqrt(_covar) : 0.0;
-
- var result = (TValue1.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _cor);
- if (update) { base[base.Count - 1] = result; } else { base.Add(result); }
-
- }
-}
diff --git a/Calculations/Basics/COVAR_Series.cs b/Calculations/Basics/COVAR_Series.cs
deleted file mode 100644
index 4d6891c6..00000000
--- a/Calculations/Basics/COVAR_Series.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-COVAR: Covariance
- Covariance is defined as the expected value (or mean) of the product
- of their deviations from their individual expected values.
-
-Sources:
- https://en.wikipedia.org/wiki/Covariance
-
- */
-
-
-public class COVAR_Series : Pair_TSeries_Indicator
-{
- public COVAR_Series(TSeries d1, TSeries d2, int period, bool useNaN = false) : base(d1, d2, period, useNaN)
- {
- if (base._d1.Count > 0 && base._d2.Count > 0) {
- for (int i = 0; i < base._d1.Count; i++) {
- this.Add(base._d1[i], base._d2[i], false);
- }
- }
- }
-
- private readonly System.Collections.Generic.List _x = new();
- private readonly System.Collections.Generic.List _y = new();
- private readonly System.Collections.Generic.List _xy = new();
-
- public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update)
- {
- BufferTrim(_x, TValue1.v, _p, update);
- BufferTrim(_y, TValue2.v, _p, update);
- BufferTrim(_xy, TValue1.v * TValue2.v, _p, update);
-
- double _avgx = _x.Average();
- double _avgy = _y.Average();
- double _avgxy = _xy.Average();
- double _covar = _avgxy - (_avgx * _avgy);
-
- var result = (TValue1.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _covar);
- if (update) { base[base.Count - 1] = result; } else { base.Add(result); }
- }
-}
diff --git a/Calculations/Basics/DIV_Series.cs b/Calculations/Basics/DIV_Series.cs
deleted file mode 100644
index 16069917..00000000
--- a/Calculations/Basics/DIV_Series.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-DIV - divide TSeries/TSeries , or TSeries/double, or double/TSeries
-
-Remarks:
- Most of scaffolding is packaged in abstracty class Pair_TSeries_Indicator.
- */
-
-public class DIV_Series : Pair_TSeries_Indicator
-{
- public DIV_Series(TSeries d1, TSeries d2 ) : base(d1, d2) {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
- public DIV_Series(TSeries d1, double dd2 ) : base(d1, dd2) {
- if (base._d1.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
- }
- public DIV_Series(double dd1, TSeries d2 ) : base(dd1, d2) {
- if (base._d2.Count > 0) { for (int i=0; i< base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
- }
-
- public override void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2, bool update)
- {
- (System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t,
- (TValue2.v is not 0) ? TValue1.v/TValue2.v : Double.PositiveInfinity);
- if (update) { base[base.Count - 1] = result; } else { base.Add(result); }
- }
-}
\ No newline at end of file
diff --git a/Calculations/Basics/MUL_Series.cs b/Calculations/Basics/MUL_Series.cs
deleted file mode 100644
index c1c573bd..00000000
--- a/Calculations/Basics/MUL_Series.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-MUL - multiply TSeries*TSeries together, or TSeries*double, or double*TSeries
-
- */
-
-public class MUL_Series : Pair_TSeries_Indicator
-{
- public MUL_Series(TSeries d1, TSeries d2 ) : base(d1, d2) {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
- public MUL_Series(TSeries d1, double dd2 ) : base(d1, dd2) {
- if (base._d1.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
- }
- public MUL_Series(double dd1, TSeries d2 ) : base(dd1, d2) {
- if (base._d2.Count > 0) { for (int i=0; i< base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
- }
-
- public override void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2, bool update)
- {
- (System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t,
- TValue1.v*TValue2.v);
- if (update) { base[base.Count - 1] = result; } else { base.Add(result); }
- }
-}
\ No newline at end of file
diff --git a/Calculations/Basics/SUB_Series.cs b/Calculations/Basics/SUB_Series.cs
deleted file mode 100644
index 88511f81..00000000
--- a/Calculations/Basics/SUB_Series.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-SUB - subtracting TSeries-TSeries, or TSeries-double, or double-TSeries
-
- */
-
-
-public class SUB_Series : Pair_TSeries_Indicator
-{
- public SUB_Series(TSeries d1, TSeries d2 ) : base(d1, d2) {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
- public SUB_Series(TSeries d1, double dd2 ) : base(d1, dd2) {
- if (base._d1.Count > 0) { for (int i=0; i< base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
- }
- public SUB_Series(double dd1, TSeries d2 ) : base(dd1, d2) {
- if (base._d2.Count > 0) { for (int i=0; i< base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
- }
-
- public override void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2, bool update)
- {
- (System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t,
- TValue1.v-TValue2.v);
- if (update) { base[base.Count - 1] = result; } else { base.Add(result); }
- }
-}
\ No newline at end of file
diff --git a/Calculations/ClassStructures/Pair_TSeries_Abstract.cs b/Calculations/ClassStructures/Pair_TSeries_Abstract.cs
deleted file mode 100644
index 99ccfee6..00000000
--- a/Calculations/ClassStructures/Pair_TSeries_Abstract.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-Abstract classes with all scaffolding required to build indicators.
- All abstracts support period, NaN, and all permutations of Add() methods.
- Indicator classess need to implement:
- - Chaining constructor (Abstract's constructor executes first)
- - Default Add(value) class
- - optional Add(series) bulk insert class (for optimization of historical analysis)
-
- Single_TSeries_Indicator - one single-value TSeries in, one TSeries out.
- Pair_TSeries_Indicator - Two TSeries in, one TSeries out. (includes simple semaphoring)
- Single_TBars_Indicator - One OHLCV TBars in, one TSeries out.
-
- */
-
-public abstract class Pair_TSeries_Indicator : TSeries {
- protected readonly int _p;
- protected readonly bool _NaN;
- protected readonly TSeries _d1;
- protected readonly TSeries _d2;
- protected readonly double _dd1, _dd2;
-
- // Chainable Constructors - add them at the end of primary constructors if needed
- protected Pair_TSeries_Indicator(TSeries source1, TSeries source2, int period, bool useNaN) {
- _p = period;
- _NaN = useNaN;
- _d1 = source1;
- _d2 = source2;
- _dd1 = double.NaN;
- _dd2 = double.NaN;
- _d1.Pub += Sub;
- _d2.Pub += Sub;
- }
-
- protected Pair_TSeries_Indicator(TSeries source1, TSeries source2) {
- _d1 = source1;
- _d2 = source2;
- _dd1 = double.NaN;
- _dd2 = double.NaN;
- _d1.Pub += Sub;
- _d2.Pub += Sub;
- }
-
- protected Pair_TSeries_Indicator(TSeries source1, double dd2) {
- _d1 = source1;
- _d2 = new TSeries();
- _dd1 = double.NaN;
- _dd2 = dd2;
- _d1.Pub += Sub;
- }
-
- protected Pair_TSeries_Indicator(double dd1, TSeries source2) {
- _d1 = new TSeries();
- _d2 = source2;
- _dd1 = dd1;
- _dd2 = double.NaN;
- _d2.Pub += Sub;
- }
-
- // overridable Add(Tvalue, Tvalue) method to add/update a single value at the end of the list
- public virtual void Add((DateTime t, double v) TValue1, (DateTime t, double v) TValue2, bool update) {
- base.Add((TValue1.t, 0), update);
- // default inserts zeros
- }
-
- // potentially overridable Add() bulk variations (could be replaced with faster bulk algos)
- public virtual void Add(TSeries d1, TSeries d2) {
- for (var i = 0; i < d1.Count; i++) {
- Add(d1[i], d2[i], false);
- }
- }
-
- public virtual void Add(TSeries d1, double dd2) {
- for (var i = 0; i < d1.Count; i++) {
- Add(d1[i], (d1[i].t, dd2), false);
- }
- }
-
- public virtual void Add(double dd1, TSeries d2) {
- for (var i = 0; i < d2.Count; i++) {
- Add((d2[i].t, dd1), d2[i], false);
- }
- }
-
- public void Add((DateTime t, double v) TValue1, (DateTime t, double v) TValue2) {
- Add(TValue1, TValue2, false);
- }
-
- public void Add(bool update) {
- if (_dd1 is double.NaN && _dd2 is double.NaN) {
- // (Series, Series)
- if (update || (_d1.Count > Count && _d2.Count > Count)) {
- Add(_d1[_d1.Count - 1], _d2[_d2.Count - 1], update);
- }
- }
- else if (_dd2 is not double.NaN && _dd1 is double.NaN) {
- // (Series, Double)
- Add(_d1[_d1.Count - 1], (_d1[_d1.Count - 1].t, _dd2), update);
- }
- else {
- // (Double, Series)
- Add((_d2[_d2.Count - 1].t, _dd1), _d2[_d2.Count - 1], update);
- }
- }
-
- public void Add() {
- Add(false);
- }
-
- public new void Sub(object source, TSeriesEventArgs e) {
- Add(e.update);
- }
-
- protected static void Add_Replace(List l, double v, bool update) {
- if (update) {
- l[l.Count - 1] = v;
- }
- else {
- l.Add(v);
- }
- }
-
- protected static void Add_Replace_Trim(List l, double v, int p, bool update) {
- Add_Replace(l, v, update);
- if (l.Count > p && p != 0) {
- l.RemoveAt(0);
- }
- }
-}
diff --git a/Calculations/Logic/COMPARE_Series.cs b/Calculations/Logic/COMPARE_Series.cs
deleted file mode 100644
index 4ee84c96..00000000
--- a/Calculations/Logic/COMPARE_Series.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-COMPARE - Generates +1 if A is above B, -1 if A is below B and 0 if A=B
-
-
- */
-
-public class COMPARE_Series : Pair_TSeries_Indicator {
-
- public COMPARE_Series(TSeries d1, TSeries d2) : base(d1, d2) {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
- public COMPARE_Series(TSeries d1, double dd2) : base(d1, dd2) {
- if (base._d1.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
- }
- public COMPARE_Series(double dd1, TSeries d2) : base(dd1, d2) {
- if (base._d2.Count > 0) { for (int i = 0; i < base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
- }
-
- public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update) {
-
- double val = TValue1.v > TValue2.v ? 1 : -1;
- val = TValue1.v == TValue2.v ? 0 : val;
- (System.DateTime t, double v) over = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v > TValue2.v ? 1 : val);
- if (update) { base[^1] = over; }
- else { base.Add(over); }
-
-
- }
-}
-
-
diff --git a/Calculations/Logic/CROSS_Series.cs b/Calculations/Logic/CROSS_Series.cs
deleted file mode 100644
index 2c4cad1c..00000000
--- a/Calculations/Logic/CROSS_Series.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-OVER - Generates +1 if A is above B, -1 if A is below B and 0 if A=B
-
-Remarks:
- OVER.Cross generates 1 when A breaks B from below and -1 when A breaks B from above
-
- */
-
-public class CROSS_Series : Pair_TSeries_Indicator {
- public TSeries Cross { get; set; } = new();
-
- private double _previous = double.NaN;
- public CROSS_Series(TSeries d1, TSeries d2) : base(d1, d2) {
- if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
- }
- public CROSS_Series(TSeries d1, double dd2) : base(d1, dd2) {
- if (base._d1.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
- }
- public CROSS_Series(double dd1, TSeries d2) : base(dd1, d2) {
- if (base._d2.Count > 0) { for (int i = 0; i < base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
- }
-
- public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update) {
-
- double val = TValue1.v > TValue2.v ? 1 : -1;
- val = TValue1.v == TValue2.v ? 0 : val;
- double over = TValue1.v > TValue2.v ? 1 : val;
-
- val = (_previous < over) ? 1 : -1;
- val = ((_previous == over) || Double.IsNaN(this._previous) || (this._previous == 0)) ? 0 : val;
- (System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t,val);
-
- this._previous = over;
-
- if (update) { base[^1] = result; }
- else { base.Add(result); }
-
- }
-}
-
-
diff --git a/Calculations/Logic/TOrders.cs b/Calculations/Logic/TOrders.cs
deleted file mode 100644
index 04d5ffa3..00000000
--- a/Calculations/Logic/TOrders.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Data;
-using System.Linq;
-
-
-public enum OType {
- NIL = 0, // No position
- BTO = 1, // Buy to Open
- STC = 2, // Sell to Close
- STO = 3, // Sell to Open
- BTC = 4, // Buy to Close
- END = 5, // Exit the trade
-}
-
-
-public class TOrders : List<(DateTime t, OType o)> {
-
- public void Add((DateTime t, OType o) TOrder, bool update = false)
- {
- if (update) { this[^1] = TOrder; }
- else { base.Add(TOrder); }
- OnEvent(update);
- }
-
-
- protected virtual void OnEvent(bool update = false) {
- Pub?.Invoke(this, new TSeriesEventArgs { update = update }); }
- public delegate void NewDataEventHandler(object source, TSeriesEventArgs args);
- public event NewDataEventHandler Pub;
-
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ADL_Series.cs b/Calculations/_Updated/ADL_Series.cs
deleted file mode 100644
index 2222887e..00000000
--- a/Calculations/_Updated/ADL_Series.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-ADL: Chaikin Accumulation/Distribution Line
- ADL is a volume-based indicator that measures the cumulative Money Flow Volume:
-
- 1. Money Flow Multiplier = [(Close - Low) - (High - Close)] /(High - Low)
- 2. Money Flow Volume = Money Flow Multiplier x Volume for the Period
- 3. ADL = Previous ADL + Current Period's Money Flow Volume
-
-Sources:
- https://school.stockcharts.com/doku.php?id=technical_indicators:accumulation_distribution_line
-
- */
-
-public class ADL_Series : TSeries {
- protected readonly TBars _data;
- private double _lastadl, _lastlastadl;
-
- //core constructors
- public ADL_Series() {
- Name = $"ADL()";
- _lastadl = _lastlastadl = 0;
- }
- public ADL_Series(TBars source) {
- _data = source;
- Name = $"ADL({(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _lastadl = _lastlastadl = 0;
- _data.Pub += Sub;
- Add(data: _data);
- }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- if (update) { this._lastadl = this._lastlastadl; }
- else { this._lastlastadl = this._lastadl; }
-
- double _adl = 0;
- double tmp = TBar.h - TBar.l;
- if (tmp > 0.0) {
- _adl = _lastadl + ((2 * TBar.c - TBar.l - TBar.h) / tmp * TBar.v);
- }
- _lastadl = _adl;
-
- var ret = (TBar.t, _adl);
- return base.Add(ret, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _lastadl = _lastlastadl = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ADOSC_Series.cs b/Calculations/_Updated/ADOSC_Series.cs
deleted file mode 100644
index 4c943b07..00000000
--- a/Calculations/_Updated/ADOSC_Series.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-ADOSC: Chaikin Accumulation/Distribution Oscillator
- ADO measures the momentum of ADL using the difference between slow (10-day) EMA(ADL)
- and fast (3-day) EMA(ADL):
-
- Chaikin A/D Oscillator is defined as 3-day EMA of ADL minus 10-day EMA of ADL
-
-Sources:
- https://school.stockcharts.com/doku.php?id=technical_indicators:chaikin_oscillator
-
- */
-
-public class ADOSC_Series : TSeries {
- protected readonly TBars _data;
- private readonly double _k1, _k2;
- private double _lastema1, _lastlastema1, _lastema2, _lastlastema2;
- private double _lastadl, _lastlastadl;
-
- //core constructors
- public ADOSC_Series(int shortPeriod, int longPeriod, bool useNaN = false) {
- Name = $"ADOSC()";
- _k1 = 2.0 / (shortPeriod + 1);
- _k2 = 2.0 / (longPeriod + 1);
- _lastadl = _lastlastadl = _lastema1 = _lastlastema1 = _lastema2 = _lastlastema2 = 0;
- }
- public ADOSC_Series(TBars source, int shortPeriod, int longPeriod, bool useNaN = false) :this(shortPeriod, longPeriod, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _lastadl = _lastlastadl = 0;
- _data.Pub += Sub;
- Add(data: _data);
- }
-
- public ADOSC_Series() : this(shortPeriod: 3, longPeriod: 10, useNaN: false) {}
-
- public ADOSC_Series(TBars source) : this(source, shortPeriod: 3, longPeriod:10, useNaN:false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update= false) {
-
- if (update) {
- _lastadl = _lastlastadl;
- _lastema1 = _lastlastema1;
- _lastema2 = _lastlastema2;
- }
-
- double _adl = 0;
- double tmp = TBar.h - TBar.l;
- if (tmp > 0.0) { _adl = _lastadl + ((2 * TBar.c - TBar.l - TBar.h) / tmp * TBar.v); }
- if (this.Count == 0) { _lastema1 = _lastema2 = _adl; }
-
- double _ema1 = (_adl - _lastema1) * _k1 + _lastema1;
- double _ema2 = (_adl - _lastema2) * _k2 + _lastema2;
-
- _lastlastadl = _lastadl;
- _lastadl = _adl;
- _lastlastema1 = _lastema1;
- _lastema1 = _ema1;
- _lastlastema2 = _lastema2;
- _lastema2 = _ema2;
-
- double _adosc = _ema1 - _ema2;
-
- var ret = (TBar.t, _adosc);
- return base.Add(ret, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _lastadl = _lastlastadl = _lastema1 = _lastlastema1 = _lastema2 = _lastlastema2 = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ALMA_Series.cs b/Calculations/_Updated/ALMA_Series.cs
deleted file mode 100644
index e4c8c3de..00000000
--- a/Calculations/_Updated/ALMA_Series.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-ALMA: Arnaud Legoux Moving Average
- The ALMA moving average uses the curve of the Normal (Gauss) distribution, which
- can be shifted from 0 to 1. This allows regulating the smoothness and high
- sensitivity of the indicator. Sigma is another parameter that is responsible for
- the shape of the curve coefficients. This moving average reduces lag of the data
- in conjunction with smoothing to reduce noise.
-
-
-Sources:
- https://phemex.com/academy/what-is-arnaud-legoux-moving-averages
- https://www.prorealcode.com/prorealtime-indicators/alma-arnaud-legoux-moving-average/
-
- Discrepancy with Pandas-TA (but passes the validation with Skender.GetAlma)
- */
-
-public class ALMA_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- private readonly System.Collections.Generic.List _buffer = new();
- private readonly System.Collections.Generic.List _weight;
- private double _norm;
- private readonly double _offset, _sigma;
-
- //core constructors
- public ALMA_Series(int period, double offset, double sigma, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"ALMA({period})";
- _offset = offset;
- _sigma = sigma;
- _weight = new();
- }
- public ALMA_Series(TSeries source, int period, double offset, double sigma, bool useNaN) : this(period, offset, sigma, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
- public ALMA_Series() : this(period:0, offset:0.85, sigma:6.0, useNaN: false) { }
- public ALMA_Series(int period) : this(period: period, offset:0.85, sigma:6.0, useNaN:false) { }
- public ALMA_Series(TBars source) : this(source:source.Close, period:0, offset:0.85, sigma:6.0, useNaN:false) { }
- public ALMA_Series(TBars source, int period) : this(source:source.Close, period:period, offset: 0.85, sigma: 6.0, useNaN: false) { }
- public ALMA_Series(TBars source, int period, double offset, double sigma, bool useNaN) : this(source.Close, period:period, offset: offset, sigma: sigma, useNaN: false) { }
- public ALMA_Series(TSeries source) : this(source, period:0, offset:0.85, sigma:6.0, useNaN:false) { }
- public ALMA_Series(TSeries source, int period) : this(source:source, period:period, offset:0.85, sigma:6.0, useNaN:false) { }
- public ALMA_Series(TSeries source, int period, bool useNaN) : this(source: source, period: period, offset: 0.85, sigma: 6.0, useNaN: useNaN) { }
-
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, double.NaN), update);
- }
-
- BufferTrim(_buffer, TValue.v, _period, update);
- if (_weight.Count < _buffer.Count) {
- for (var i = 0; i < _buffer.Count - _weight.Count; i++) {
- _weight.Add(0.0);
- }
- }
-
-
- if (_buffer.Count <= _period || _period == 0) {
- var _len = _buffer.Count;
- _norm = 0;
- var _m = _offset * (_len - 1);
- var _s = _len / _sigma;
- for (var i = 0; i < _len; i++) {
- var _wt = Math.Exp(-((i - _m) * (i - _m)) / (2 * _s * _s));
- _weight[i] = _wt;
- _norm += _wt;
- }
- }
-
- double _weightedSum = 0;
- for (var i = 0; i < _buffer.Count; i++) {
- _weightedSum += _weight[i] * _buffer[i];
- }
-
- var _alma = _weightedSum / _norm;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _alma);
- return base.Add(res, update);
- }
-
- //variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- _weight.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ATRP_Series.cs b/Calculations/_Updated/ATRP_Series.cs
deleted file mode 100644
index 7f4cf4c7..00000000
--- a/Calculations/_Updated/ATRP_Series.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-ATRP: Average True Range Percent
- Average True Range Percent is (ATR/Close Price)*100.
- This normalizes so it can be compared to other stocks.
-
-Sources:
- https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/atrp
-
- */
-
-public class ATRP_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TBars _data;
- private double _k;
- private int _len;
- private double _lastatr, _lastlastatr, _cm1, _lastcm1, _sum, _oldsum;
-
- //core constructors
- public ATRP_Series(int period, bool useNaN) {
- _period = period;
- _k = 1.0 / (double)(_period);
- _NaN = useNaN;
- _len = 0;
- Name = $"ATRP({period})";
- }
- public ATRP_Series(TBars source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(data: _data);
- }
- public ATRP_Series() : this(period: 1, useNaN: false) { }
- public ATRP_Series(int period) : this(period: period, useNaN: false) { }
- public ATRP_Series(TBars source) : this(source, period: 1, useNaN: false) { }
- public ATRP_Series(TBars source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- if (update) { _lastatr = _lastlastatr; _cm1 = _lastcm1; _sum = _oldsum; }
- else {
- _lastlastatr = _lastatr; _lastcm1 = _cm1; _oldsum = _sum;
- _k = (_period == 0) ? 1 / (double)_len : _k;
- _len++;
- }
-
- if (_len == 1) { _cm1 = TBar.c; }
- double d1 = Math.Abs(TBar.h - TBar.l);
- double d2 = Math.Abs(_cm1 - TBar.h);
- double d3 = Math.Abs(_cm1 - TBar.l);
- (DateTime t, double v) d = (TBar.t, Math.Max(d1, Math.Max(d2, d3)));
- _cm1 = TBar.c;
-
- double _atr = 0;
- if (this.Count == 0) { _atr = d.v; }
- else if (this.Count < _period + 1) { _sum += d.v; _atr = _sum / (this.Count); }
- else { _atr = _k * (d.v - _lastatr) + _lastatr; }
- _lastatr = _atr;
- double _atrp = 100 * (_atr / TBar.c);
-
- var res = (TBar.t, Count < _period - 1 && _NaN ? double.NaN : _atrp);
- return base.Add(res, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ATR_Series.cs b/Calculations/_Updated/ATR_Series.cs
deleted file mode 100644
index be22668d..00000000
--- a/Calculations/_Updated/ATR_Series.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-ATR: wildeR Moving Average
- The average true range (ATR) is a price volatility indicator
- showing the average price variation of assets within a given time period.
-
-Sources:
- https://en.wikipedia.org/wiki/Average_true_range
- https://www.tradingview.com/wiki/Average_True_Range_(ATR)
- https://www.investopedia.com/terms/a/atr.asp
-
- */
-
-public class ATR_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TBars _data;
- private double _k;
- private int _len;
- private double _lastatr, _lastlastatr, _cm1, _lastcm1, _sum, _oldsum;
-
- //core constructors
- public ATR_Series(int period, bool useNaN) {
- _period = period;
- _k = 1.0 / (double)(_period);
- _NaN = useNaN;
- _len = 0;
- Name = $"ATR({period})";
- }
- public ATR_Series(TBars source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(data: _data);
- }
- public ATR_Series() : this(period: 1, useNaN: false) { }
- public ATR_Series(int period) : this(period: period, useNaN: false) { }
- public ATR_Series(TBars source) : this(source, period: 1, useNaN: false) { }
- public ATR_Series(TBars source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- if (update) { _lastatr = _lastlastatr; _cm1 = _lastcm1; _sum = _oldsum; }
- else {
- _lastlastatr = _lastatr; _lastcm1 = _cm1; _oldsum = _sum;
- _k = (_period == 0) ? 1 / (double)_len : _k;
- _len++;
- }
-
- if (_len == 1) { _cm1 = TBar.c; }
- double d1 = Math.Abs(TBar.h - TBar.l);
- double d2 = Math.Abs(_cm1 - TBar.h);
- double d3 = Math.Abs(_cm1 - TBar.l);
- (DateTime t, double v) d = (TBar.t, Math.Max(d1, Math.Max(d2, d3)));
- _cm1 = TBar.c;
-
- double _atr = 0;
- if (this.Count == 0) { _atr = d.v; }
- else if (this.Count < _period + 1) { _sum += d.v; _atr = _sum / (this.Count); }
- else { _atr = _k * (d.v - _lastatr) + _lastatr; }
- _lastatr = _atr;
-
- var res = (TBar.t, Count < _period - 1 && _NaN ? double.NaN : _atr);
- return base.Add(res, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/BBANDS_Series.cs b/Calculations/_Updated/BBANDS_Series.cs
deleted file mode 100644
index 7cc5a3e0..00000000
--- a/Calculations/_Updated/BBANDS_Series.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-BBANDS: Bollinger Bands®
- Price channels created by John Bollinger, depict volatility as standard deviation boundary
- line range from a moving average of price. The bands automatically widen when volatility
- increases and contract when volatility decreases. Their dynamic nature allows them to be
- used on different securities with the standard settings.
-
- Mid Band = simple moving average (SMA)
- Upper Band = SMA + (standard deviation of price x multiplier)
- Lower Band = SMA - (standard deviation of price x multiplier)
- Bandwidth = Width of the channel: (Upper-Lower)/SMA
- %B = The location of the data point within the channel: (Price-Lower)/(Upper/Lower)
- Z-Score = number of standard deviations of the data point from SMA
-
-Sources:
- https://www.investopedia.com/terms/b/bollingerbands.asp
- https://school.stockcharts.com/doku.php?id=technical_indicators:bollinger_bands
-
-Note:
- Bollinger Bands® is a registered trademark of John A. Bollinger.
-
- */
-
-public class BBANDS_Series : TSeries {
- protected readonly int _period;
- protected readonly double _multiplier;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- public SMA_Series Mid { get; }
- public TSeries Upper { get; }
- public TSeries Lower { get; }
- public TSeries PercentB { get; }
- public TSeries Bandwidth { get; }
- public TSeries Zscore { get; }
- private readonly SDEV_Series _sdev;
-
- //core constructors
- public BBANDS_Series(int period, double multiplier, bool useNaN) {
- _period = period;
- _multiplier = multiplier;
- _NaN = useNaN;
- Name = $"BBANDS({period})";
- }
- public BBANDS_Series(TSeries source, int period, double multiplier, bool useNaN) : this(period, multiplier, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- Upper = new("BB_Up");
- Lower = new("BB_Low");
- Bandwidth = new("BBandwidth");
- PercentB = new("%BBandwidth");
- Zscore = new("Zscore");
-
- Mid = new(period, false);
- _sdev = new(period, false);
-
- _data.Pub += Sub;
- Add(_data);
- }
-
- public BBANDS_Series() : this(period:0, multiplier: 2.0, useNaN: false) { }
- public BBANDS_Series(int period) : this(period: period, multiplier: 2.0, useNaN:false) { }
- public BBANDS_Series(TBars source) : this(source:source.Close, period:0, multiplier: 2.0, useNaN:false) { }
- public BBANDS_Series(TBars source, int period) : this(source:source.Close, period:period, multiplier: 2.0, useNaN: false) { }
- public BBANDS_Series(TBars source, int period, double multiplier, bool useNaN) : this(source.Close, period:period, multiplier:multiplier, useNaN: false) { }
- public BBANDS_Series(TSeries source) : this(source, period:0, useNaN:false) { }
- public BBANDS_Series(TSeries source, int period) : this(source:source, period:period, useNaN:false) { }
- public BBANDS_Series(TSeries source, int period, bool useNaN) : this(source: source, period: period, multiplier: 2.0, useNaN: useNaN) { }
-
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update=false) {
- var _mid = Mid.Add(TValue,update);
- var _sd = this._sdev.Add(TValue, update);
- var _upper = Upper.Add((TValue.t, _mid.v + _sd.v * _multiplier), update);
- var _lower = Lower.Add((TValue.t, _mid.v - _sd.v * _multiplier), update);
- double _pbdnd = TValue.v - _lower.v;
- double _pbdvr = _upper.v - _lower.v;
- PercentB.Add((TValue.t, _pbdnd/_pbdvr), update);
- Zscore.Add((TValue.t, (TValue.v-_mid.v)/_sd.v), update);
- Bandwidth.Add((TValue.t, _pbdvr / _mid.v), update);
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _pbdvr / _mid.v);
- return base.Add(res, update);
- }
-
- //variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
- //reset calculation
- public override void Reset() {
- Mid.Clear();
- _sdev.Clear();
- Upper.Clear();
- Lower.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/BIAS_Series.cs b/Calculations/_Updated/BIAS_Series.cs
deleted file mode 100644
index 0c859ee4..00000000
--- a/Calculations/_Updated/BIAS_Series.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-BIAS: Rate of change between the source and a moving average.
- Bias is a statistical term which means a systematic deviation from the actual value.
-
-BIAS = (close - SMA) / SMA
- = (close / SMA) - 1
-
-Sources:
- https://en.wikipedia.org/wiki/Bias_of_an_estimator
-
- */
-
-public class BIAS_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly SMA_Series _sma;
-
- //core constructors
- public BIAS_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"BIAS({period})";
- _sma = new(period, false);
- }
- public BIAS_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public BIAS_Series() : this(period: 0, useNaN: false) { }
- public BIAS_Series(int period) : this(period: period, useNaN: false) { }
- public BIAS_Series(TBars source) : this(source.Close, 0, false) { }
- public BIAS_Series(TBars source, int period) : this(source.Close, period, false) { }
- public BIAS_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public BIAS_Series(TSeries source) : this(source, 0, false) { }
- public BIAS_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- var _s = _sma.Add(TValue,update);
- double _bias = (TValue.v / ((_s.v!=0)?_s.v:1)) - 1;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _bias);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _sma.Reset();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/CCI_Series.cs b/Calculations/_Updated/CCI_Series.cs
deleted file mode 100644
index 89efbc20..00000000
--- a/Calculations/_Updated/CCI_Series.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-CCI: Commodity Channel Index
- Commodity Channel Index is a momentum oscillator used to primarily identify overbought
- and oversold levels relative to a mean. CCI measures the current price level relative
- to an average price level over a given period of time:
- - CCI is relatively high when prices are far above their average.
- - CCI is relatively low when prices are far below their average.
- Using this method, CCI can be used to identify overbought and oversold levels.
-
-Sources:
- https://www.investopedia.com/terms/c/commoditychannelindex.asp
- https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/cci
-
- */
-
-public class CCI_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TBars _data;
- private readonly System.Collections.Generic.List _tp = new();
-
- //core constructors
- public CCI_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"CCI({period})";
- }
- public CCI_Series(TBars source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(data: _data);
- }
- public CCI_Series() : this(period: 2, useNaN: false) { }
- public CCI_Series(int period) : this(period: period, useNaN: false) { }
- public CCI_Series(TBars source) : this(source, period: 2, useNaN: false) { }
- public CCI_Series(TBars source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- double _tpItem = (TBar.h + TBar.l + TBar.c) / 3.0;
- if (update) {
- this._tp[this._tp.Count - 1] = _tpItem;
- }
- else {
- this._tp.Add(_tpItem);
- }
- if (this._tp.Count > this._period) { this._tp.RemoveAt(0); }
-
- // average TP over _tp buffer
- double _avgTp = _tp.Average();
-
- // average Deviation over _tp buffer
- double _avgDv = 0;
- for (int i = 0; i < this._tp.Count; i++) { _avgDv += Math.Abs(_avgTp - this._tp[i]); }
- _avgDv /= this._tp.Count;
-
- double _cci = (_avgDv == 0) ? 0 : (this._tp[this._tp.Count - 1] - _avgTp) / (0.015 * _avgDv);
- var res = (TBar.t, Count < _period - 1 && _NaN ? double.NaN : _cci);
- return base.Add(res, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _tp.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/CMO_Series.cs b/Calculations/_Updated/CMO_Series.cs
deleted file mode 100644
index ea800ed2..00000000
--- a/Calculations/_Updated/CMO_Series.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-CMO: Chande Momentum Oscillator
- Chande Momentum Oscillator (also known as CMO indicator) was developed by Tushar S. Chande
- CMO is similar to other momentum oscillators (e.g. RSI or Stochastics). Alike RSI oscillator,
- the CMO values move in the range from -100 to +100 points and its aim is to detect the
- overbought and oversold market conditions. CMO calculates the price momentum on both the up
- days as well as the down days. The CMO calculation is based on non-smoothed price values
- meaning that it can reach its extremes more frequently and the short-time swings are more visible.
-
-Sources:
- https://www.technicalindicators.net/indicators-technical-analysis/144-cmo-chande-momentum-oscillator
-
- */
-
-public class CMO_Series : TSeries {
- private readonly System.Collections.Generic.List _buff_up = new();
- private readonly System.Collections.Generic.List _buff_dn = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private double _plast_value, _last_value;
-
- //core constructors
- public CMO_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"CMO({period})";
- }
- public CMO_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public CMO_Series() : this(period: 0, useNaN: false) { }
- public CMO_Series(int period) : this(period: period, useNaN: false) { }
- public CMO_Series(TBars source) : this(source.Close, 0, false) { }
- public CMO_Series(TBars source, int period) : this(source.Close, period, false) { }
- public CMO_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public CMO_Series(TSeries source) : this(source, 0, false) { }
- public CMO_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) { _last_value = _plast_value; } else { _plast_value = _last_value; }
- BufferTrim(buffer:_buff_up, (TValue.v > _last_value) ? TValue.v - _last_value : 0, period:_period, update: update);
- BufferTrim(buffer: _buff_dn, (TValue.v < _last_value) ? _last_value - TValue.v : 0, period: _period, update: update);
- _last_value = TValue.v;
- double _cmo_up = 0;
- double _cmo_dn = 0;
- for (int i = 0; i < Math.Min(_buff_up.Count, _buff_dn.Count); i++) {
- _cmo_up += _buff_up[i];
- _cmo_dn += _buff_dn[i];
- }
- double _cmo = 100 * (_cmo_up - _cmo_dn) / (_cmo_up + _cmo_dn);
- if (_cmo_up + _cmo_dn == 0) { _cmo = 0; }
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _cmo);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
-
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buff_up.Clear();
- _buff_dn.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/CUSUM_Series.cs b/Calculations/_Updated/CUSUM_Series.cs
deleted file mode 100644
index 08897f07..00000000
--- a/Calculations/_Updated/CUSUM_Series.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-CUSUM: Cumulative Sum (aka Running Total)
- SUM across a period provides a rolling sum of all values across the period.
- If SUM values would be divided with period, the output would be SMA()
-
-Sources:
- https://en.wikipedia.org/wiki/CUSUM
- */
-
-public class CUSUM_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
-
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public CUSUM_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"CUSUM({period})";
- }
- public CUSUM_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public CUSUM_Series() : this(period: 0, useNaN: false) { }
- public CUSUM_Series(int period) : this(period: period, useNaN: false) { }
- public CUSUM_Series(TBars source) : this(source.Close, 0, false) { }
- public CUSUM_Series(TBars source, int period) : this(source.Close, period, false) { }
- public CUSUM_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public CUSUM_Series(TSeries source) : this(source, period: 0, useNaN: false) { }
- public CUSUM_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sum = 0;
- for (int i = 0; i < _buffer.Count; i++) { _sum += _buffer[i]; }
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _sum);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/DECAY_Series.cs b/Calculations/_Updated/DECAY_Series.cs
deleted file mode 100644
index 263875c3..00000000
--- a/Calculations/_Updated/DECAY_Series.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-DECAY:
- Linear decay can be modeled by a straight line with a negative slope of 1/period.
- The value decreases in a straight line from the last maximum to 0.
- Decay = Last Max - distance/period
-
- Exponential decay is modeled as an exponential curve with diminishing factor of
- 1-1/p
-
- */
-
-public class DECAY_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly bool _exp;
- private double _pdecay, _ppdecay;
- private readonly double _dfactor;
-
- //core constructors
- public DECAY_Series(int period, bool exponential, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"DECAY({period})";
- _exp = exponential;
- _dfactor = (_exp) ? 1.0 - 1.0 / (double)_period : 1 / (double)_period;
- _pdecay = _ppdecay = 0;
- }
- public DECAY_Series(TSeries source, int period, bool exponential, bool useNaN) : this(period, exponential, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public DECAY_Series() : this(period: 0, exponential: false, useNaN: false) { }
- public DECAY_Series(int period) : this(period: period, exponential: false, useNaN: false) { }
- public DECAY_Series(TBars source) : this(source.Close, period: 0, exponential: false, useNaN: false) { }
- public DECAY_Series(TBars source, int period) : this(source.Close, period: period, exponential:false, useNaN:false) { }
- public DECAY_Series(TBars source, int period, bool useNaN) : this(source.Close, period: period, exponential: false, useNaN) { }
- public DECAY_Series(TSeries source) : this(source, period: 0, exponential: false, useNaN:false) { }
- public DECAY_Series(TSeries source, int period) : this(source: source, period: period, exponential: false, useNaN: false) { }
- public DECAY_Series(TSeries source, int period, bool useNaN) : this(source: source, period: period, exponential: false, useNaN: useNaN) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
- if (update) { _pdecay = _ppdecay; }
- else { _ppdecay = _pdecay; }
-
- if (this.Count == 0) { _pdecay = TValue.v; }
- double _decay = Math.Max(TValue.v, Math.Max((_exp) ? _pdecay * _dfactor : _pdecay - _dfactor, 0));
- _pdecay = _decay;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _decay);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _pdecay = _ppdecay = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/DEMA_Series.cs b/Calculations/_Updated/DEMA_Series.cs
deleted file mode 100644
index dffd9f71..00000000
--- a/Calculations/_Updated/DEMA_Series.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-DEMA: Double Exponential Moving Average
- DEMA uses EMA(EMA()) to calculate smoother Exponential moving average.
-
-Sources:
- https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/double-exponential-moving-average-dema/
-
-Remark:
- ema1 = EMA(close, length)
- ema2 = EMA(ema1, length)
- DEMA = 2 * ema1 - ema2
-
- */
-
-public class DEMA_Series : TSeries {
- private double _k;
- private double _sum, _oldsum;
- private double _lastema1, _oldema1, _lastema2, _oldema2;
- private int _len;
- private readonly bool _useSMA;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
-//core constructor
- public DEMA_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- _useSMA = useSMA;
- Name = $"DEMA({period})";
- _k = 2.0 / (_period + 1);
- _len = 0;
- _sum = _oldsum = _lastema1 = _lastema2 = 0;
- }
- //generic constructors (source)
-
- public DEMA_Series() : this(0, false, true) {}
- public DEMA_Series(int period) : this(period, false, true) {}
- public DEMA_Series(TBars source) : this(source.Close, 0, false) {}
- public DEMA_Series(TBars source, int period) : this(source.Close, period, false) {}
- public DEMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {}
- public DEMA_Series(TSeries source, int period) : this(source, period, false, true) {}
- public DEMA_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) {}
- public DEMA_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
-// core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) {
- _lastema1 = _oldema1;
- _lastema2 = _oldema2;
- _sum = _oldsum;
- }
- else {
- _oldema1 = _lastema1;
- _oldema2 = _lastema2;
- _oldsum = _sum;
- _len++;
- }
-
- if (_period == 0) {
- _k = 2.0 / (_len + 1);
- }
-
- double _ema1, _ema2, _dema;
- if (Count == 0) {
- _ema1 = _ema2 = _sum = TValue.v;
- }
- else if (_len <= _period && _useSMA && _period != 0) {
- _sum += TValue.v;
- _ema1 = _sum / Math.Min(_len, _period);
- _ema2 = _ema1;
- }
- else {
- _ema1 = (TValue.v - _lastema1) * _k + _lastema1;
- _ema2 = (_ema1 - _lastema2) * _k + _lastema2;
- }
-
- _dema = 2 * _ema1 - _ema2;
-
- _lastema1 = double.IsNaN(_ema1) ? _lastema1 : _ema1;
- _lastema2 = double.IsNaN(_ema2) ? _lastema2 : _ema2;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _dema);
- return base.Add(res, update);
- }
-
-//variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) {
- return (DateTime.Today, double.NaN);
- }
-
- foreach (var item in data) {
- Add(item, false);
- }
-
- return _data.Last;
- }
-
- public (DateTime t, double v) Add(bool update) {
- return Add(_data.Last, update);
- }
-
- public (DateTime t, double v) Add() {
- return Add(_data.Last, false);
- }
-
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(_data.Last, e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _sum = _oldsum = _lastema1 = _lastema2 = 0;
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/DWMA_Series.cs b/Calculations/_Updated/DWMA_Series.cs
deleted file mode 100644
index 20283c34..00000000
--- a/Calculations/_Updated/DWMA_Series.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-/*
-DWMA: Double Weighted Moving Average
- The weights are decreasing over the period with p^2 decay
- and the most recent data has the heaviest weight.
-
- */
-
-public class DWMA_Series : TSeries {
- private readonly List _buffer = new();
- private List _weights;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- protected int _len;
-
-//core constructors
- public DWMA_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"DWMA({period})";
- _len = 0;
- _weights = CalculateWeights(_period);
- }
-
- public DWMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
- public DWMA_Series() : this(0, false) {
- }
-
- public DWMA_Series(int period) : this(period, false) {
- }
-
- public DWMA_Series(TBars source) : this(source.Close, 0, false) {
- }
-
- public DWMA_Series(TBars source, int period) : this(source.Close, period, false) {
- }
-
- public DWMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {
- }
-
- public DWMA_Series(TSeries source, int period) : this(source, period, false) {
- }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(_buffer, TValue.v, _period, update);
- if (_period == 0) {
- _len++;
- _weights = CalculateWeights(_len);
- }
-
- double _dwma = 0, _wsum = 0;
- var bufferCount = _buffer.Count;
-
- var lockObj = new object();
- Parallel.For(0, bufferCount, i =>
- {
- var temp = _buffer[i] * _weights[i];
- lock (lockObj) {
- _dwma += temp;
- _wsum += _weights[i];
- }
- });
- _dwma /= _wsum;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _dwma);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) {
- return (DateTime.Today, double.NaN);
- }
-
- foreach (var item in data) {
- Add(item, false);
- }
-
- return _data.Last;
- }
-
- public (DateTime t, double v) Add(bool update) {
- return Add(_data.Last, update);
- }
-
- public (DateTime t, double v) Add() {
- return Add(_data.Last, false);
- }
-
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(_data.Last, e.update);
- }
-
- //calculating weights
- private static List CalculateWeights(int period) {
- var weights = new List(period);
- for (var i = 0; i < period; i++) {
- weights.Add((i + 1) * (i + 1));
- }
-
- return weights;
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- _buffer.Clear();
- _weights = CalculateWeights(_period);
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/EMA_Series.cs b/Calculations/_Updated/EMA_Series.cs
deleted file mode 100644
index 174d978a..00000000
--- a/Calculations/_Updated/EMA_Series.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-EMA: Exponential Moving Average
- EMA needs very short history buffer and calculates the EMA value using just the
- previous EMA value. The weight of the new datapoint (k) is k = 2 / (period-1)
-
-Sources:
- https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages
- https://www.investopedia.com/ask/answers/122314/what-exponential-moving-average-ema-formula-and-how-ema-calculated.asp
- https://blog.fugue88.ws/archives/2017-01/The-correct-way-to-start-an-Exponential-Moving-Average-EMA
-
-Issues:
- There is no consensus what the first EMA value should be - a zero, a first
- datapoint, or an average of the initial Period bars. All three starting methods
- converge within 20+ bars to the same moving average. Most implementations (including this one)
- use SMA() for the first Period bars as a seeding value for EMA.
-
- */
-
-public class EMA_Series : TSeries {
- private double _k;
- private double _lastema, _oldema;
- private double _sum, _oldsum;
- private int _len;
- private readonly bool _useSMA;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
-//core constructors
-
- public EMA_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- _useSMA = useSMA;
- Name = $"EMA({period})";
- _k = 2.0 / (_period + 1);
- _len = 0;
- _sum = _oldsum = _lastema = _oldema = 0;
- }
- public EMA_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public EMA_Series() : this(0, false, true) {}
- public EMA_Series(int period) : this(period, false, true) {}
- public EMA_Series(TBars source) : this(source.Close, 0, false) {}
- public EMA_Series(TBars source, int period) : this(source.Close, period, false) {}
- public EMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {}
- public EMA_Series(TSeries source, int period) : this(source, period, false, true) {}
- public EMA_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) {}
-
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) {
- _lastema = _oldema;
- _sum = _oldsum;
- }
- else {
- _oldema = _lastema;
- _oldsum = _sum;
- _len++;
- }
-
- double _ema = 0;
- if (_period == 0) {
- _k = 2.0 / (_len + 1);
- }
-
- if (Count == 0) {
- _ema = _sum = TValue.v;
- }
- else if (_len <= _period && _useSMA && _period != 0) {
- _sum += TValue.v;
- if (_period != 0 && _len > _period) {
- _sum -= _data[Count - _period - (update ? 1 : 0)].v;
- }
-
- _ema = _sum / Math.Min(_len, _period);
- }
- else {
- _ema = _k * (TValue.v - _lastema) + _lastema;
- }
-
- _lastema = double.IsNaN(_ema) ? _lastema : _ema;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _ema);
- return base.Add(res, update);
- }
-
-//variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _sum = _oldsum = _lastema = _oldema = 0;
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ENTROPY_Series.cs b/Calculations/_Updated/ENTROPY_Series.cs
deleted file mode 100644
index 27592dfd..00000000
--- a/Calculations/_Updated/ENTROPY_Series.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-ENTROPY:
- Introduced by Claude Shannon in 1948, entropy measures the unpredictability
- of the data, or equivalently, of its average information.
-
-Calculation:
- P = close / Σ(close)
- ENTROPY = Σ(-P * Log(P) / Log(base))
-
-Sources:
- https://en.wikipedia.org/wiki/Entropy_(information_theory)
- https://math.stackexchange.com/questions/3428693/how-to-calculate-entropy-from-a-set-of-correlated-samples
-
- */
-
-public class ENTROPY_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly double _logbase;
- private readonly System.Collections.Generic.List _buffer = new();
- private readonly System.Collections.Generic.List _buff2 = new();
-
- //core constructors
- public ENTROPY_Series(int period, double logbase, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- _logbase = logbase;
- Name = $"ENTROPY({period})";
- }
- public ENTROPY_Series(TSeries source, int period, double logbase, bool useNaN) : this(period, logbase, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public ENTROPY_Series() : this(period: 0, logbase: 2.0, useNaN: false) { }
- public ENTROPY_Series(int period) : this(period: period, logbase: 2.0, useNaN: false) { }
- public ENTROPY_Series(TBars source) : this(source.Close, period: 0, logbase: 2.0, useNaN: false) { }
- public ENTROPY_Series(TBars source, int period) : this(source.Close, period, logbase: 2.0, useNaN: false) { }
- public ENTROPY_Series(TBars source, int period, bool useNaN) : this(source.Close, period: period, logbase: 2.0, useNaN: useNaN) { }
- public ENTROPY_Series(TSeries source) : this(source, period: 0, logbase: 2.0, useNaN: false) { }
- public ENTROPY_Series(TSeries source, int period) : this(source: source, period: period, logbase: 2.0, useNaN: false) { }
- public ENTROPY_Series(TSeries source, int period, bool useNaN) : this(source: source, period: period, logbase: 2.0, useNaN: useNaN) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- double _sum = _buffer.Sum();
- double _pp = this._buffer[^1] / _sum;
- double _ppp = -_pp * Math.Log(_pp) / Math.Log(this._logbase);
- BufferTrim(_buff2, _ppp, _period, update);
- double _entp = _buff2.Sum();
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _entp);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- _buff2.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/FWMA_Series.cs b/Calculations/_Updated/FWMA_Series.cs
deleted file mode 100644
index 81134148..00000000
--- a/Calculations/_Updated/FWMA_Series.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using System.Numerics;
-using System.Linq;
-
-/*
-FWMA: Fibonacci's Weighted Moving Average is similar to a Weighted Moving Average
- (WMA) where the weights are based on the Fibonacci Sequence.
-
- */
-public class FWMA_Series : TSeries {
- private readonly List _buffer = new();
- private List _weights;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- protected int _len;
-
- public FWMA_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"FWMA({period})";
- _len = 0;
- _weights = CalculateWeights(_period);
- }
-
- public FWMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
- public FWMA_Series() : this(period: 0, useNaN: false) { }
- public FWMA_Series(int period) : this(period: period, useNaN: false) { }
- public FWMA_Series(TBars source) : this(source.Close, 0, false) { }
- public FWMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public FWMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public FWMA_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- if (_period == 0) {
- _len++;
- _weights = CalculateWeights(_len);
- }
- double _fwma = 0;
- double totalWeights = _weights.Sum();
- object lockObj = new object();
- Parallel.For(0, _buffer.Count, i =>
- {
- double temp = _buffer[i] * _weights[i];
- lock (lockObj) { _fwma += temp; }
- });
- _fwma /= totalWeights;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _fwma);
- return base.Add(res, update);
- }
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- private static List CalculateWeights(int period) {
- //to prevent overflow, max period can be no more than 1476
- period = (period > 1476) ? 1476 : period;
- List weights = new List(period);
- BigInteger a = 0;
- BigInteger b = 1;
- for (int i = 0; i < period; i++) {
- BigInteger temp = a;
- a = b;
- b = temp + b;
- weights.Add((double)Decimal.Parse(a.ToString()));
- }
- return weights;
- }
-
- public override void Reset() {
- _weights = CalculateWeights(_period);
- _buffer.Clear();
- }
-}
diff --git a/Calculations/_Updated/HEMA_Series.cs b/Calculations/_Updated/HEMA_Series.cs
deleted file mode 100644
index 60aacda4..00000000
--- a/Calculations/_Updated/HEMA_Series.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-HEMA: Hull-EMA Moving Average - a hybrid indicator
- Modified HUll Moving Average; instead of using WMA (Weighted MA) for calculation,
- HEMA uses EMA for Hull's formula:
-
-EMA1 = EMA(n/2) of price - where k = 4/(n/2 +1)
-EMA2 = EMA(n) of price - where k = 3/(n+1)
-Raw HMA = (2 * EMA1) - EMA2
-EMA3 = EMA(sqrt(n)) of Raw HMA - where k = 2/(sqrt(n)+1)
- */
-
-public class HEMA_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private double _k1, _k2, _k3;
- private int _len;
- private double _lastema1, _oldema1;
- private double _lastema2, _oldema2;
- private double _lasthema, _oldhema;
-
- //core constructors
- public HEMA_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"HEMA({period})";
- (_k1, _k2, _k3) = CalculateK(_period);
- _len = 0;
- _lastema1 = _oldema1 = _lastema2 = _oldema2 = _lasthema = _oldhema = 0;
- }
- public HEMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public HEMA_Series() : this(period: 0, useNaN: false) { }
- public HEMA_Series(int period) : this(period: period, useNaN: false) { }
- public HEMA_Series(TBars source) : this(source.Close, 0, false) { }
- public HEMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public HEMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public HEMA_Series(TSeries source) : this(source, 0, false) { }
- public HEMA_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) {
- _lastema1 = _oldema1;
- _lastema2 = _oldema2;
- _lasthema = _oldhema;
- }
- else {
- _oldema1 = _lastema1;
- _oldema2 = _lastema2;
- _oldhema = _lasthema;
- }
- double _ema1, _ema2, _hema;
- if (_period == 0) {
- _len++;
- (_k1, _k2, _k3) = CalculateK(_len);
- }
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, double.NaN), update);
- } else if (this.Count == 0) {
- _ema1 = _ema2 = _hema = TValue.v;
- }
- else {
- _ema1 = _k1 * (TValue.v - _lastema1) + _lastema1;
- _ema2 = _k2 * (TValue.v - _lastema2) + _lastema2;
- _hema = _k3 * (((2 * _ema1) - _ema2) - _lasthema) + _lasthema;
- }
-
- _lastema1 = _ema1;
- _lastema2 = _ema2;
- _lasthema = _hema;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _hema);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _lastema1 = _lastema2 = _lasthema = 0;
- _oldema1 = _oldema2 = _oldhema = 0;
- _len = 0;
- }
-
- public static (double k1, double k2, double k3) CalculateK(int len) {
- double k1 = 8 / (double)(len + 7);
- double k2 = 3 / (double)(len + 2);
- double k3 = 2 / Math.Sqrt(len + 3);
-
- return (k1, k2, k3);
- }
-
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/HMA_Series.cs b/Calculations/_Updated/HMA_Series.cs
deleted file mode 100644
index 01736639..00000000
--- a/Calculations/_Updated/HMA_Series.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-HMA: Hull Moving Average
- Developed by Alan Hull, an extremely fast and smooth moving average; almost
- eliminates lag altogether and manages to improve smoothing at the same time.
-
-Sources:
- https://alanhull.com/hull-moving-average
- https://school.stockcharts.com/doku.php?id=technical_indicators:hull_moving_average
-
-WMA1 = WMA(n/2) of price
-WMA2 = WMA(n) of price
-Raw HMA = (2 * WMA1) - WMA2
-HMA = WMA(sqrt(n)) of Raw HMA
-
- */
-
-public class HMA_Series : TSeries {
- protected int _period, _period2, _psqrt;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- protected WMA_Series _wma1, _wma2, _wma3;
-
- //core constructors
- public HMA_Series(int period, bool useNaN) {
- _period = period;
- _period2 = period /2;
- _psqrt = (int)Math.Sqrt(period);
- _NaN = useNaN;
- _wma1 = new(Math.Max(_period2,1), false);
- _wma2 = new(Math.Max(_period,1), false);
- _wma3 = new(Math.Max(_psqrt,1), useNaN);
- Name = $"HMA({period})";
- }
- public HMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public HMA_Series() : this(period: 0, useNaN: false) { }
- public HMA_Series(int period) : this(period: period, useNaN: false) { }
- public HMA_Series(TBars source) : this(source.Close, 0, false) { }
- public HMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public HMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public HMA_Series(TSeries source) : this(source, 0, false) { }
- public HMA_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (_period == 0) {
- _wma1.Len = this.Count / 2;
- _wma2.Len = this.Count;
- _wma1.Len = (int)Math.Sqrt(this.Count);
- }
- double _w1 = _wma1.Add(TValue, update).v;
- double _w2 = _wma2.Add(TValue, update).v;
- double _hma = _wma3.Add((2 * _w1) - _w2, update).v;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _hma);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _wma1.Reset();
- _wma2.Reset();
- _wma3.Reset();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/HWMA_Series.cs b/Calculations/_Updated/HWMA_Series.cs
deleted file mode 100644
index 8f360b52..00000000
--- a/Calculations/_Updated/HWMA_Series.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-HWMA: Holt-Winter Moving Average
- Indicator HWMA (Holt-Winter Moving Average) is a three-parameter moving
- average by the Holt-Winter method; Holt-Winters Exponential Smoothing is
- used for forecasting time series data that exhibits both a trend and a
- seasonal variation.
-
-
-Sources:
- https://timeseriesreasoning.com/contents/holt-winters-exponential-smoothing/
- https://www.mql5.com/en/code/20856
-
-nA - smoothed series (from 0 to 1)
-nB - assess the trend (from 0 to 1)
-nC - assess seasonality (from 0 to 1)
-
-Heuristic for determining alpha, beta, and gamma from period:
- alpha = 2 / (1 + period)
- beta = 1 / period
- gamma = 1 / period
-
-F[i] = (1-nA) * (F[i-1] + V[i-1] + 0.5 * A[i-1]) + nA * Price[i]
-V[i] = (1-nB) * (V[i-1] + A[i-1]) + nB * (F[i] - F[i-1])
-A[i] = (1-nC) * A[i-1] + nC * (V[i] - V[i-1])
-HWMA[i] = F[i] + V[i] + 0.5 * A[i]
-
- */
-
-public class HWMA_Series : TSeries {
- private int _len;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- double _nA, _nB, _nC;
- double _pF, _pV, _pA;
- double _ppF, _ppV, _ppA;
-
- //core constructors
-
- public HWMA_Series(double nA, double nB, double nC, bool useNaN) {
- _period = (int)((2 - nA) / nA);
- _nA = nA;
- _nB = nB;
- _nC = nC;
- _NaN = useNaN;
- Name = $"HWMA({_period})";
- _len = 0;
- }
- public HWMA_Series(TSeries source, double nA, double nB, double nC, bool useNaN = false) : this(nA, nB, nC, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public HWMA_Series() : this(period: 0, useNaN: false) { }
- public HWMA_Series(int period) : this(period, useNaN: false) { }
- public HWMA_Series(int period, bool useNaN) : this(nA: 2 / (1 + (double)period), nB: 1 / (double)period, nC: 1 / (double)period, useNaN) {
- _period = period;
- }
- public HWMA_Series(TBars source) : this(source.Close, period: 0, useNaN: false) { }
- public HWMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public HWMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public HWMA_Series(TSeries source, int period) : this(source, period, false) { }
- public HWMA_Series(TSeries source, int period, bool useNaN) : this(source, nA: 2 / (1 + (double)period), nB: 1 / (double)period, nC: 1 / (double)period, useNaN: useNaN) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
- double _F, _V, _A;
- if (_len == 0) { _pF = TValue.v; _pA = _pV = 0; }
-
- if (update) { _pF = _ppF; _pV = _ppV; _pA = _ppA; }
- else {
- _ppF = _pF;
- _ppV = _pV;
- _ppA = _pA;
- _len++;
- }
-
- if (_period == 0) {
- _nA = 2 / (1 + (double)_len);
- _nB = 1 / (double)_len;
- _nC = 1 / (double)_len;
- }
- if (_period == 1) {
- _nA = 1;
- _nB = 0;
- _nC = 0;
- }
-
- _F = (1 - _nA) * (_pF + _pV + 0.5 * _pA) + _nA * TValue.v;
- _V = (1 - _nB) * (_pV + _pA) + _nB * (_F - _pF);
- _A = (1 - _nC) * _pA + _nC * (_V - _pV);
-
- double _hwma = _F + _V + 0.5 * _A;
- _pF = _F;
- _pV = _V;
- _pA = _A;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _hwma);
- return base.Add(res, update);
- }
-
- //variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/KAMA_Series.cs b/Calculations/_Updated/KAMA_Series.cs
deleted file mode 100644
index 74065605..00000000
--- a/Calculations/_Updated/KAMA_Series.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-KAMA: Kaufman's Adaptive Moving Average
- Created in 1988 by American quantitative finance theorist Perry J. Kaufman and is known as
- Kaufman's Adaptive Moving Average (KAMA). Even though the method was developed as early as 1972,
- it was not until the popular book titled "Trading Systems and Methods" that it was made widely
- available to the public. Unlike other conventional moving averages systems, the Kaufman's Adaptive
- Moving Average, considers market volatility apart from price fluctuations.
-
- KAMA[i] = KAMA[i-1] + SC * ( price - KAMA[i-1] )
-
-Sources:
- https://www.tutorialspoint.com/kaufman-s-adaptive-moving-average-kama-formula-and-how-does-it-work
- https://corporatefinanceinstitute.com/resources/knowledge/trading-investing/kaufmans-adaptive-moving-average-kama/
- https://www.technicalindicators.net/indicators-technical-analysis/152-kama-kaufman-adaptive-moving-average
-
-Remark:
- If useNaN:true argument is provided, KAMA starts calculating values from [period] bar onwards.
- Without useNaN argument (default setting), KAMA starts calculating values from bar 1 - and yields
- slightly different results for the first 50 bars - and then converges with the other one.
-
- */
-
-public class KAMA_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- private double _lastkama, _lastlastkama;
- private readonly double _scFast, _scSlow;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public KAMA_Series(int period, int fast, int slow, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- _scFast = 2.0 / (((period < fast) ? period : fast) + 1);
- _scSlow = 2.0 / (slow + 1);
- _lastkama = _lastlastkama = 0;
- Name = $"KAMA({period})";
- }
- public KAMA_Series(TSeries source, int period, int fast, int slow, bool useNaN) : this(period, fast, slow, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public KAMA_Series() : this(period: 0, fast: 2, slow: 30, useNaN: false) { }
- public KAMA_Series(int period) : this(period: period, fast: 2, slow: 30, useNaN: false) { }
- public KAMA_Series(TBars source) : this(source.Close, period: 0, fast: 2, slow: 30, useNaN: false) { }
- public KAMA_Series(TBars source, int period) : this(source.Close, period: period, fast: 2, slow: 30, useNaN: false) { }
- public KAMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period: period, fast: 2, slow: 30, useNaN: useNaN) { }
- public KAMA_Series(TSeries source) : this(source, period: 0, fast: 2, slow: 30, useNaN: false) { }
- public KAMA_Series(TSeries source, int period) : this(source: source, period: period, fast: 2, slow: 30, useNaN: false) { }
- public KAMA_Series(TSeries source, int period, bool useNaN) : this(source: source, period: period, fast: 2, slow: 30, useNaN: useNaN) { }
- public KAMA_Series(TSeries source, int period, int fast, int slow) : this(source: source, period: period, fast: fast, slow: slow, useNaN: false) { }
-
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
-
- if (update) { _lastkama = _lastlastkama; }
- else { _lastlastkama = _lastkama; }
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period + 1, update: update);
-
- double _kama = 0;
- if (this.Count < _period) { _kama = TValue.v; }
- else {
- double _change = Math.Abs(_buffer[^1] - _buffer[(_buffer.Count > _period + 1) ? 1 : 0]);
- double _sumpv = 0;
- for (int i = 1; i < _buffer.Count; i++) { _sumpv += Math.Abs(_buffer[(_buffer.Count > 0) ? i : 0] - _buffer[i - 1]); }
- double _er = (_sumpv == 0) ? 0 : _change / _sumpv;
- double _sc = (_er * (_scFast - _scSlow)) + _scSlow;
- _kama = (_lastkama + (_sc * _sc * (TValue.v - _lastkama)));
- }
- _lastkama = _kama;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _kama);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- _lastkama = _lastlastkama = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/KURTOSIS_Series.cs b/Calculations/_Updated/KURTOSIS_Series.cs
deleted file mode 100644
index 2c4e10c8..00000000
--- a/Calculations/_Updated/KURTOSIS_Series.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-KURTOSIS: Kurtosis of population
- Kurtosis characterizes the relative peakedness or flatness of a distribution
- compared with the normal distribution. Positive kurtosis indicates a relatively
- peaked distribution. Negative kurtosis indicates a relatively flat distribution.
-
- The normal curve is called Mesokurtic curve. If the curve of a distribution is
- more outlier prone (or heavier-tailed) than a normal or mesokurtic curve then
- it is referred to as a Leptokurtic curve. If a curve is less outlier prone (or
- lighter-tailed) than a normal curve, it is called as a platykurtic curve.
-
-Calculation:
- sum4 = Σ(close-SMA)^4
- sum2 = (Σ(close-SMA)^2)^2
- KURTOSIS = length * (sum4/sum2)
-
-Sources:
- https://en.wikipedia.org/wiki/Kurtosis
- https://stats.oarc.ucla.edu/other/mult-pkg/faq/general/faq-whats-with-the-different-formulas-for-kurtosis/
-
- */
-
-public class KURTOSIS_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly System.Collections.Generic.List _buffer = new();
-
- //core constructors
- public KURTOSIS_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"KURTOSIS({period})";
- }
- public KURTOSIS_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public KURTOSIS_Series() : this(period: 0, useNaN: false) { }
- public KURTOSIS_Series(int period) : this(period: period, useNaN: false) { }
- public KURTOSIS_Series(TSeries source) : this(source, period: 0, useNaN: false) { }
- public KURTOSIS_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
-
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- double _n = _buffer.Count;
- double _avg = _buffer.Average();
-
- double _s2 = 0;
- double _s4 = 0;
- for (int i = 0; i < this._buffer.Count; i++) {
- _s2 += (_buffer[i] - _avg) * (_buffer[i] - _avg);
- _s4 += (_buffer[i] - _avg) * (_buffer[i] - _avg) * (_buffer[i] - _avg) * (_buffer[i] - _avg);
- }
-
- double _Vx = _s2 / (_n - 1);
- double _kurt = (_n > 3) ?
- (_n * (_n + 1) * _s4) / (_Vx * _Vx * (_n - 3) * (_n - 1) * (_n - 2)) - (3 * (_n - 1) * (_n - 1) / ((_n - 2) * (_n - 3))) //using Sheskin Algo
- : (_s2 * _s2) / _n - 3; //using Snedecor and Cochran (1967) algo
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _kurt);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MACD_Series.cs b/Calculations/_Updated/MACD_Series.cs
deleted file mode 100644
index 20d8c86b..00000000
--- a/Calculations/_Updated/MACD_Series.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MACD: Moving Average Convergence/Divergence
- Moving average convergence divergence (MACD) is a trend-following momentum
- indicator that shows the relationship between two moving averages of a series.
- The MACD is calculated by subtracting the 26-period exponential moving average (EMA)
- from the 12-period EMA. MACD Signal is 9-day EMA of MACD.
-
- */
-
-public class MACD_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
-
- protected readonly int _slow, _fast, _signal;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly EMA_Series _TSlow;
- private readonly EMA_Series _TFast;
- public EMA_Series Signal { get; }
-
- //core constructors
- public MACD_Series(int slow = 26, int fast = 12, int signal = 9, bool useNaN = false) {
- _slow = slow;
- _fast = fast;
- _signal = signal;
- _NaN = useNaN;
- Name = $"MACD({slow},{fast},{signal})";
- _TSlow = new(slow, useNaN:false, useSMA:true);
- _TFast = new(fast, useNaN: false, useSMA: true);
- Signal = new(signal, useNaN: false, useSMA: true);
- }
- public MACD_Series(TSeries source, int slow, int fast, int signal, bool useNaN) : this(slow, fast, signal, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MACD_Series(TSeries source) : this(source:source, slow:26, fast:12, signal:9 , useNaN:false) { }
- public MACD_Series(TSeries source, int slow, int fast, int signal) : this(source: source, slow: slow, fast:fast, signal:signal, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
-
- var _sslow = _TSlow.Add(TValue,update);
- var _sfast = _TFast.Add(TValue, update);
- Signal.Add((TValue.t, _sfast.v-_sslow.v));
-
- var res = (TValue.t, Count < _fast - 1 && _NaN ? double.NaN : _sfast.v-_sslow.v);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MAD_Series.cs b/Calculations/_Updated/MAD_Series.cs
deleted file mode 100644
index 4f18a04b..00000000
--- a/Calculations/_Updated/MAD_Series.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MAD: Mean Absolute Deviation
- Also known as AAD - Average Absolute Deviation, to differentiate it from Median Absolute Deviation
- MAD defines the degree of variation across the series.
-
-Calculation:
- MAD = Σ(|close-SMA|) / period
-
-Sources:
- https://en.wikipedia.org/wiki/Average_absolute_deviation
-
- */
-
-public class MAD_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MAD_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MAD({period})";
- }
- public MAD_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MAD_Series() : this(period: 0, useNaN: false) { }
- public MAD_Series(int period) : this(period: period, useNaN: false) { }
- public MAD_Series(TBars source) : this(source.Close, 0, false) { }
- public MAD_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MAD_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MAD_Series(TSeries source) : this(source, 0, false) { }
- public MAD_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
- double _mad = 0;
- for (int i = 0; i < _buffer.Count; i++) { _mad += Math.Abs(_buffer[i] - _sma); }
- _mad /= this._buffer.Count;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _mad);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MAE_Series.cs b/Calculations/_Updated/MAE_Series.cs
deleted file mode 100644
index 9bf7a6a9..00000000
--- a/Calculations/_Updated/MAE_Series.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MAE: Mean Absolute Error
- Defined as a Mean (Average) of the absolute difference between actual and estimated values.
- MAE = (1/n) * Σ|y_i - MA_i|
-
-Sources:
- https://en.wikipedia.org/wiki/Mean_absolute_error
-
- */
-
-public class MAE_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MAE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MSE({period})";
- }
- public MAE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MAE_Series() : this(period: 0, useNaN: false) { }
- public MAE_Series(int period) : this(period: period, useNaN: false) { }
- public MAE_Series(TBars source) : this(source.Close, 0, false) { }
- public MAE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MAE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MAE_Series(TSeries source) : this(source, 0, false) { }
- public MAE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _mae = 0;
- for (int i = 0; i < _buffer.Count; i++) { _mae += Math.Abs(_buffer[i] - _sma); }
- _mae /= this._buffer.Count;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _mae);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MAMA_Series.cs b/Calculations/_Updated/MAMA_Series.cs
deleted file mode 100644
index c4dd2a51..00000000
--- a/Calculations/_Updated/MAMA_Series.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-MAMA: MESA Adaptive Moving Average
- Created by John Ehlers, the MAMA indicator is a 5-period adaptive moving average of
- high/low price that uses classic electrical radio-frequency signal processing algorithms
- to reduce noise.
-
- KAMAi = KAMAi - 1 + SC * ( price - KAMAi-1 )
-
-Sources:
- https://mesasoftware.com/papers/MAMA.pdf
- https://www.tradingview.com/script/foQxLbU3-Ehlers-MESA-Adaptive-Moving-Average-LazyBear/
-
- */
-
-public class MAMA_Series : TSeries {
- private int _len;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- private double sumPr;
- private double fastl, slowl;
- private (double i, double i1, double i2, double i3, double i4, double i5, double i6, double io) pr, i1, q1, sm, dt;
- private (double i, double i1, double io) i2, q2, re, im, pd, ph, mama, fama;
- public TSeries Fama { get; }
- private double mamaseed, famaseed;
-
- //core constructors
-
- public MAMA_Series(double fastlimit, double slowlimit, bool useNaN) {
- _period = (int)(2 / fastlimit) - 1;
- fastl = fastlimit;
- slowl = slowlimit;
- Fama = new TSeries();
- _NaN = useNaN;
- Name = $"MAMA({_period})";
- _len = 0;
- }
- public MAMA_Series(TSeries source, double fastlimit, double slowlimit, bool useNaN = false) : this(fastlimit, slowlimit, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MAMA_Series() : this(period: 0, useNaN: false) { }
- public MAMA_Series(int period) : this(period, useNaN: false) { }
- public MAMA_Series(int period, bool useNaN) : this(fastlimit: 2 / (period + 1), slowlimit: 0.2 / (period + 1), useNaN) {
- _period = period;
- }
- public MAMA_Series(TBars source) : this(source.Close, period: 0, useNaN: false) { }
- public MAMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MAMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MAMA_Series(TSeries source, int period) : this(source, period, false) { }
- public MAMA_Series(TSeries source, int period, bool useNaN) : this(source, fastlimit: 2 / ((double)period + 1), slowlimit: 0.2 / ((double)period + 1), useNaN: useNaN) { }
-
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
- if (!update) {
- // roll forward (oldx = x)
- pr.io = pr.i6; pr.i6 = pr.i5; pr.i5 = pr.i4; pr.i4 = pr.i3; pr.i3 = pr.i2; pr.i2 = pr.i1; pr.i1 = pr.i;
- i1.io = i1.i6; i1.i6 = i1.i5; i1.i5 = i1.i4; i1.i4 = i1.i3; i1.i3 = i1.i2; i1.i2 = i1.i1; i1.i1 = i1.i;
- q1.io = q1.i6; q1.i6 = q1.i5; q1.i5 = q1.i4; q1.i4 = q1.i3; q1.i3 = q1.i2; q1.i2 = q1.i1; q1.i1 = q1.i;
- dt.io = dt.i6; dt.i6 = dt.i5; dt.i5 = dt.i4; dt.i4 = dt.i3; dt.i3 = dt.i2; dt.i2 = dt.i1; dt.i1 = dt.i;
- sm.io = sm.i6; sm.i6 = sm.i5; sm.i5 = sm.i4; sm.i4 = sm.i3; sm.i3 = sm.i2; sm.i2 = sm.i1; sm.i1 = sm.i;
- i2.io = i2.i1; i2.i1 = i2.i; q2.io = q2.i1; q2.i1 = q2.i;
- re.io = re.i1; re.i1 = re.i; im.io = im.i1; im.i1 = im.i;
- pd.io = pd.i1; pd.i1 = pd.i; ph.io = ph.i1; ph.i1 = ph.i;
- mama.io = mama.i1; mama.i1 = mama.i;
- fama.io = fama.i1;
- fama.i1 = fama.i;
- _len++;
- }
- if (_period == 0) {
- fastl = 2 / (double)_len;
- slowl = fastl * 0.1;
- }
- if (_period == 1) {
- fastl = 1;
- slowl = 1;
- }
- var i = _len - 1;
- pr.i = TValue.v;
- if (i > 5) {
- var adj = 0.075 * pd.i1 + 0.54;
-
- // smooth and detrender
- sm.i = (4 * pr.i + 3 * pr.i1 + 2 * pr.i2 + pr.i3) / 10;
- dt.i = (0.0962 * sm.i + 0.5769 * sm.i2 - 0.5769 * sm.i4 - 0.0962 * sm.i6) * adj;
-
- // in-phase and quadrature
- q1.i = (0.0962 * dt.i + 0.5769 * dt.i2 - 0.5769 * dt.i4 - 0.0962 * dt.i6) * adj;
- i1.i = dt.i3;
-
- // advance the phases by 90 degrees
- double jI = (0.0962 * i1.i + 0.5769 * i1.i2 - 0.5769 * i1.i4 - 0.0962 * i1.i6) * adj;
- double jQ = (0.0962 * q1.i + 0.5769 * q1.i2 - 0.5769 * q1.i4 - 0.0962 * q1.i6) * adj;
-
- // phasor addition for 3-bar averaging
- i2.i = i1.i - jQ;
- q2.i = q1.i + jI;
-
- i2.i = 0.2 * i2.i + 0.8 * i2.i1; // smoothing it
- q2.i = 0.2 * q2.i + 0.8 * q2.i1;
-
- // homodyne discriminator
- re.i = i2.i * i2.i1 + q2.i * q2.i1;
- im.i = i2.i * q2.i1 - q2.i * i2.i1;
-
- re.i = 0.2 * re.i + 0.8 * re.i1; // smoothing it
- im.i = 0.2 * im.i + 0.8 * im.i1;
-
- // calculate period
- pd.i = im.i != 0 && re.i != 0 ? 6.283185307179586 / Math.Atan(im.i / re.i) : 0d;
-
- // adjust period to thresholds
- pd.i = pd.i > 1.5 * pd.i1 ? 1.5 * pd.i1 : pd.i;
- pd.i = pd.i < 0.67 * pd.i1 ? 0.67 * pd.i1 : pd.i;
- pd.i = pd.i < 6d ? 6d : pd.i;
- pd.i = pd.i > 50d ? 50d : pd.i;
-
- // smooth the period
- pd.i = 0.2 * pd.i + 0.8 * pd.i1;
-
- // determine phase position
- ph.i = i1.i != 0 ? Math.Atan(q1.i / i1.i) * 57.29577951308232 : 0;
-
- // change in phase
- var delta = Math.Max(ph.i1 - ph.i, 1d);
-
- // adaptive alpha value
- var alpha = Math.Max(fastl / delta, slowl);
-
- // final indicators
- mama.i = alpha * (pr.i - mama.i1) + mama.i1;
- fama.i = 0.5d * alpha * (mama.i - fama.i1) + fama.i1;
- }
- else {
- sumPr += pr.i;
- pd.i = sm.i = dt.i = i1.i = q1.i = i2.i = q2.i = re.i = im.i = ph.i = 0;
- mama.i = fama.i = sumPr / (i + 1);
-
- if (_len == 1) {
- mamaseed = famaseed = TValue.v;
- }
- else {
- mamaseed = fastl * (TValue.v - mamaseed) + mamaseed;
- famaseed = slowl * (TValue.v - famaseed) + famaseed;
- }
- }
-
- double _fama = (i > 5) ? fama.i : famaseed;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _fama);
- Fama.Add(res, update);
- double _mama = (i > 5) ? mama.i : mamaseed;
- res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _mama);
- return base.Add(res, update);
- }
-
- //variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MAPE_Series.cs b/Calculations/_Updated/MAPE_Series.cs
deleted file mode 100644
index 944daf86..00000000
--- a/Calculations/_Updated/MAPE_Series.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MAPE: Mean Absolute Percentage Error
- Measures the size of the error in percentage terms
-
-Calculation:
- MAPE = Σ(|close – SMA| / |close|) / n
-
-Sources:
- https://en.wikipedia.org/wiki/Mean_absolute_percentage_error
-
-Remark:
- returns infinity if any of observations is 0.
- Use SMAPE or WMAPE instead to avoid division-by-zero in MAPE
-
- */
-
-public class MAPE_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MAPE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MAPE({period})";
- }
- public MAPE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MAPE_Series() : this(period: 0, useNaN: false) { }
- public MAPE_Series(int period) : this(period: period, useNaN: false) { }
- public MAPE_Series(TBars source) : this(source.Close, 0, false) { }
- public MAPE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MAPE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MAPE_Series(TSeries source) : this(source, 0, false) { }
- public MAPE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _mape = 0;
- for (int i = 0; i < _buffer.Count; i++) {
- _mape += (_buffer[i] != 0) ? Math.Abs(_buffer[i] - _sma) / Math.Abs(_buffer[i]) : double.PositiveInfinity;
- }
- _mape /= (_buffer.Count > 0) ? _buffer.Count : 1;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _mape);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MAX_Series.cs b/Calculations/_Updated/MAX_Series.cs
deleted file mode 100644
index 8a2facff..00000000
--- a/Calculations/_Updated/MAX_Series.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MAX - Maximum value in the given period in the series.
- If period = 0 => period = full length of the series
-
- */
-
-public class MAX_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MAX_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MAX({period})";
- }
- public MAX_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MAX_Series() : this(period: 0, useNaN: false) { }
- public MAX_Series(int period) : this(period: period, useNaN: false) { }
- public MAX_Series(TBars source) : this(source.Close, 0, false) { }
- public MAX_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MAX_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MAX_Series(TSeries source) : this(source, 0, false) { }
- public MAX_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _max= _buffer.Max();
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _max);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MEDIAN_Series.cs b/Calculations/_Updated/MEDIAN_Series.cs
deleted file mode 100644
index fde7c634..00000000
--- a/Calculations/_Updated/MEDIAN_Series.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MED - Median value
- Median of numbers is the middlemost value of the given set of numbers.
- It separates the higher half and the lower half of a given data sample.
- At least half of the observations are smaller than or equal to median
- and at least half of the observations are greater than or equal to the median.
-
- If the number of values is odd, the middlemost observation of the sorted
- list is the median of the given data. If the number of values is even,
- median is the average of (n/2)th and [(n/2) + 1]th values of the sorted list.
-
- If period = 0 => period is max
-
-Sources:
- https://corporatefinanceinstitute.com/resources/knowledge/other/median/
- https://en.wikipedia.org/wiki/Median
-
- */
-
-public class MEDIAN_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MEDIAN_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MEDIAN({period})";
- }
- public MEDIAN_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MEDIAN_Series() : this(period: 0, useNaN: false) { }
- public MEDIAN_Series(int period) : this(period: period, useNaN: false) { }
- public MEDIAN_Series(TBars source) : this(source.Close, 0, false) { }
- public MEDIAN_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MEDIAN_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MEDIAN_Series(TSeries source) : this(source, 0, false) { }
- public MEDIAN_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- System.Collections.Generic.List _s = new(this._buffer);
- _s.Sort();
- int _p1 = _s.Count / 2;
- int _p2 = Math.Max(0, (_s.Count / 2) - 1);
- double _med = (_s.Count % 2 != 0) ? _s[_p1] : (_s[_p1] + _s[_p2]) / 2;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _med);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MIDPOINT_Series.cs b/Calculations/_Updated/MIDPOINT_Series.cs
deleted file mode 100644
index c410be23..00000000
--- a/Calculations/_Updated/MIDPOINT_Series.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MIDPOINT: Midpoint value (max+min)/2 in the given period in the series.
- If period = 0 => period = full length of the series
-
-Sources:
- https://thefaqblog.com/what-is-the-midpoint-in-statistics/
-
- */
-
-public class MIDPOINT_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MIDPOINT_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MIDPOINT({period})";
- }
- public MIDPOINT_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MIDPOINT_Series() : this(period: 0, useNaN: false) { }
- public MIDPOINT_Series(int period) : this(period: period, useNaN: false) { }
- public MIDPOINT_Series(TBars source) : this(source.Close, 0, false) { }
- public MIDPOINT_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MIDPOINT_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MIDPOINT_Series(TSeries source) : this(source, 0, false) { }
- public MIDPOINT_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _max= _buffer.Max();
- double _min = _buffer.Min();
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : (_max+_min)*0.5);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MIDPRICE_Series.cs b/Calculations/_Updated/MIDPRICE_Series.cs
deleted file mode 100644
index 5b2bf73f..00000000
--- a/Calculations/_Updated/MIDPRICE_Series.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-MIDPRICE: Midpoint price (highhest high + lowest low)/2 in the given period in the series.
- If period = 0 => period = full length of the series
-
- */
-
-public class MIDPRICE_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TBars _data;
- private readonly System.Collections.Generic.List _bufferhi = new();
- private readonly System.Collections.Generic.List _bufferlo = new();
-
- //core constructors
- public MIDPRICE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MIDPRICE({period})";
- }
- public MIDPRICE_Series(TBars source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(data: _data);
- }
- public MIDPRICE_Series() : this(period: 2, useNaN: false) { }
- public MIDPRICE_Series(int period) : this(period: period, useNaN: false) { }
- public MIDPRICE_Series(TBars source) : this(source, period: 2, useNaN: false) { }
- public MIDPRICE_Series(TBars source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- BufferTrim(_bufferhi, TBar.h, _period, update);
- BufferTrim(_bufferlo, TBar.l, _period, update);
- double _mid = (_bufferhi.Max() + _bufferlo.Min()) * 0.5;
-
- var res = (TBar.t, Count < _period - 1 && _NaN ? double.NaN : _mid);
- return base.Add(res, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _bufferhi.Clear();
- _bufferlo.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MIN_Series.cs b/Calculations/_Updated/MIN_Series.cs
deleted file mode 100644
index 2b34aa7b..00000000
--- a/Calculations/_Updated/MIN_Series.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MIN - Minimum value in the given period in the series.
- If period = 0 => period = full length of the series
-
- */
-
-public class MIN_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MIN_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MAX({period})";
- }
- public MIN_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MIN_Series() : this(period: 0, useNaN: false) { }
- public MIN_Series(int period) : this(period: period, useNaN: false) { }
- public MIN_Series(TBars source) : this(source.Close, 0, false) { }
- public MIN_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MIN_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MIN_Series(TSeries source) : this(source, 0, false) { }
- public MIN_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _max= _buffer.Min();
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _max);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/MSE_Series.cs b/Calculations/_Updated/MSE_Series.cs
deleted file mode 100644
index a918962e..00000000
--- a/Calculations/_Updated/MSE_Series.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-MSE: Mean Square Error
- Defined as a Mean (Average) of the Square of the difference between actual and estimated values.
-
-Sources:
- https://en.wikipedia.org/wiki/Mean_squared_error
-
- */
-
-public class MSE_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public MSE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"MSE({period})";
- }
- public MSE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public MSE_Series() : this(period: 0, useNaN: false) { }
- public MSE_Series(int period) : this(period: period, useNaN: false) { }
- public MSE_Series(TBars source) : this(source.Close, 0, false) { }
- public MSE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public MSE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public MSE_Series(TSeries source) : this(source, 0, false) { }
- public MSE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _mse = 0;
- for (int i = 0; i < _buffer.Count; i++) { _mse += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
- _mse /= this._buffer.Count;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _mse);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/OBV_Series.cs b/Calculations/_Updated/OBV_Series.cs
deleted file mode 100644
index 40aa2c6e..00000000
--- a/Calculations/_Updated/OBV_Series.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-OBV: On-Balance Volume
- On-balance volume (OBV) is a technical trading momentum indicator that uses volume flow to predict
- changes in stock price. Joseph Granville first developed the OBV metric in the 1963 book
- Granville's New Key to Stock Market Profits.
-
- | +volume; if close > close[previous]
- OBV = OBV[previous] + | 0; if close = close[previous]
- | -volume; if close < close[previous]
-
-Sources:
- https://www.investopedia.com/terms/o/onbalancevolume.asp
- https://www.tradingview.com/wiki/On_Balance_Volume_(OBV)
- https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/on-balance-volume-obv/
- https://www.motivewave.com/studies/on_balance_volume.htm
-
-Note:
- There is no consensus on what is the first OBV value in the series:
- - TA-LIB uses the first volume: OBV[0] = volume[0]
- - Skender stock library uses 0: OBV[0] = 0
-
- */
-
-public class OBV_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TBars _data;
- private double _lastobv, _lastlastobv;
- private double _lastclose, _lastlastclose;
-
- //core constructors
- public OBV_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"OBV({period})";
- this._lastobv = this._lastlastobv = 0;
- this._lastclose = this._lastlastclose = 0;
- }
- public OBV_Series(TBars source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(data: _data);
- }
- public OBV_Series() : this(period: 2, useNaN: false) { }
- public OBV_Series(int period) : this(period: period, useNaN: false) { }
- public OBV_Series(TBars source) : this(source, period: 2, useNaN: false) { }
- public OBV_Series(TBars source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
-
- if (update) {
- this._lastobv = this._lastlastobv;
- this._lastclose = this._lastlastclose;
- }
-
- double _obv = this._lastobv;
- if (TBar.c > this._lastclose) { _obv += TBar.v; }
- if (TBar.c < this._lastclose) { _obv -= TBar.v; }
-
- this._lastlastobv = this._lastobv;
- this._lastobv = _obv;
-
- this._lastlastclose = this._lastclose;
- this._lastclose = TBar.c;
-
- var res = (TBar.t, (this.Count < this._period && this._NaN) ? double.NaN : _obv);
- return base.Add(res, update);
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- this._lastobv = this._lastlastobv = 0;
- this._lastclose = this._lastlastclose = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/RMA_Series.cs b/Calculations/_Updated/RMA_Series.cs
deleted file mode 100644
index 5a624bd9..00000000
--- a/Calculations/_Updated/RMA_Series.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-RMA: wildeR Moving Average
- J. Welles Wilder introduced RMA as an alternative to EMA. RMA's weight (k) is
- set as 1/period, giving less weight to the new data compared to EMA.
-
-Sources:
- https://archive.org/details/newconceptsintec00wild/page/23/mode/2up
- https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/WildersSmoothing
- https://www.incrediblecharts.com/indicators/wilder_moving_average.php
-
-Issues:
- Pandas-TA library calculates RMA using straight Exponential Weighted Mean:
- pandas.ewm().mean() and returns incorrect first (period) of bars compared to
- published formula. This implementation passess the validation test in Wilder's book.
-
- */
-
-public class RMA_Series : TSeries {
- private double _k;
- private double _lastrma, _oldrma;
- private double _sum, _oldsum;
- private readonly bool _useSMA;
- private int _len;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
-//core constructor
- public RMA_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- _useSMA = useSMA;
- Name = $"RMA({period})";
- _k = 1.0 / (double)(this._period);
- _len = 0;
- _sum = _oldsum = _lastrma = _oldrma = 0;
- }
- //generic constructors (source)
-
- public RMA_Series() : this(0, false, true) {}
- public RMA_Series(int period) : this(period, false, true) {}
- public RMA_Series(TBars source) : this(source.Close, 0, false) {}
- public RMA_Series(TBars source, int period) : this(source.Close, period, false) {}
- public RMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {}
- public RMA_Series(TSeries source, int period) : this(source, period, false, true) {}
- public RMA_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) {}
- public RMA_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
-// core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) {
- _lastrma = _oldrma;
- _sum = _oldsum;
- }
- else {
- _oldrma = _lastrma;
- _oldsum = _sum;
- _len++;
- }
-
- double _rma = 0;
- if (_period == 0) {
- _k = 1.0 / (double)(this._len);
- }
-
- if (Count == 0) {
- _rma = _sum = TValue.v;
-
- } else if (_len <= _period && _useSMA && _period != 0) {
- _sum += TValue.v;
- if (_period != 0 && _len > _period) {
- _sum -= _data[Count - _period - (update ? 1 : 0)].v;
- }
- _rma = _sum / Math.Min(_len, _period);
- }
- else {
- _rma = _k * (TValue.v - _lastrma) + _lastrma;
- }
-
- _lastrma = double.IsNaN(_rma) ? _lastrma : _rma;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _rma);
- return base.Add(res, update);
- }
-
-//variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _sum = _oldsum = _lastrma = _oldrma = 0;
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/RSI_Series.cs b/Calculations/_Updated/RSI_Series.cs
deleted file mode 100644
index 8d3979a1..00000000
--- a/Calculations/_Updated/RSI_Series.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-RSI: Relative Strength Index
- Created by J. Welles Wilder, the Relative Strength Index measures strength
- of the winning/losing streak over N lookback periods on a scale of 0 to 100,
- to depict overbought and oversold conditions.
-
-Sources:
- https://www.investopedia.com/terms/r/rsi.asp
-
- */
-
-public class RSI_Series : TSeries {
- private readonly System.Collections.Generic.List _gain = new();
- private readonly System.Collections.Generic.List _loss = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private double _avgGain, _avgLoss, _lastValue;
- private double _avgGain_o, _avgLoss_o, _lastValue_o;
- private int i;
-
- //core constructors
- public RSI_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"RSI({period})";
- i = 0;
- }
- public RSI_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public RSI_Series() : this(period: 0, useNaN: false) { }
- public RSI_Series(int period) : this(period: period, useNaN: false) { }
- public RSI_Series(TBars source) : this(source.Close, 0, false) { }
- public RSI_Series(TBars source, int period) : this(source.Close, period, false) { }
- public RSI_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public RSI_Series(TSeries source) : this(source, 0, false) { }
- public RSI_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
-
- double _rsi = 0;
- if (update) {
- _lastValue = _lastValue_o;
- _avgGain = _avgGain_o;
- _avgLoss = _avgLoss_o;
- }
- else {
- _lastValue_o = _lastValue;
- _avgGain_o = _avgGain;
- _avgLoss_o = _avgLoss;
- }
-
- if (i == 0) { _lastValue = TValue.v; }
-
- double _gainval = (TValue.v > _lastValue) ? TValue.v - _lastValue : 0;
- BufferTrim(_gain, _gainval, _period, update);
- double _lossval = (TValue.v < _lastValue) ? _lastValue - TValue.v : 0;
- BufferTrim(_loss, _lossval, _period, update);
- _lastValue = TValue.v;
-
- // calculate RSI
- if (i > _period && _period != 0) {
- _avgGain = ((_avgGain * (_period - 1)) + _gain[^1]) / _period;
- _avgLoss = ((_avgLoss * (_period - 1)) + _loss[^1]) / _period;
- if (_avgLoss > 0) {
- double rs = _avgGain / _avgLoss;
- _rsi = 100 - (100 / (1 + rs));
- }
- else { _rsi = 100; }
- }
- // initialize average gain
- else {
- double _sumGain = 0;
- for (int p = 0; p < _gain.Count; p++) { _sumGain += _gain[p]; }
- double _sumLoss = 0;
- for (int p = 0; p < _loss.Count; p++) { _sumLoss += _loss[p]; }
-
- _avgGain = _sumGain / _gain.Count;
- _avgLoss = _sumLoss / _loss.Count;
-
- _rsi = (_avgLoss > 0) ? 100 - (100 / (1 + (_avgGain / _avgLoss))) : 100;
- }
- if (!update) { i++; }
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _rsi);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- i = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SDEV_Series.cs b/Calculations/_Updated/SDEV_Series.cs
deleted file mode 100644
index ab5ca503..00000000
--- a/Calculations/_Updated/SDEV_Series.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-SDEV: Population Standard Deviation
- Population Standard Deviation is the square root of the biased variance, also knons as
- Uncorrected Sample Standard Deviation
-
-Sources:
- https://en.wikipedia.org/wiki/Standard_deviation#Uncorrected_sample_standard_deviation
-
-Remark:
- SDEV (Population Standard Deviation) is also known as a biased/uncorrected Standard Deviation.
- For unbiased version that uses Bessel's correction, use SDEV instead.
-
- */
-
-public class SDEV_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public SDEV_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"SDEV({period})";
- }
- public SDEV_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SDEV_Series() : this(period: 0, useNaN: false) { }
- public SDEV_Series(int period) : this(period: period, useNaN: false) { }
- public SDEV_Series(TBars source) : this(source.Close, 0, false) { }
- public SDEV_Series(TBars source, int period) : this(source.Close, period, false) { }
- public SDEV_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public SDEV_Series(TSeries source) : this(source, 0, false) { }
- public SDEV_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _var = 0;
- for (int i = 0; i < _buffer.Count; i++) { _var += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
- _var /= this._buffer.Count;
- double _sdev = Math.Sqrt(_var);
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _sdev);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SLOPE_Series.cs b/Calculations/_Updated/SLOPE_Series.cs
deleted file mode 100644
index 4aef642e..00000000
--- a/Calculations/_Updated/SLOPE_Series.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-SLOPE: Slope of linear regression (using Least Square Method)
- Linear Regression provides a slope of a straight line that is the best approximation of the given set of data.
- The method of least squares is a standard approach in linear regression analysis to approximate the solution
- by minimizing the sum of the squares of the residuals made in the results of each individual equation.
-
-Additional outputs provided by LINREG:
- .Intercept - y-intercept point of the best fit line
- .RSquared - R-Squared (R²), Coefficient of Determination
- .StdDev - Standard Deviation of data over given periods
-
- y = Slope * x + Intercept
-
-Sources:
- https://en.wikipedia.org/wiki/Least_squares
-
- */
-
-public class SLOPE_Series : TSeries {
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly TSeries p_Intercept = new();
- private readonly TSeries p_RSquared = new();
- private readonly TSeries p_StdDev = new();
- private readonly System.Collections.Generic.List _buffer = new();
- public TSeries Intercept => p_Intercept;
- public TSeries RSquared => p_RSquared;
- public TSeries StdDev => p_StdDev;
- //core constructors
- public SLOPE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"SLOPE({period})";
- }
- public SLOPE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SLOPE_Series() : this(period: 0, useNaN: false) { }
- public SLOPE_Series(int period) : this(period: period, useNaN: false) { }
- public SLOPE_Series(TBars source) : this(source.Close, 0, false) { }
- public SLOPE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public SLOPE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public SLOPE_Series(TSeries source) : this(source, 0, false) { }
- public SLOPE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- int _len = this._buffer.Count;
-
- // get averages for period
- double sumX = 0;
- double sumY = 0;
-
- for (int p = 0; p < _len; p++) {
- sumX += this.Count - _len + 2 + p;
- sumY += _buffer[p];
- }
- double avgX = sumX / _len;
- double avgY = sumY / _len;
-
- // least squares method
- double sumSqX = 0;
- double sumSqY = 0;
- double sumSqXY = 0;
-
- for (int p = 0; p < _len; p++) {
- double devX = this.Count - _len + 2 + p - avgX;
- double devY = _buffer[p] - avgY;
-
- sumSqX += devX * devX;
- sumSqY += devY * devY;
- sumSqXY += devX * devY;
- }
-
- double _slope = sumSqXY / sumSqX;
- double _intercept = avgY - (_slope * avgX);
-
- // calculate Standard Deviation and R-Squared
- double stdDevX = Math.Sqrt(sumSqX / _len);
- double stdDevY = Math.Sqrt(sumSqY / _len);
- double _StdDev = stdDevY;
-
- double arrr = (stdDevX * stdDevY != 0) ? sumSqXY / (stdDevX * stdDevY) / _len : 0;
- double _RSquared = arrr * arrr;
-
- var ret = (TValue.t, this.Count < this._period - 1 && this._NaN ? double.NaN : _intercept);
- p_Intercept.Add(ret, update);
-
- ret = (TValue.t, this.Count < this._period - 1 && this._NaN ? double.NaN : _StdDev);
- p_StdDev.Add(ret, update);
-
- ret = (TValue.t, this.Count < this._period - 1 && this._NaN ? double.NaN : _RSquared);
- p_RSquared.Add(ret, update);
-
- ret = (TValue.t, this.Count < this._period - 1 && this._NaN ? double.NaN : _slope);
- return base.Add(ret, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SMAPE_Series.cs b/Calculations/_Updated/SMAPE_Series.cs
deleted file mode 100644
index b79a3442..00000000
--- a/Calculations/_Updated/SMAPE_Series.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-SMAPE: Symmetric Mean Absolute Percentage Error
- Measures the size of the error in percentage terms
-
-Sources:
- https://en.wikipedia.org/wiki/Symmetric_mean_absolute_percentage_error
-
- */
-
-public class SMAPE_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public SMAPE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"SMAPE({period})";
- }
- public SMAPE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SMAPE_Series() : this(period: 0, useNaN: false) { }
- public SMAPE_Series(int period) : this(period: period, useNaN: false) { }
- public SMAPE_Series(TBars source) : this(source.Close, 0, false) { }
- public SMAPE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public SMAPE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public SMAPE_Series(TSeries source) : this(source, 0, false) { }
- public SMAPE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
- double _smape = 0;
- for (int i = 0; i < _buffer.Count; i++) { _smape += Math.Abs(_buffer[i] - _sma) / (Math.Abs(_buffer[i]) + Math.Abs(_sma)); }
- _smape /= this._buffer.Count;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _smape);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SMA_Series.cs b/Calculations/_Updated/SMA_Series.cs
deleted file mode 100644
index c9a817f0..00000000
--- a/Calculations/_Updated/SMA_Series.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-SMA: Simple Moving Average
- The weights are equally distributed across the period, resulting in a mean() of
- the data within the period
-
-Sources:
- https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/simple-moving-average-sma/
- https://stats.stackexchange.com/a/24739
-
-Remark:
- This calc doesn't use LINQ or SUM() or any of (slow) iterative methods. It is not as fast as TA-LIB
- implementation, but it does allow incremental additions of inputs and real-time calculations of SMA()
-
- */
-public class SMA_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
-
- private double _sum, _oldsum;
- private readonly int _period;
- private readonly TSeries _data;
- protected readonly bool _NaN;
-
- //core constructor
- public SMA_Series(int period, bool useNaN) {
- _period = Math.Max(0, period);
- _NaN = useNaN;
- Name = $"SMA({period})";
- _sum = _oldsum = 0;
- }
- public SMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SMA_Series() : this(0, false) {}
- public SMA_Series(int period) : this(period, false) {}
- public SMA_Series(TBars source) : this(source.Close, 0, false) {}
- public SMA_Series(TBars source, int period) : this(source.Close, period, false) {}
- public SMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {}
- public SMA_Series(TSeries source) : this(source, 0, false) {}
- public SMA_Series(TSeries source, int period) : this(source, period, false) {}
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) { return (TValue.t, double.NaN);
- } else {
- if (update && _buffer.Count > 0) {
- _sum -= _buffer[^1];
- _buffer[^1] = TValue.v;
- _oldsum = _sum;
- }
- else {
- _buffer.Add(TValue.v);
- _oldsum = _sum;
- }
-
- _sum += TValue.v;
- if (_period != 0 && _buffer.Count > _period) {
- _sum -= _buffer[0];
- _buffer.RemoveAt(0);
- }
- }
-
- double _div = _period == 0 ? _buffer.Count : Math.Min(_buffer.Count, _period);
- var _sma = _sum / _div;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _sma);
- return base.Add(res, update);
- }
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
-
- //reset calculation
- public override void Reset() {
- _sum = _oldsum = 0;
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SMMA_Series.cs b/Calculations/_Updated/SMMA_Series.cs
deleted file mode 100644
index 8f464cc1..00000000
--- a/Calculations/_Updated/SMMA_Series.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-/*
-SMMA: Smoothed Moving Average
- The Smoothed Moving Average (SMMA) is a combination of a SMA and an EMA. It gives the recent prices
- an equal weighting as the historic prices as it takes all available price data into account.
- The main advantage of a smoothed moving average is that it removes short-term fluctuations.
-
- SMMA(i) = (SMMA-1*(N-1) + CLOSE (i)) / N
-
-Sources:
- https://blog.earn2trade.com/smoothed-moving-average
- https://guide.traderevolution.com/traderevolution/mobile-applications/phone/android/technical-indicators/moving-averages/smma-smoothed-moving-average
- https://www.chartmill.com/documentation/technical-analysis-indicators/217-MOVING-AVERAGES-%7C-The-Smoothed-Moving-Average-%28SMMA%29
-
- */
-
-public class SMMA_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
-
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private double _lastsmma, _lastlastsmma;
-
- //core constructors
- public SMMA_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"SMMA({period})";
- }
- public SMMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SMMA_Series() : this(period: 0, useNaN: false) { }
- public SMMA_Series(int period) : this(period: period, useNaN: false) { }
- public SMMA_Series(TBars source) : this(source.Close, 0, false) { }
- public SMMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public SMMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public SMMA_Series(TSeries source) : this(source, 0, false) { }
- public SMMA_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, double.NaN),update);
- }
-
- double _smma = 0;
- if (update) { this._lastsmma = this._lastlastsmma; }
-
- if (this.Count < this._period) {
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- _smma = _buffer.Average();
- }
- else {
- _smma = ((_lastsmma * (_period - 1)) + TValue.v) / _period;
- }
-
- this._lastlastsmma = this._lastsmma;
- this._lastsmma = _smma;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _smma);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- this._lastsmma = this._lastlastsmma = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SSDEV_Series.cs b/Calculations/_Updated/SSDEV_Series.cs
deleted file mode 100644
index 2b5f62d3..00000000
--- a/Calculations/_Updated/SSDEV_Series.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-SSDEV: (Corrected) Sample Standard Deviation
- Sample Standard Deviaton uses Bessel's correction to correct the bias in the variance.
-
-Sources:
- https://en.wikipedia.org/wiki/Standard_deviation#Corrected_sample_standard_deviation
- Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction
-
-Remark:
- SSDEV (Sample Standard Deviation) is also known as a unbiased/corrected Standard Deviation.
- For a population/biased/uncorrected Standard Deviation, use PSDEV instead
-
- */
-
-public class SSDEV_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public SSDEV_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"SSDEV({period})";
- }
- public SSDEV_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SSDEV_Series() : this(period: 0, useNaN: false) { }
- public SSDEV_Series(int period) : this(period: period, useNaN: false) { }
- public SSDEV_Series(TBars source) : this(source.Close, 0, false) { }
- public SSDEV_Series(TBars source, int period) : this(source.Close, period, false) { }
- public SSDEV_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public SSDEV_Series(TSeries source) : this(source, 0, false) { }
- public SSDEV_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _svar = 0;
- for (int i = 0; i < this._buffer.Count; i++) { _svar += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
- _svar /= (_buffer.Count > 1) ? _buffer.Count - 1 : 1; // Bessel's correction
- double _ssdev = Math.Sqrt(_svar);
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _ssdev);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/SVAR_Series.cs b/Calculations/_Updated/SVAR_Series.cs
deleted file mode 100644
index bb693c54..00000000
--- a/Calculations/_Updated/SVAR_Series.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-VAR: Population Variance
- Population variance without Bessel's correction
-
-Sources:
- https://en.wikipedia.org/wiki/Variance
- Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction
-
-Remark:
- VAR (Population Variance) is also known as a biased Sample Variance. For unbiased
- sample variance use SVAR instead.
-
- */
-
-public class SVAR_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public SVAR_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"SVAR({period})";
- }
- public SVAR_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public SVAR_Series() : this(period: 0, useNaN: false) { }
- public SVAR_Series(int period) : this(period: period, useNaN: false) { }
- public SVAR_Series(TBars source) : this(source.Close, 0, false) { }
- public SVAR_Series(TBars source, int period) : this(source.Close, period, false) { }
- public SVAR_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public SVAR_Series(TSeries source) : this(source, 0, false) { }
- public SVAR_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _svar = 0;
- for (int i = 0; i < this._buffer.Count; i++) { _svar += (this._buffer[i] - _sma) * (this._buffer[i] - _sma); }
- _svar /= (this._buffer.Count > 1) ? this._buffer.Count - 1 : 1; // Bessel's correction
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _svar);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/T3_Series.cs b/Calculations/_Updated/T3_Series.cs
deleted file mode 100644
index 7cba0dcd..00000000
--- a/Calculations/_Updated/T3_Series.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Numerics;
-
-/*
-T3: Tillson T3 Moving Average
- Tim Tillson described it in "Technical Analysis of Stocks and Commodities", January 1998 in the
- article "Better Moving Averages". Tillson’s moving average becomes a popular indicator of
- technical analysis as it gets less lag with the price chart and its curve is considerably smoother.
-
-Sources:
- https://technicalindicators.net/indicators-technical-analysis/150-t3-moving-average
- http://www.binarytribune.com/forex-trading-indicators/t3-moving-average-indicator/
- */
-
-public class T3_Series : TSeries {
- private readonly double _k, _k1m, _c1, _c2, _c3, _c4;
- private readonly System.Collections.Generic.List _buffer1 = new();
- private readonly System.Collections.Generic.List _buffer2 = new();
- private readonly System.Collections.Generic.List _buffer3 = new();
- private readonly System.Collections.Generic.List _buffer4 = new();
- private readonly System.Collections.Generic.List _buffer5 = new();
- private readonly System.Collections.Generic.List _buffer6 = new();
- private readonly bool _useSMA;
- private double _lastema1, _lastema2, _lastema3, _lastema4, _lastema5, _lastema6;
- private double _llastema1, _llastema2, _llastema3, _llastema4, _llastema5, _llastema6;
- protected int _len;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public T3_Series(int period, double vfactor, bool useSMA, bool useNaN) {
- _period = period;
- _len = 0;
- _NaN = useNaN;
- Name = $"T3({period})";
- _useSMA = useSMA;
- double _a = vfactor; //0.7; //0.618
- _c1 = -_a * _a * _a;
- _c2 = 3 * _a * _a + 3 * _a * _a * _a;
- _c3 = -6 * _a * _a - 3 * _a - 3 * _a * _a * _a;
- _c4 = 1 + 3 * _a + _a * _a * _a + 3 * _a * _a;
-
- _k = 2.0 / (_period + 1);
- _k1m = 1.0 - _k;
- _lastema1 = _llastema1 = _lastema2 = _llastema2 = _lastema3 = _llastema3 = _lastema4 = _llastema4 = _lastema5 = _llastema5 = _lastema5 = _llastema5 = 0;
- }
- public T3_Series(TSeries source, int period, double vfactor, bool useSMA, bool useNaN) : this(period, vfactor, useSMA, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public T3_Series() : this(period: 0, vfactor: 0.7, useSMA: true, useNaN: false) { }
- public T3_Series(int period) : this(period: period, vfactor: 0.7, useSMA: true, useNaN: false) { }
- public T3_Series(TBars source) : this(source.Close, 0, vfactor: 0.7, useSMA: true, useNaN: false) { }
- public T3_Series(TBars source, int period) : this(source.Close, period, vfactor: 0.7, useSMA: true, useNaN: false) { }
- public T3_Series(TBars source, int period, bool useNaN) : this(source.Close, period, vfactor: 0.7, useSMA: true, useNaN: useNaN) { }
- public T3_Series(TBars source, int period, double vfactor, bool useNaN) : this(source.Close, period, vfactor: vfactor, useSMA: true, useNaN: useNaN) { }
- public T3_Series(TBars source, int period, bool useSMA, bool useNaN) : this(source.Close, period, vfactor: 0.7, useSMA: useSMA, useNaN: useNaN) { }
- public T3_Series(TSeries source) : this(source, 0, vfactor: 0.7, useSMA: true, useNaN: false) { }
- public T3_Series(TSeries source, int period) : this(source: source, period: period, vfactor: 0.7, useSMA: true, useNaN: false) { }
- public T3_Series(TSeries source, int period, bool useNaN) : this(source: source, period: period, vfactor: 0.7, useSMA: true, useNaN: useNaN) { }
- public T3_Series(TSeries source, int period, double vfactor) : this(source: source, period: period, vfactor: vfactor, useSMA: true, useNaN: false) { }
- public T3_Series(TSeries source, int period, double vfactor, bool useNaN) : this(source: source, period: period, vfactor: vfactor, useSMA: true, useNaN: useNaN) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- double _ema1, _ema2, _ema3, _ema4, _ema5, _ema6;
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN),update);
- }
-
- if (update) { _lastema1 = _llastema1; _lastema2 = _llastema2; _lastema3 = _llastema3; _lastema4 = _llastema4; _lastema5 = _llastema5; _lastema6 = _llastema6; }
- else { _llastema1 = _lastema1; _llastema2 = _lastema2; _llastema3 = _lastema3; _llastema4 = _lastema4; _llastema5 = _lastema5; _llastema6 = _lastema6; }
-
- if (_len == 0) { _lastema1 = _lastema2 = _lastema3 = _lastema4 = _lastema5 = _lastema6 = TValue.v; }
-
-
- if ((_len < _period) && _useSMA) {
- BufferTrim(_buffer1, TValue.v, _period, update);
- _ema1 = 0;
- for (int i = 0; i < _buffer1.Count; i++) { _ema1 += _buffer1[i]; }
- _ema1 /= _buffer1.Count;
-
- BufferTrim(_buffer2, _ema1, _period, update);
- _ema2 = 0;
- for (int i = 0; i < _buffer2.Count; i++) { _ema2 += _buffer2[i]; }
- _ema2 /= _buffer2.Count;
-
- BufferTrim(_buffer3, _ema2, _period, update);
- _ema3 = 0;
- for (int i = 0; i < _buffer3.Count; i++) { _ema3 += _buffer3[i]; }
- _ema3 /= _buffer3.Count;
-
- BufferTrim(_buffer4, _ema3, _period, update);
- _ema4 = 0;
- for (int i = 0; i < _buffer4.Count; i++) { _ema4 += _buffer4[i]; }
- _ema4 /= _buffer4.Count;
-
- BufferTrim(_buffer5, _ema4, _period, update);
- _ema5 = 0;
- for (int i = 0; i < _buffer5.Count; i++) { _ema5 += _buffer5[i]; }
- _ema5 /= _buffer5.Count;
-
- BufferTrim(_buffer6, _ema5, _period, update);
- _ema6 = 0;
- for (int i = 0; i < _buffer6.Count; i++) { _ema6 += _buffer6[i]; }
- _ema6 /= _buffer6.Count;
- }
- else {
- _ema1 = (TValue.v * this._k) + (this._lastema1 * this._k1m);
- _ema2 = (_ema1 * this._k) + (this._lastema2 * this._k1m);
- _ema3 = (_ema2 * this._k) + (this._lastema3 * this._k1m);
- _ema4 = (_ema3 * this._k) + (this._lastema4 * this._k1m);
- _ema5 = (_ema4 * this._k) + (this._lastema5 * this._k1m);
- _ema6 = (_ema5 * this._k) + (this._lastema6 * this._k1m);
- }
- _len++;
- _lastema1 = _ema1;
- _lastema2 = _ema2;
- _lastema3 = _ema3;
- _lastema4 = _ema4;
- _lastema5 = _ema5;
- _lastema6 = _ema6;
-
- double _T3 = _c1 * _ema6 + _c2 * _ema5 + _c3 * _ema4 + _c4 * _ema3;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _T3);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _lastema1 = _llastema1 = _lastema2 = _llastema2 = _lastema3 = _llastema3 = _lastema4 = _llastema4 = _lastema5 = _llastema5 = _lastema5 = _llastema5 = 0;
- _buffer1.Clear();
- _buffer2.Clear();
- _buffer3.Clear();
- _buffer4.Clear();
- _buffer5.Clear();
- _buffer6.Clear();
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/TBars.cs b/Calculations/_Updated/TBars.cs
deleted file mode 100644
index 0c0274d4..00000000
--- a/Calculations/_Updated/TBars.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-namespace QuanTAlib;
-using System;
-
-/*
-TBars class - includes all series for common data used in indicators and other calculations.
- Has a bit limited overloading and casting (compared to TSeries)
- Includes Select(int) method to simplify choosing the most optimal data source for indicators
- Includes the most basic pricing calcs: HL2, OC2, OHL3, HLC3, OHLC4, HLCC4
- (it is 'cheaper' to calculate them once during data capture than each time during data analysis)
-
- */
-
-public class TBars : System.Collections.Generic.List<(DateTime t, double o, double h, double l, double c, double v)>
-{
- public string Name { get; set; }
- private readonly TSeries _open = new("open");
- private readonly TSeries _high = new("high");
- private readonly TSeries _low = new("low");
- private readonly TSeries _close = new("close");
- private readonly TSeries _volume = new("volume");
- private readonly TSeries _hl2 = new("HL2");
- private readonly TSeries _oc2 = new("OC2");
- private readonly TSeries _ohl3 = new("OHL3");
- private readonly TSeries _hlc3 = new("HLC3");
- private readonly TSeries _ohlc4 = new("OHLC4");
- private readonly TSeries _hlcc4 = new("HLCC4");
-
- public TSeries Open => this._open;
- public TSeries High => this._high;
- public TSeries Low => this._low;
- public TSeries Close => this._close;
- public TSeries Volume => this._volume;
- public TSeries HL2 => this._hl2;
- public TSeries OC2 => this._oc2;
- public TSeries OHL3 => this._ohl3;
- public TSeries HLC3 => this._hlc3;
- public TSeries OHLC4 => this._ohlc4;
- public TSeries HLCC4 => this._hlcc4;
-
- public TBars() { }
-
- public TBars(string Name) {
- this.Name = Name;
- }
-
- public (DateTime t, double o, double h, double l, double c, double v) Last => this[^1];
- public TBars Tail(int count = 10)
- {
- TBars outBars = new();
- if (count > this.Count) { count = this.Count; }
- for (int i = this.Count - count; i < this.Count; i++) { outBars.Add(this[i]); }
- return outBars;
- }
- public TSeries Select(int source)
- {
- return source switch
- {
- 0 => _open,
- 1 => _high,
- 2 => _low,
- 3 => _close,
- 4 => _hl2,
- 5 => _oc2,
- 6 => _ohl3,
- 7 => _hlc3,
- 8 => _ohlc4,
- _ => _hlcc4,
- };
- }
- public static string SelectStr(int source)
- {
- return source switch
- {
- 0 => "Open",
- 1 => "High",
- 2 => "Low",
- 3 => "Close",
- 4 => "HL2",
- 5 => "OC2",
- 6 => "OHL3",
- 7 => "HLC3",
- 8 => "OHLC4",
- _ => "HLCC4",
- };
- }
-
- public virtual (DateTime t, double v) Add((double o, double h, double l, double c, double v) p, bool update = false) =>
- Add((t: (this.Count == 0) ? DateTime.Today : this[^1].t.AddDays(1),p.o,p.h,p.l,p.c,p.v),update);
-
- public virtual (DateTime t, double v) Add(double o, double h, double l, double c, double v, bool update = false) =>
- Add((o,h,l,c,v),update);
-
- public virtual (DateTime t, double v) Add(DateTime t, double o, double h, double l, double c, double v, bool update = false) =>
- this.Add((t, o, h, l, c, v), update);
-
- public virtual (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- if (update) { this[^1] = TBar; } else { base.Add(TBar); }
-
- _open.Add((TBar.t, TBar.o), update);
- _high.Add((TBar.t, TBar.h), update);
- _low.Add((TBar.t, TBar.l), update);
- _close.Add((TBar.t, TBar.c), update);
- _volume.Add((TBar.t, TBar.v), update);
- _hl2.Add((TBar.t, (TBar.h + TBar.l) * 0.5), update);
- _oc2.Add((TBar.t, (TBar.o + TBar.c) * 0.5), update);
- _ohl3.Add((TBar.t, (TBar.o + TBar.h + TBar.l) * 0.333333333333333), update);
- _hlc3.Add((TBar.t, (TBar.h + TBar.l + TBar.c) * 0.333333333333333), update);
- _ohlc4.Add((TBar.t, (TBar.o + TBar.h + TBar.l + TBar.c) * 0.25), update);
- _hlcc4.Add((TBar.t, (TBar.h + TBar.l + TBar.c + TBar.c) * 0.25), update);
-
- this.OnEvent(update);
- return (TBar.t, (TBar.o + TBar.h + TBar.l + TBar.c) * 0.25);
- }
-
- public delegate void NewDataEventHandler(object source, TSeriesEventArgs args);
- public event NewDataEventHandler Pub;
- protected virtual void OnEvent(bool update = false) { if (Pub != null && Pub.Target != this) {
- Pub(this, new TSeriesEventArgs { update = update }); } }
-
- public void Sub(object source, TSeriesEventArgs e) { TBars ss = (TBars)source; if (ss.Count > 1) {
- for (int i = 0; i < ss.Count; i++) { this.Add(ss[i]); }
- } else {
- this.Add(ss[^1], e.update);
- }
- }
-
- /// common helpers
- public static void BufferTrim(System.Collections.Generic.List buffer, double value, int period, bool update) {
- if (!update) {
- buffer.Add(value);
- if (buffer.Count > period && period > 0) { buffer.RemoveAt(0); }
- return;
- }
- buffer[^1] = value;
- }
- public virtual void Reset() {
- }
-}
diff --git a/Calculations/_Updated/TEMA_Series.cs b/Calculations/_Updated/TEMA_Series.cs
deleted file mode 100644
index f48019fa..00000000
--- a/Calculations/_Updated/TEMA_Series.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-TEMA: Triple Exponential Moving Average
- TEMA uses EMA(EMA(EMA())) to calculate less laggy Exponential moving average.
-
-Sources:
- https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/triple-exponential-moving-average-tema/
-
-Remark:
- ema1 = EMA(close, length)
- ema2 = EMA(ema1, length)
- ema3 = EMA(ema2, length)
- TEMA = 3 * (ema1 - ema2) + ema3
-
- */
-
-public class TEMA_Series : TSeries {
- private double _k;
- private double _sum, _oldsum;
- private double _lastema1, _oldema1, _lastema2, _oldema2, _lastema3, _oldema3;
- private int _len;
- private readonly bool _useSMA;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
-//core constructor
- public TEMA_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- _useSMA = useSMA;
- Name = $"TEMA({period})";
- _k = 2.0 / (_period + 1);
- _len = 0;
- _sum = _oldsum = _lastema1 = _lastema2 = _lastema3 = 0;
- }
- public TEMA_Series() : this(0, false, true) {}
- public TEMA_Series(int period) : this(period, false, true) {}
- public TEMA_Series(TBars source) : this(source.Close, 0, false) {}
- public TEMA_Series(TBars source, int period) : this(source.Close, period, false) {}
- public TEMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {}
- public TEMA_Series(TSeries source, int period) : this(source, period, false, true) {}
- public TEMA_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) {}
- public TEMA_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
-// core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) {
- _lastema1 = _oldema1;
- _lastema2 = _oldema2;
- _lastema3 = _oldema3;
- _sum = _oldsum;
- }
- else {
- _oldema1 = _lastema1;
- _oldema2 = _lastema2;
- _oldema3 = _lastema3;
- _oldsum = _sum;
- _len++;
- }
-
- if (_period == 0) { _k = 2.0 / (_len + 1); }
-
- double _ema1, _ema2, _ema3, _tema;
- if (this.Count == 0) {
- _ema1 = _ema2 = _ema3 =_sum = TValue.v;
- }
- else if (_len <= _period && _useSMA && _period != 0) {
- _sum += TValue.v;
- _ema1 = _sum / Math.Min(_len, _period);
- _ema2 = _ema1;
- _ema3 = _ema2;
- }
- else {
- _ema1 = (TValue.v - _lastema1) * _k + _lastema1;
- _ema2 = (_ema1 - _lastema2) * _k + _lastema2;
- _ema3 = (_ema2 - _lastema3) * _k + _lastema3;
- }
-
- _tema = (3 * (_ema1 - _ema2)) + _ema3;
-
- _lastema1 = Double.IsNaN(_ema1)?_lastema1:_ema1;
- _lastema2 = Double.IsNaN(_ema2)?_lastema2:_ema2;
- _lastema3 = Double.IsNaN(_ema3) ? _lastema3 : _ema3;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _tema);
- return base.Add(res, update);
- }
-
-//variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _sum = _oldsum = _lastema1 = _lastema2 = 0;
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/TRIMA_Series.cs b/Calculations/_Updated/TRIMA_Series.cs
deleted file mode 100644
index 050a4b88..00000000
--- a/Calculations/_Updated/TRIMA_Series.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-TRIMA: Triangular Moving Average
- A weighted moving average where the shape of the weights are triangular and the greatest
- weight is in the middle of the period,
-
-Sources:
- https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/triangular-moving-average-trima/
-
-Remark:
- trima = sma(sma(signal, n/2), n/2)
-
- */
-
-public class TRIMA_Series : TSeries {
- private readonly int _p1a, _p1b;
- private readonly SMA_Series sma, trima;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public TRIMA_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"xMA({period})";
- _p1a = (int)Math.Floor((period * 0.5) + 1);
- _p1b = (int)Math.Ceiling(0.5 * period);
- sma = new(_p1a);
- trima = new(_p1b);
-
- }
- public TRIMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public TRIMA_Series() : this(period: 0, useNaN: false) { }
- public TRIMA_Series(int period) : this(period: period, useNaN: false) { }
- public TRIMA_Series(TBars source) : this(source.Close, 0, false) { }
- public TRIMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public TRIMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public TRIMA_Series(TSeries source) : this(source, 0, false) { }
- public TRIMA_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
-
- var _sma = sma.Add(TValue, update);
- var _trima = trima.Add(_sma, update);
-
- var res = (_trima.t, Count < _period - 1 && _NaN ? double.NaN : _trima.v);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- sma.Reset();
- trima.Reset();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/TRIX_Series.cs b/Calculations/_Updated/TRIX_Series.cs
deleted file mode 100644
index f955bf04..00000000
--- a/Calculations/_Updated/TRIX_Series.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-TRIX: Triple Exponential Average Oscillator
- Developed by Jack Hutson in the early 1980s, the triple exponential average (TRIX)
- has become a popular technical analysis tool to aid chartists in spotting diversions
- and directional cues in stock trading patterns.
-
-Sources:
- https://www.investopedia.com/terms/t/trix.asp
-
- */
-
-public class TRIX_Series : TSeries {
- private readonly double _k;
- private readonly System.Collections.Generic.List _buffer1 = new();
- private readonly System.Collections.Generic.List _buffer2 = new();
- private readonly System.Collections.Generic.List _buffer3 = new();
- private double _lastema1, _lastema2, _lastema3;
- private double _llastema1, _llastema2, _llastema3;
- private int _len;
- private readonly bool _useSMA;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
-//core constructors
-
- public TRIX_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- _useSMA = useSMA;
- Name = $"TRIX({period})";
- _k = 2.0 / (_period + 1);
- _len = 0;
- _lastema1 = _llastema1 = _lastema2 = _llastema2 = _lastema3 = _llastema3 = 0;
- }
- public TRIX_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public TRIX_Series() : this(0, false, true) {}
- public TRIX_Series(int period) : this(period, false, true) {}
- public TRIX_Series(TBars source) : this(source.Close, 0, false) {}
- public TRIX_Series(TBars source, int period) : this(source.Close, period, false) {}
- public TRIX_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) {}
- public TRIX_Series(TSeries source, int period) : this(source, period, false, true) {}
- public TRIX_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) {}
-
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (double.IsNaN(TValue.v)) {
- return base.Add((TValue.t, Double.NaN), update);
- }
- if (_len == 0) { _lastema1 = _lastema2 = _lastema3 = TValue.v; }
- if (update) { _lastema1 = _llastema1; _lastema2 = _llastema2; _lastema3 = _llastema3; }
- else { _llastema1 = _lastema1; _llastema2 = _lastema2; _llastema3 = _lastema3; _len++;
- }
-
- double _ema1, _ema2, _ema3;
- if ((this.Count < _period) && _useSMA) {
- BufferTrim(_buffer1, TValue.v, _period, update);
- _ema1 = 0;
- for (int i = 0; i < _buffer1.Count; i++) { _ema1 += _buffer1[i]; }
- _ema1 /= _buffer1.Count;
-
- BufferTrim(_buffer2, _ema1, _period, update);
- _ema2 = 0;
- for (int i = 0; i < _buffer2.Count; i++) { _ema2 += _buffer2[i]; }
- _ema2 /= _buffer2.Count;
-
- BufferTrim(_buffer3, _ema2, _period, update);
- _ema3 = 0;
- for (int i = 0; i < _buffer3.Count; i++) { _ema3 += _buffer3[i]; }
- _ema3 /= _buffer3.Count;
- }
- else {
- _ema1 = (TValue.v - _lastema1) * _k + _lastema1;
- _ema2 = (_ema1 - _lastema2) * _k + _lastema2;
- _ema3 = (_ema2 - _lastema3) * _k + _lastema3;
- }
- double _trix = 100 * (_ema3 - _lastema3) / _lastema3;
- _lastema1 = _ema1;
- _lastema2 = _ema2;
- _lastema3 = _ema3;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _trix);
- return base.Add(res, update);
- }
-
-//variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/TR_Series.cs b/Calculations/_Updated/TR_Series.cs
deleted file mode 100644
index 9365d5f6..00000000
--- a/Calculations/_Updated/TR_Series.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-TR: True Range
- True Range was introduced by J. Welles Wilder in his book New Concepts in Technical Trading Systems.
- It measures the daily range plus any gap from the closing price of the preceding day.
-
-Calculation:
- d1 = ABS(High - Low)
- d2 = ABS(High - Previous close)
- d3 = ABS(Previous close - Low)
- TR = MAX(d1,d2,d3)
-
-Sources:
- https://www.macroption.com/true-range/
-
- */
-
-public class TR_Series : TSeries {
- protected readonly TBars _data;
- private double _cm1, _cm1_o;
-
- //core constructors
- public TR_Series() {
- Name = $"TR()";
- _cm1 = _cm1_o = double.NaN;
- }
- public TR_Series(TBars source) {
- _data = source;
- Name = $"TR({(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _cm1 = _cm1_o = double.NaN;
- _data.Pub += Sub;
- Add(data: _data);
- }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
-
- if (update) {
- _cm1 = _cm1_o;
- }
- else {
- _cm1_o = _cm1;
- }
-
- if (_cm1 is double.NaN) {
- _cm1 = TBar.c;
- }
-
- double d1 = Math.Abs(TBar.h - TBar.l);
- double d2 = Math.Abs(_cm1 - TBar.h);
- double d3 = Math.Abs(_cm1 - TBar.l);
- _cm1 = TBar.c;
- var ret = (TBar.t, Math.Max(d1, Math.Max(d2, d3)));
- return base.Add(ret, update);
-
- }
-
- public new void Add(TBars data) {
- foreach (var item in data) { Add(item, false); }
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TBar: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TBar: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TBar: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _cm1 = _cm1_o = double.NaN;
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/TSeries.cs b/Calculations/_Updated/TSeries.cs
deleted file mode 100644
index 4a8a6312..00000000
--- a/Calculations/_Updated/TSeries.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Data;
-using System.Linq;
-
-/*
-TSeries is the cornerstone of all QuanTAlib classes.
- TSeries is a single List of tuples (time, value) and contains several operators, casts, overloads
- and other helpers that simplify usage of library.
- Think of TSeries as an equivalent of Numpy array.
-
- - includes Length property (to mimic array's method)
- - includes publishing and subscribing methods that attach to events
-
- */
-public class TSeriesEventArgs : EventArgs {
- public bool update { get; set; }
-}
-
-public class TSeries : List<(DateTime t, double v)> {
- private readonly (DateTime t, double v) Default = (DateTime.MinValue, double.NaN);
- public IEnumerable t => this.Select(item => item.t);
- public IEnumerable v => this.Select(item => item.v);
- public (DateTime t, double v) Last => Count > 0 ? this[^1] : Default;
-
- public int Length => Count;
- public string Name { get; set; }
- public int Keep = 0;
-
- public TSeries() {
- this.Name = "data";
- }
-
- public TSeries(string Name) {
- this.Name = Name;
- }
-
- public virtual (DateTime t, double v) Add(double v, bool update = false) {
- return Add((t: Count == 0 ? DateTime.Today : this[^1].t.AddDays(1), v), update);
- }
-
- public virtual (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- if (update) {
- this[^1] = TValue;
- }
- else {
- base.Add(TValue);
- }
-
- OnEvent(update);
- return TValue;
- }
-
- public virtual (DateTime t, double v) Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false) {
- if (update) {
- this[this.Count - 1] = (TBar.t, TBar.c);
- }
- else {
- base.Add((TBar.t, TBar.c));
- }
-
- OnEvent(update);
- return (TBar.t, TBar.c);
- }
-
- public virtual (DateTime t, double v) Add(TSeries data) {
- foreach (var item in data) { Add(item); }
- return data.Last;
- }
-
- public virtual (DateTime t, double v) Add(TBars data) {
- foreach (var item in data) { Add(item.c, false); }
- return (data.Last.t, data.Last.c);
- }
-
- public void Sub(object source, TSeriesEventArgs e) {
- var data = (TSeries) source;
- if (data == null) { return; }
- foreach (var item in data) { Add(item); }
- }
-
- public delegate void NewEventHandler(object source, TSeriesEventArgs args);
-
- public event NewEventHandler Pub;
-
- protected virtual void OnEvent(bool update = false)
- {
- if (Keep > 0) {
- TrimToSize(keep:Keep);
- }
- Pub?.Invoke(this, new TSeriesEventArgs {update = update});
- }
-
- /// common helpers
- public static void BufferTrim(List buffer, double value, int period, bool update) {
- if (!update) {
- buffer.Add(value);
- if (buffer.Count > period && period > 0) { buffer.RemoveAt(0); }
- return;
- }
- buffer[^1] = value;
- }
- public virtual void Reset() {
- }
-
- public void TrimToSize(int keep) {
- if (keep >= this.Count) {
- return; // No need to trim if the series is already smaller than or equal to n
- }
-
- // Remove elements from the beginning of the list
- int elementsToRemove = this.Count - keep;
- RemoveRange(0, elementsToRemove);
- }
-}
diff --git a/Calculations/_Updated/VAR_Series.cs b/Calculations/_Updated/VAR_Series.cs
deleted file mode 100644
index fcd0caba..00000000
--- a/Calculations/_Updated/VAR_Series.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-VAR: Population Variance
- Population variance without Bessel's correction
-
-Sources:
- https://en.wikipedia.org/wiki/Variance
- Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction
-
-Remark:
- VAR (Population Variance) is also known as a biased Sample Variance. For unbiased
- sample variance use SVAR instead.
-
- */
-
-public class VAR_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public VAR_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"VAR({period})";
- }
- public VAR_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public VAR_Series() : this(period: 0, useNaN: false) { }
- public VAR_Series(int period) : this(period: period, useNaN: false) { }
- public VAR_Series(TBars source) : this(source.Close, 0, false) { }
- public VAR_Series(TBars source, int period) : this(source.Close, period, false) { }
- public VAR_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public VAR_Series(TSeries source) : this(source, 0, false) { }
- public VAR_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _pvar = 0;
- for (int i = 0; i < _buffer.Count; i++) { _pvar += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
- _pvar /= this._buffer.Count;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _pvar);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/WMAPE_Series.cs b/Calculations/_Updated/WMAPE_Series.cs
deleted file mode 100644
index bbbdeee4..00000000
--- a/Calculations/_Updated/WMAPE_Series.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-WMAPE: Weighted Mean Absolute Percentage Error
- Measures the size of the error in percentage terms. Improves problems with MAPE
- when there are zero or close-to-zero values because there would be a division by zero
- or values of MAPE tending to infinity.
-
-Sources:
- https://en.wikipedia.org/wiki/WMAPE
-
- */
-
-public class WMAPE_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public WMAPE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"WMAPE({period})";
- }
- public WMAPE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public WMAPE_Series() : this(period: 0, useNaN: false) { }
- public WMAPE_Series(int period) : this(period: period, useNaN: false) { }
- public WMAPE_Series(TBars source) : this(source.Close, 0, false) { }
- public WMAPE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public WMAPE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public WMAPE_Series(TSeries source) : this(source, 0, false) { }
- public WMAPE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
-
- double _sma = _buffer.Average();
-
- double _div = 0;
- double _wmape = 0;
- for (int i = 0; i < _buffer.Count; i++) {
- _wmape += Math.Abs(_buffer[i] - _sma);
- _div += Math.Abs(_buffer[i]);
- }
- _wmape = (_div != 0) ? _wmape / _div : double.PositiveInfinity;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _wmape);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/WMA_Series.cs b/Calculations/_Updated/WMA_Series.cs
deleted file mode 100644
index f423e3ca..00000000
--- a/Calculations/_Updated/WMA_Series.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-/*
-WMA: (linearly) Weighted Moving Average
- The weights are linearly decreasing over the period and the most recent data has
- the heaviest weight.
-
-Sources:
- https://corporatefinanceinstitute.com/resources/knowledge/trading-investing/weighted-moving-average-wma/
- https://www.technicalindicators.net/indicators-technical-analysis/83-moving-averages-simple-exponential-weighted
-
- */
-
-public class WMA_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- private System.Collections.Generic.List _weights;
- protected int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- protected int _len;
- public int Len {
- get { return _len; }
- set { _len = value; }
- }
-
- //core constructors
- public WMA_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"WMA({period})";
- _len = 1;
- _weights = CalculateWeights(_period);
- }
- public WMA_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public WMA_Series() : this(period: 0, useNaN: false) { }
- public WMA_Series(int period) : this(period: period, useNaN: false) { }
- public WMA_Series(TBars source) : this(source.Close, 0, false) { }
- public WMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public WMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public WMA_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update=false) {
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- if (_period == 0) {
- _weights = CalculateWeights(_len);
- _len++;
- }
- double _wma = 0;
- double totalWeights = (_buffer.Count * (_buffer.Count + 1)) * 0.5;
- object lockObj = new object();
- Parallel.For(0, _buffer.Count, i =>
- {
- double temp = _buffer[i] * this._weights[i];
- lock (lockObj) { _wma += temp; }
- });
- _wma /= totalWeights;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _wma);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //calculating weights
- private static List CalculateWeights(int period) {
- List weights = new List(period);
- for (int i = 0; i < period; i++) {
- weights.Add(i + 1);
- }
- return weights;
- }
-
- //reset calculation
- public override void Reset() {
- _len = 0;
- _weights = CalculateWeights(_period);
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ZLEMA_Series.cs b/Calculations/_Updated/ZLEMA_Series.cs
deleted file mode 100644
index 0f7cd56c..00000000
--- a/Calculations/_Updated/ZLEMA_Series.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-ZLEMA: Zero Lag Exponential Moving Average
- The Zero lag exponential moving average (ZLEMA) indicator was created by John
- Ehlers and Ric Way.
-
-The formula for a given N-Day period and for a given Data series is:
- Lag = (Period-1)/2
- Ema Data = {Data+(Data-Data(Lag days ago))
- ZLEMA = EMA (EmaData,Period)
-
-Remark:
- The idea is do a regular exponential moving average (EMA) calculation but on a
- de-lagged data instead of doing it on the regular data. Data is de-lagged by
- removing the data from "lag" days ago thus removing (or attempting to remove)
- the cumulative lag effect of the moving average.
-
- */
-
-public class ZLEMA_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- private int _len;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly EMA_Series _ema;
-
- //core constructor
- public ZLEMA_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- Name = $"ZLEMA({period})";
- _len = 1;
- _ema = new(period);
- }
- //generic constructors (source)
-
- public ZLEMA_Series() : this(0, false, true) { }
- public ZLEMA_Series(int period) : this(period, false, true) { }
- public ZLEMA_Series(TBars source) : this(source.Close, 0, false) { }
- public ZLEMA_Series(TBars source, int period) : this(source.Close, period, false) { }
- public ZLEMA_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public ZLEMA_Series(TSeries source, int period) : this(source, period, false, true) { }
- public ZLEMA_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) { }
- public ZLEMA_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- int _lag;
- if (_period == 0) {
- _lag = (int)((_len - 1) * 0.5);
- _len++;
- }
- else { _lag = (int)((_period - 1) * 0.5); }
- _lag = Math.Min(_lag, _buffer.Count - 1);
- _lag = Math.Max(_lag, 0) + 1;
- double _zlValue = 2 * TValue.v - _buffer[^_lag];
- double _zlema = _ema.Add((TValue.t, _zlValue), update).v;
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _zlema);
- return base.Add(res, update);
- }
-
- //variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
-
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- _ema.Reset();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ZL_Series.cs b/Calculations/_Updated/ZL_Series.cs
deleted file mode 100644
index 033088e4..00000000
--- a/Calculations/_Updated/ZL_Series.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-namespace QuanTAlib;
-
-using System;
-using System.Linq;
-
-/*
-ZL: Zero Lag
- Data is de-lagged by removing the data from “lag” days ago, thus removing
- (or attempting to) the cumulative effect of the moving average.
-
-Calculation:
- Lag = (Period-1)/2
- ZL = Data + (Data - Data(Lag days ago) )
-
-Sources:
- https://mudrex.com/blog/zero-lag-ema-trading-strategy/
-
- */
-
-public class ZL_Series: TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- private int _len;
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
- private readonly EMA_Series _ema;
-
- //core constructor
- public ZL_Series(int period, bool useNaN, bool useSMA) {
- _period = period;
- _NaN = useNaN;
- Name = $"ZL({period})";
- _len = 1;
- _ema = new(period);
- }
- //generic constructors (source)
-
- public ZL_Series() : this(0, false, true) { }
- public ZL_Series(int period) : this(period, false, true) { }
- public ZL_Series(TBars source) : this(source.Close, 0, false) { }
- public ZL_Series(TBars source, int period) : this(source.Close, period, false) { }
- public ZL_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public ZL_Series(TSeries source, int period) : this(source, period, false, true) { }
- public ZL_Series(TSeries source, int period, bool useNaN) : this(source, period, useNaN, true) { }
- public ZL_Series(TSeries source, int period, bool useNaN, bool useSMA) : this(period, useNaN, useSMA) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
-
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer: _buffer, value: TValue.v, period: _period, update: update);
- int _lag;
- if (_period == 0) {
- _lag = (int)((_len - 1) * 0.5);
- _len++;
- }
- else { _lag = (int)((_period - 1) * 0.5); }
- _lag = Math.Min(_lag, _buffer.Count - 1);
- _lag = Math.Max(_lag, 0) + 1;
- double _zlValue = 2 * TValue.v - _buffer[^_lag];
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _zlValue);
- return base.Add(res, update);
- }
-
- //variation of Add()
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- _ema.Reset();
- }
-}
\ No newline at end of file
diff --git a/Calculations/_Updated/ZSCORE_Series.cs b/Calculations/_Updated/ZSCORE_Series.cs
deleted file mode 100644
index 06c37130..00000000
--- a/Calculations/_Updated/ZSCORE_Series.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System.Linq;
-
-namespace QuanTAlib;
-using System;
-using System.Collections.Generic;
-
-/*
-ZSCORE: number of standard deviations from SMA
- Z-score describes a value's relationship to the mean of a series, as measured in
- terms of standard deviations from the mean. If a Z-score is 0, it indicates that
- the data point's score is identical to the mean score. A Z-score of 1.0 would
- indicate a value that is one standard deviation from the mean. Z-scores may be
- positive or negative, with a positive value indicating the score is above the
- mean and a negative score indicating it is below the mean.
-
-Sources:
- https://en.wikipedia.org/wiki/Z-score
- https://www.investopedia.com/terms/z/zscore.asp
-
-Calculation:
- std = std * STDEV(close, length)
- mean = SMA(close, length)
- ZSCORE = (close - mean) / std
-
- */
-
-public class ZSCORE_Series : TSeries {
- private readonly System.Collections.Generic.List _buffer = new();
- protected readonly int _period;
- protected readonly bool _NaN;
- protected readonly TSeries _data;
-
- //core constructors
- public ZSCORE_Series(int period, bool useNaN) {
- _period = period;
- _NaN = useNaN;
- Name = $"ZSCORE({period})";
- }
- public ZSCORE_Series(TSeries source, int period, bool useNaN) : this(period, useNaN) {
- _data = source;
- Name = Name.Substring(0, Name.IndexOf(")")) + $", {(string.IsNullOrEmpty(_data.Name) ? "data" : _data.Name)})";
- _data.Pub += Sub;
- Add(_data);
- }
- public ZSCORE_Series() : this(period: 0, useNaN: false) { }
- public ZSCORE_Series(int period) : this(period: period, useNaN: false) { }
- public ZSCORE_Series(TBars source) : this(source.Close, 0, false) { }
- public ZSCORE_Series(TBars source, int period) : this(source.Close, period, false) { }
- public ZSCORE_Series(TBars source, int period, bool useNaN) : this(source.Close, period, useNaN) { }
- public ZSCORE_Series(TSeries source) : this(source, 0, false) { }
- public ZSCORE_Series(TSeries source, int period) : this(source: source, period: period, useNaN: false) { }
-
- //////////////////
- // core Add() algo
- public override (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
- BufferTrim(buffer:_buffer, value:TValue.v, period:_period, update: update);
- double _sma = _buffer.Average();
-
- double _pvar = 0;
- for (int i = 0; i < _buffer.Count; i++) { _pvar += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
- _pvar /= this._buffer.Count;
- double _psdev = Math.Sqrt(_pvar);
- double _zscore = (_psdev == 0) ? 1 : (TValue.v - _sma) / _psdev;
-
- var res = (TValue.t, Count < _period - 1 && _NaN ? double.NaN : _zscore);
- return base.Add(res, update);
- }
-
- public override (DateTime t, double v) Add(TSeries data) {
- if (data == null) { return (DateTime.Today, Double.NaN); }
- foreach (var item in data) { Add(item, false); }
- return _data.Last;
- }
- public (DateTime t, double v) Add(bool update) {
- return this.Add(TValue: _data.Last, update: update);
- }
- public (DateTime t, double v) Add() {
- return Add(TValue: _data.Last, update: false);
- }
- private new void Sub(object source, TSeriesEventArgs e) {
- Add(TValue: _data.Last, update: e.update);
- }
-
- //reset calculation
- public override void Reset() {
- _buffer.Clear();
- }
-}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..5d40b927
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,37 @@
+
+
+ en-US
+ net8.0
+ enable
+ enable
+ true
+ preview
+ false
+ false
+ true
+ AnyCPU
+ False
+ bin\$(Configuration)\
+ False
+ full
+ true
+ true
+ true
+ snupkg
+ AnyCPU
+ true
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
+
+ D:\Quantower
+ $([System.IO.Directory]::GetDirectories("$(QuantowerRoot)\TradingPlatform", "v1*")[0])
+
+
+
\ No newline at end of file
diff --git a/GitVersion.yml b/GitVersion.yml
index 42d649b0..ffbb8c15 100644
--- a/GitVersion.yml
+++ b/GitVersion.yml
@@ -3,28 +3,21 @@ branches:
main:
regex: ^main$
is-release-branch: true
- is-mainline: true
- prevent-increment-of-merged-branch-version: true
track-merge-target: false
+ tracks-release-branches: false
increment: Patch
- source-branches: [ 'develop' ]
- is-release-branch: true
- is-mainline: true
- label: ''
- develop:
- regex: ^dev$
- increment: Patch
- is-release-branch: false
- prevent-increment-of-merged-branch-version: false
+ source-branches: ['dev']
+ dev:
+ regex: ^dev(elop)?(ment)?$
+ increment: Inherit
track-merge-target: true
source-branches: []
- is-release-branch: false
tracks-release-branches: true
- is-mainline: false
label: dev
ignore:
sha: []
-major-version-bump-message: '\+semver:\s?(feature|major)'
-minor-version-bump-message: '\+semver:\s?(new|update|minor|add)'
-no-bump-message: '\+semver:\s?(skip|none|fix)'
-
+major-version-bump-message: '\+semver:\s?(breaking|major)'
+minor-version-bump-message: '\+semver:\s?(feature|minor)'
+patch-version-bump-message: '\+semver:\s?(fix|patch)'
+no-bump-message: '\+semver:\s?(none|skip)'
+commit-message-incrementing: Enabled
\ No newline at end of file
diff --git a/Indicators/Charts/2MACross_chart.cs b/Indicators/Charts/2MACross_chart.cs
deleted file mode 100644
index 58a8063d..00000000
--- a/Indicators/Charts/2MACross_chart.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using TradingPlatform.BusinessLayer;
-namespace QuanTAlib;
-
-public class MovingAverage_chart : Indicator {
- #region Parameters
- [InputParameter("MA1: Type:", 0, variants: new object[]
- { "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
- "ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
- private int MA1type = 15;
-
- [InputParameter("MA1: Smoothing period:", 1, 1, 999, 1, 1)]
- private int MA1Period = 10;
-
- [InputParameter("MA1: Data source:", 2, variants: new object[]
- { "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
- "OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
- private int MA1DataSource = 3;
-
- [InputParameter("MA2: Type:", 3, variants: new object[]
- { "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
- "ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
- private int MA2type = 16;
-
- [InputParameter("MA2: Smoothing period:", 4, 1, 999, 1, 1)]
- private int MA2Period = 50;
-
- [InputParameter("MA2: Data source:", 5, variants: new object[]
- { "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
- "OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
- private int MA2DataSource = 8;
-
- [InputParameter("Long trades", 6)]
- private bool LongTrades = true;
-
- [InputParameter("Short trades", 6)]
- private bool ShortTrades = true;
-
- #endregion Parameters
-
- protected HistoricalData History;
- private TBars bars;
-
- ///////
- private TSeries MA1, MA2;
- private CROSS_Series trades;
- private COMPARE_Series overunder;
-
- ///////
-
- public MovingAverage_chart() {
- this.SeparateWindow = false;
- this.Name = "MAs Crossover";
- this.AddLineSeries("MA1", Color.LimeGreen, 2, LineStyle.Solid);
- this.AddLineSeries("MA2", Color.OrangeRed, 2, LineStyle.Solid);
- }
-
- protected override void OnInit() {
- this.bars = new();
- this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
- for (int i = this.History.Count - 1; i >= 0; i--) {
- var rec = this.History[i, SeekOriginHistory.Begin];
- bars.Add(rec.TimeLeft, rec[PriceType.Open],
- rec[PriceType.High], rec[PriceType.Low],
- rec[PriceType.Close], rec[PriceType.Volume]);
- }
- this.Name = "MAs Cross: [ ";
- switch (MA1type) {
- case 0:
- MA1 = new SMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"SMA";
- break;
- case 1:
- MA1 = new EMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"EMA";
- break;
- case 2:
- MA1 = new WMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"WMA";
- break;
- case 3:
- MA1 = new T3_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"T3";
- break;
- case 4:
- MA1 = new SMMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"SMMA";
- break;
- case 5:
- MA1 = new TRIMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"TRIMA";
- break;
- case 6:
- MA1 = new DWMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"DWMA";
- break;
- case 7:
- MA1 = new FWMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period);
- this.Name += $"FWMA";
- break;
- case 8:
- MA1 = new DEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"DEMA";
- break;
- case 9:
- MA1 = new TEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"TEMA";
- break;
- case 10:
- MA1 = new ALMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"ALMA";
- break;
- case 11:
- MA1 = new HMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"HMA";
- break;
- case 12:
- MA1 = new HEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"HEMA";
- break;
- case 13:
- double factor = 1.015 * Math.Exp(-0.043 * (double)this.MA1Period);
- MA1 = new MAMA_Series(source: bars.Select(this.MA1DataSource), fastlimit: factor, slowlimit: factor * 0.1, useNaN: false);
- this.Name += $"MAMA";
- break;
- case 14:
- MA1 = new KAMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"KAMA";
- break;
- case 15:
- MA1 = new ZLEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"ZLEMA";
- break;
- default:
- MA1 = new JMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"JMA";
- break;
- }
-
- this.Name = this.Name + $" ({MA1Period}:{TBars.SelectStr(this.MA1DataSource)}) : ";
-
- switch (MA2type) {
- case 0:
- MA2 = new SMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"SMA";
- break;
- case 1:
- MA2 = new EMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"EMA";
- break;
- case 2:
- MA2 = new WMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"WMA";
- break;
- case 3:
- MA2 = new T3_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"T3";
- break;
- case 4:
- MA2 = new SMMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"SMMA";
- break;
- case 5:
- MA2 = new TRIMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"TRIMA";
- break;
- case 6:
- MA2 = new DWMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"DWMA";
- break;
- case 7:
- MA2 = new FWMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period);
- this.Name += $"FWMA";
- break;
- case 8:
- MA2 = new DEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"DEMA";
- break;
- case 9:
- MA2 = new TEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"TEMA";
- break;
- case 10:
- MA2 = new ALMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"ALMA";
- break;
- case 11:
- MA2 = new HMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"HMA";
- break;
- case 12:
- MA2 = new HEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"HEMA";
- break;
- case 13:
- double factor = 1.015 * Math.Exp(-0.043 * (double)this.MA2Period);
- MA2 = new MAMA_Series(source: bars.Select(this.MA2DataSource), fastlimit: factor, slowlimit: factor * 0.1, useNaN: false);
- this.Name += $"MAMA";
- break;
- case 14:
- MA2 = new KAMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"KAMA";
- break;
- case 15:
- MA2 = new ZLEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"ZLEMA";
- break;
- default:
- MA2 = new JMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"JMA";
- break;
- }
- this.Name += $"({MA2Period}:{TBars.SelectStr(this.MA2DataSource)}) ]";
-
- int maxKeep = Math.Max(Math.Max(this.MA1Period, this.MA2Period), 100);
- MA1.Keep = maxKeep;
- MA2.Keep = maxKeep;
- trades.Keep = maxKeep;
- overunder.Keep = maxKeep;
-
- overunder = new(MA1, MA2);
- trades = new(MA1, MA2);
- }
-
- protected override void OnUpdate(UpdateArgs args) {
- bool update = !(args.Reason == UpdateReason.NewBar ||
- args.Reason == UpdateReason.HistoricalBar);
- this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
- this.GetPrice(PriceType.High),
- this.GetPrice(PriceType.Low),
- this.GetPrice(PriceType.Close),
- this.GetPrice(PriceType.Volume), update);
- this.SetValue(this.MA1[^1].v, lineIndex: 0);
- this.SetValue(this.MA2[^1].v, lineIndex: 1);
-
- if (trades[^1].v == 1) {
- this.EndCloud(0, 1, Color.Empty);
- if (LongTrades) {
- this.LinesSeries[0].SetMarker(0, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.UpArrow));
- this.BeginCloud(0, 1, Color.FromArgb(127, Color.Green));
- }
- if (ShortTrades) {
- this.LinesSeries[1].SetMarker(0, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.DownArrow));
- }
- }
- if (trades[^1].v == -1) {
- this.EndCloud(0, 1, Color.Empty);
- if (ShortTrades) {
- this.LinesSeries[1].SetMarker(0, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.UpArrow));
- this.BeginCloud(0, 1, Color.FromArgb(127, Color.Red));
- }
- if (LongTrades) {
- this.LinesSeries[0].SetMarker(0, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.DownArrow));
- }
- }
- }
- public override void OnPaintChart(PaintChartEventArgs args) {
- base.OnPaintChart(args);
- if (this.CurrentChart == null) {return;}
- Graphics graphics = args.Graphics;
- var mainWindow = this.CurrentChart.MainWindow;
- int leftIndex = (int)mainWindow.CoordinatesConverter.GetBarIndex(mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Left));
- int rightIndex = (int)Math.Ceiling(mainWindow.CoordinatesConverter.GetBarIndex(mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Right)));
- int historycount = HistoricalData.Count;
- int ymax = mainWindow.ClientRectangle.Height;
- int xmax = mainWindow.ClientRectangle.Width;
-
- /*
- for (int i = leftIndex; i <= rightIndex; i++) {
- int xi = (int)Math.Round(mainWindow.CoordinatesConverter.GetChartX(Time(Count - 1 - i)));
- int width = this.CurrentChart.BarsWidth;
- int height = (int)((equity[i+historycount].v) *proportion);
-
- Brush bb = Brushes.DarkSlateGray;
- bb = (overunder[i+historycount].v>0 && LongTrades)? Brushes.Green : bb;
- bb = (overunder[i + historycount].v < 0 && ShortTrades) ? Brushes.Red : bb;
-
- graphics.FillRectangle(bb, xi, ymax - height, width, height);
- }
- */
- }
-}
diff --git a/Indicators/Charts/2MASlope_chart.cs b/Indicators/Charts/2MASlope_chart.cs
deleted file mode 100644
index 65acfa9c..00000000
--- a/Indicators/Charts/2MASlope_chart.cs
+++ /dev/null
@@ -1,307 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-using TradingPlatform.BusinessLayer;
-namespace QuanTAlib;
-
-public class MovingAverageSlope_chart : Indicator {
- #region Parameters
- [InputParameter("MA1: Type:", 0, variants: new object[]
- { "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
- "ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
- private int MA1type = 16;
-
- [InputParameter("MA1: Smoothing period:", 1, 1, 999, 1, 1)]
- private int MA1Period = 10;
-
- [InputParameter("MA1: Data source:", 2, variants: new object[]
- { "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
- "OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
- private int MA1DataSource = 3;
-
- [InputParameter("MA2: Type:", 3, variants: new object[]
- { "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FWMA", 7, "DEMA", 8, "TEMA", 9,
- "ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
- private int MA2type = 6;
-
- [InputParameter("MA2: Smoothing period:", 4, 1, 999, 1, 1)]
- private int MA2Period = 50;
-
- [InputParameter("MA2: Data source:", 5, variants: new object[]
- { "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
- "OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
- private int MA2DataSource = 8;
-
- [InputParameter("Data required for slope calc:", 6, 2, 10, 1, 1)]
- private int SlopePeriod = 3;
-
- [InputParameter("Long trades", 7)]
- private bool LongTrades = true;
-
- [InputParameter("Short trades", 8)]
- private bool ShortTrades;
-
- #endregion Parameters
-
- protected HistoricalData History;
- private TBars bars;
-
- ///////
- private TSeries MA1, MA2;
- private SLOPE_Series sMA1, sMA2;
- private CROSS_Series sig1, sig2;
-
- private bool inLong, inShort;
- ///////
-
- public MovingAverageSlope_chart() {
- this.SeparateWindow = false;
- this.Name = "Slopes convergence";
- this.AddLineSeries("MA1", Color.DarkSlateGray, 2, LineStyle.Solid);
- this.AddLineSeries("MA2", Color.DarkSlateGray, 2, LineStyle.Solid);
- }
-
- protected override void OnInit() {
- this.bars = new();
- this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
- for (int i = this.History.Count - 1; i >= 0; i--) {
- var rec = this.History[i, SeekOriginHistory.Begin];
- bars.Add(rec.TimeLeft, rec[PriceType.Open],
- rec[PriceType.High], rec[PriceType.Low],
- rec[PriceType.Close], rec[PriceType.Volume]);
- }
- this.Name = "Slopes convergence: [ ";
- switch (MA1type) {
- case 0:
- MA1 = new SMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"SMA";
- break;
- case 1:
- MA1 = new EMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"EMA";
- break;
- case 2:
- MA1 = new WMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"WMA";
- break;
- case 3:
- MA1 = new T3_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"T3";
- break;
- case 4:
- MA1 = new SMMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"SMMA";
- break;
- case 5:
- MA1 = new TRIMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"TRIMA";
- break;
- case 6:
- MA1 = new DWMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"DWMA";
- break;
- case 7:
- MA1 = new FWMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period);
- this.Name += $"FWMA";
- break;
- case 8:
- MA1 = new DEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"DEMA";
- break;
- case 9:
- MA1 = new TEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"TEMA";
- break;
- case 10:
- MA1 = new ALMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"ALMA";
- break;
- case 11:
- MA1 = new HMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"HMA";
- break;
- case 12:
- MA1 = new HEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"HEMA";
- break;
- case 13:
- double factor = 1.015 * Math.Exp(-0.043 * (double)this.MA1Period);
- MA1 = new MAMA_Series(source: bars.Select(this.MA1DataSource), fastlimit: factor, slowlimit: factor * 0.1, useNaN: false);
- this.Name += $"MAMA";
- break;
- case 14:
- MA1 = new KAMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"KAMA";
- break;
- case 15:
- MA1 = new ZLEMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"ZLEMA";
- break;
- default:
- MA1 = new JMA_Series(source: bars.Select(this.MA1DataSource), period: this.MA1Period, useNaN: false);
- this.Name += $"JMA";
- break;
- }
-
- this.Name = this.Name + $" ({MA1Period}:{TBars.SelectStr(this.MA1DataSource)}) : ";
-
- switch (MA2type) {
- case 0:
- MA2 = new SMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"SMA";
- break;
- case 1:
- MA2 = new EMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"EMA";
- break;
- case 2:
- MA2 = new WMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"WMA";
- break;
- case 3:
- MA2 = new T3_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"T3";
- break;
- case 4:
- MA2 = new SMMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"SMMA";
- break;
- case 5:
- MA2 = new TRIMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"TRIMA";
- break;
- case 6:
- MA2 = new DWMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"DWMA";
- break;
- case 7:
- MA2 = new FWMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period);
- this.Name += $"FWMA";
- break;
- case 8:
- MA2 = new DEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"DEMA";
- break;
- case 9:
- MA2 = new TEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"TEMA";
- break;
- case 10:
- MA2 = new ALMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"ALMA";
- break;
- case 11:
- MA2 = new HMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"HMA";
- break;
- case 12:
- MA2 = new HEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"HEMA";
- break;
- case 13:
- double factor = 1.015 * Math.Exp(-0.043 * (double)this.MA2Period);
- MA2 = new MAMA_Series(source: bars.Select(this.MA2DataSource), fastlimit: factor, slowlimit: factor * 0.1, useNaN: false);
- this.Name += $"MAMA";
- break;
- case 14:
- MA2 = new KAMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"KAMA";
- break;
- case 15:
- MA2 = new ZLEMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"ZLEMA";
- break;
- default:
- MA2 = new JMA_Series(source: bars.Select(this.MA2DataSource), period: this.MA2Period, useNaN: false);
- this.Name += $"JMA";
- break;
- }
- this.Name += $"({MA2Period}:{TBars.SelectStr(this.MA2DataSource)}) ]";
-
- sMA1 = new(MA1, SlopePeriod);
- sMA2 = new(MA2, SlopePeriod);
- sig1 = new(sMA1, 0);
- sig2 = new(sMA2, 0);
-
- int maxKeep = Math.Max(Math.Max(this.MA1Period, this.MA2Period), 100);
-
- MA1.Keep = maxKeep;
- MA2.Keep = maxKeep;
- sMA1.Keep = maxKeep;
- sMA2.Keep = maxKeep;
- sig1.Keep = maxKeep;
- sig2.Keep = maxKeep;
- }
-
- protected override void OnUpdate(UpdateArgs args) {
- bool update = !(args.Reason == UpdateReason.NewBar ||
- args.Reason == UpdateReason.HistoricalBar);
- this.bars.Add(this.Time(),this.Open(), this.High(), this.Low(), this.Close(), this.Volume(), update);
- this.SetValue(this.MA1[^1].v, lineIndex: 0);
- this.SetValue(this.MA2[^1].v, lineIndex: 1);
-
- Color s1Color= (this.sMA1[^1].v > 0)?Color.LimeGreen:Color.OrangeRed;
- Color s2Color = (this.sMA2[^1].v > 0) ? Color.LimeGreen : Color.OrangeRed;
-
- this.LinesSeries[0].SetMarker(0,s1Color);
- this.LinesSeries[1].SetMarker(0,s2Color);
-
- if (sig1[^1].v > 0 || sig2[^1].v > 0) {
- if (sMA1[^1].v >= 0 && sMA2[^1].v >= 0 && LongTrades)
- {
- inLong = true;
- this.BeginCloud(0, 1, Color.FromArgb(127, Color.DarkGreen));
- this.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v)? 0 : 1 ].SetMarker(0, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.UpArrow));
- }
- else {
- this.EndCloud(0, 1, Color.Empty);
- if (inShort && this.Count > 1)
- {
- this.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v) ? 1 : 0].SetMarker(1, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.DownArrow));
- inShort = false;
- }
- }
- }
-
- if (sig1[^1].v < 0 || sig2[^1].v < 0) {
- if (sMA1[^1].v <= 0 && sMA2[^1].v <= 0 && ShortTrades)
- {
- inShort = true;
- this.BeginCloud(0, 1, Color.FromArgb(100, Color.Red));
- this.LinesSeries[(this.MA1[^1].v > this.MA2[^1].v) ? 0 : 1].SetMarker(0, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.UpArrow));
- }
- else {
- this.EndCloud(0, 1, Color.Empty);
- if (inLong && this.Count > 1) {
- LinesSeries[(this.MA1[^1].v > this.MA2[^1].v)?1:0].SetMarker(1, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.DownArrow));
- inLong = false;
- }
- }
- }
- }
- public override void OnPaintChart(PaintChartEventArgs args) {
- base.OnPaintChart(args);
- if (this.CurrentChart == null) {return;}
- Graphics graphics = args.Graphics;
- var mainWindow = this.CurrentChart.MainWindow;
- int leftIndex = (int)mainWindow.CoordinatesConverter.GetBarIndex(mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Left));
- int rightIndex = (int)Math.Ceiling(mainWindow.CoordinatesConverter.GetBarIndex(mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Right)));
-/*
- int historycount = HistoricalData.Count;
- int ymax = mainWindow.ClientRectangle.Height;
-
-
- for (int i = leftIndex; i <= rightIndex; i++) {
- int xi = (int)Math.Round(mainWindow.CoordinatesConverter.GetChartX(Time(Count - 1 - i)));
- int width = this.CurrentChart.BarsWidth;
- int height = (int)((equity[i+historycount].v) *proportion);
-
- Brush bb = Brushes.DarkSlateGray;
- bb = (overunder[i+historycount].v>0 && LongTrades)? Brushes.Green : bb;
- bb = (overunder[i + historycount].v < 0 && ShortTrades) ? Brushes.Red : bb;
-
- graphics.FillRectangle(bb, xi, ymax - height, width, height);
- }
-*/
- }
-}
diff --git a/Indicators/Charts/JMA_chart.cs b/Indicators/Charts/JMA_chart.cs
deleted file mode 100644
index 449f6965..00000000
--- a/Indicators/Charts/JMA_chart.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using TradingPlatform.BusinessLayer;
-using TradingPlatform.BusinessLayer.Chart;
-namespace QuanTAlib;
-
-public class JMA_chart : Indicator {
- #region Parameters
-
- [InputParameter("Data source", 0, variants: new object[]
- { "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
- "OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
- private int DataSource = 3;
-
- [InputParameter("Smoothing period", 1, 1, 999, 1, 1)]
- private int Period = 9;
-
- [InputParameter("Volatility short", 2, 3, 50, 1, 1)]
- private int Vshort = 10;
-
- [InputParameter("Volatility long", 3, 20, 500, 1, 1)]
- private int Vlong = 65;
-
- [InputParameter("Phase", 4, -100, 100, 1, 2)]
- private double Jphase;
-
- #endregion Parameters
-
- ///////
- private JMA_Series indicator;
- ///////
-
- protected TBars bars;
- protected IChartWindow mainWindow;
- protected Graphics graphics;
- protected int firstOnScreenBarIndex, lastOnScreenBarIndex;
- protected HistoricalData History;
- protected int HistPeriod;
- public JMA_chart() {
- Name = "JMA - Jurik Moving Avg";
- Description = "Jurik Moving Average description";
- AddLineSeries(lineName: "JMA", lineColor: Color.Yellow, lineWidth: 3,lineStyle: LineStyle.Solid);
- SeparateWindow = false;
- HistPeriod = Period;
- }
-
-
- protected override void OnInit() {
- base.OnInit();
- bars = new();
- var dur1 = this.HistoricalData.FromTime;
- var dur = this.HistoricalData.Period.Duration.TotalSeconds * (HistPeriod * 4); //seconds of two periods
-
- this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
-
- for (int i = this.History.Count - 1; i >= 0; i--) {
-
- var rec = this.History[i, SeekOriginHistory.Begin];
-
- bars.Add(rec.TimeLeft, rec[PriceType.Open],
- rec[PriceType.High], rec[PriceType.Low],
- rec[PriceType.Close], rec[PriceType.Volume]);
- }
-
- indicator = new(source: bars.Select(DataSource), period: Period, phase: Jphase, vshort: Vshort, vlong: Vlong, useNaN: true);
- indicator.Keep = Math.Max(Period, 100);
- }
-
- protected override void OnUpdate(UpdateArgs args) {
- base.OnUpdate(args);
- bars.Add(Time(), GetPrice(PriceType.Open),
- GetPrice(PriceType.High),
- GetPrice(PriceType.Low),
- GetPrice(PriceType.Close),
- GetPrice(PriceType.Volume),
- update: !(args.Reason == UpdateReason.NewBar || args.Reason == UpdateReason.HistoricalBar));
-
- this.SetValue(indicator[^1].v, lineIndex: 0);
- }
- public override void OnPaintChart(PaintChartEventArgs args) {
- base.OnPaintChart(args);
- if (this.CurrentChart == null) {
- return;
- }
-
- graphics = args.Graphics;
- mainWindow = this.CurrentChart.MainWindow;
-
- DateTime leftTime = mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Left);
- DateTime rightTime = mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Right);
- firstOnScreenBarIndex = (int)mainWindow.CoordinatesConverter.GetBarIndex(leftTime);
- lastOnScreenBarIndex = (int)Math.Ceiling(mainWindow.CoordinatesConverter.GetBarIndex(rightTime));
- }
-
-}
diff --git a/Indicators/Charts/TrailingStop.cs b/Indicators/Charts/TrailingStop.cs
deleted file mode 100644
index 50a1d4f7..00000000
--- a/Indicators/Charts/TrailingStop.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using TradingPlatform.BusinessLayer;
-namespace QuanTAlib;
-
-public class TrailingStop_chart : Indicator {
- #region Parameters
-
- [InputParameter("Period", 0, 1, 100, 1, 1)]
- protected int _period = 30;
-
- [InputParameter("Factor", 1, 1, 100, 0.1, 1)]
- protected double _factor = 10;
-
- [InputParameter("Long TS", 2)]
- private bool _LongTS = true;
-
- [InputParameter("Short TS", 3)]
- private bool _ShortTS = true;
-
- #endregion Parameters
-
- ///////
- private HistoricalData History;
- private TBars bars;
- private ATR_Series _atr;
- private double _tslineL, _ratchetL, _tslineS, _ratchetS;
-
- ///////
-
- public TrailingStop_chart() {
- Name = $"ATR Trailing Stop";
- AddLineSeries(lineName: "TrailingATR Long", lineColor: Color.Yellow, lineWidth: 1,lineStyle: LineStyle.Dot);
- AddLineSeries(lineName: "Ratchet Long", lineColor: Color.Yellow, lineWidth: 3, lineStyle: LineStyle.Solid);
-
- AddLineSeries(lineName: "TrailingATR Short", lineColor: Color.Yellow, lineWidth: 1, lineStyle: LineStyle.Dot);
- AddLineSeries(lineName: "Ratchet Short", lineColor: Color.Yellow, lineWidth: 3, lineStyle: LineStyle.Solid);
-
- SeparateWindow = false;
- }
-
-
- protected override void OnInit() {
- this.Name = $"Trailing Stop (ATR:{_period}, Mult:{_factor:f2})";
- this.bars = new();
-
- this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
- for (int i = this.History.Count - 1; i >= 0; i--) {
- var rec = this.History[i, SeekOriginHistory.Begin];
- bars.Add(rec.TimeLeft, rec[PriceType.Open],
- rec[PriceType.High], rec[PriceType.Low],
- rec[PriceType.Close], rec[PriceType.Volume]);
- }
- _atr = new(source: bars, _period, useNaN: true);
- _ratchetL = Double.NegativeInfinity;
- _ratchetS = Double.PositiveInfinity;
-
- this.LinesSeries[0].Visible = _LongTS;
- this.LinesSeries[1].Visible = _LongTS;
- this.LinesSeries[2].Visible = _ShortTS;
- this.LinesSeries[3].Visible = _ShortTS;
- }
-
- protected override void OnUpdate(UpdateArgs args) {
- bool update = !(args.Reason == UpdateReason.NewBar ||
- args.Reason == UpdateReason.HistoricalBar);
- this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
- this.GetPrice(PriceType.High),
- this.GetPrice(PriceType.Low),
- this.GetPrice(PriceType.Close),
- this.GetPrice(PriceType.Volume), update);
-
- _tslineL = bars.High[^1].v - (_factor * _atr[^1].v);
- _ratchetL = Math.Max(_tslineL,_ratchetL);
- if (_ratchetL > bars.Low[^1].v) {
- this.LinesSeries[1].SetMarker(0, new IndicatorLineMarker(Color.Yellow, bottomIcon: IndicatorLineMarkerIconType.DownArrow));
- _ratchetL = _tslineL;
- }
-
- _tslineS = bars.High[^1].v + (_factor * _atr[^1].v);
- _ratchetS = Math.Min(_tslineS, _ratchetS);
- if (_ratchetS < bars.High[^1].v) {
- this.LinesSeries[3].SetMarker(0, new IndicatorLineMarker(Color.Yellow, upperIcon: IndicatorLineMarkerIconType.UpArrow));
- _ratchetS = _tslineS;
- }
-
- this.SetValue(_tslineL, lineIndex: 0);
- this.SetValue(_ratchetL, lineIndex: 1);
- this.SetValue(_tslineS, lineIndex: 2);
- this.SetValue(_ratchetS, lineIndex: 3);
- }
-}
-
diff --git a/QuanTAlib.sln b/QuanTAlib.sln
index d0b6ce59..44dd6e71 100644
--- a/QuanTAlib.sln
+++ b/QuanTAlib.sln
@@ -1,74 +1,51 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
-VisualStudioVersion = 17.2.32210.308
+VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculations", "Calculations\Calculations.csproj", "{AAE21F8A-9BC2-4647-A9EB-4DC86C569080}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "quantalib", "lib\quantalib.csproj", "{584E06A9-CEB4-476A-85CC-6A8FF3974AE2}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{283EACC9-3AF6-4DAE-9C1C-0F7F8C8CD70D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tests", "tests\tests.csproj", "{D85FEBB4-B651-466F-85CC-FD902378D4D2}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Indicators", "Indicators\Indicators.csproj", "{43AD2D78-024C-4D96-A70B-915CF519965A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MovingAverages", "quantower\averages\Averages.csproj", "{32CC09CC-26E3-4FCE-8932-C0513C4AD766}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strategies", "Strategies\Strategies.csproj", "{FA526AF6-95BC-4AC0-8B46-A304FD06689D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntheticVendor", "SyntheticVendor\SyntheticVendor.csproj", "{20B1B5F1-8C36-4668-B0AE-951C13AE197B}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{47B6ACDB-F535-4FEB-9A0A-C427CAE8C28E}"
- ProjectSection(SolutionItems) = preProject
- docs\.nojekyll = docs\.nojekyll
- docs\ALMA.md = docs\ALMA.md
- docs\DEMA.md = docs\DEMA.md
- docs\DWMA.md = docs\DWMA.md
- docs\EMA.md = docs\EMA.md
- docs\FMA.md = docs\FMA.md
- docs\getting_started.ipynb = docs\getting_started.ipynb
- docs\HEMA.md = docs\HEMA.md
- docs\HMA.md = docs\HMA.md
- docs\HWMA.md = docs\HWMA.md
- docs\index.html = docs\index.html
- docs\indicators.md = docs\indicators.md
- docs\JMA.md = docs\JMA.md
- docs\KAMA.md = docs\KAMA.md
- docs\LICENSE = docs\LICENSE
- docs\MAMA.md = docs\MAMA.md
- docs\QA.md = docs\QA.md
- docs\readme.md = docs\readme.md
- docs\RMA.md = docs\RMA.md
- docs\SMA.md = docs\SMA.md
- docs\SMMA.md = docs\SMMA.md
- docs\T3.md = docs\T3.md
- docs\TEMA.md = docs\TEMA.md
- docs\TRIMA.md = docs\TRIMA.md
- docs\WMA.md = docs\WMA.md
- docs\ZLEMA.md = docs\ZLEMA.md
- docs\_sidebar.md = docs\_sidebar.md
- EndProjectSection
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "quantower", "quantower", "{A8D9AE68-24E3-476C-BB98-244541BB4B43}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "quantower\Statistics\Statistics.csproj", "{B6D3EB11-63B6-430F-B526-E1981B3D8214}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {AAE21F8A-9BC2-4647-A9EB-4DC86C569080}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {AAE21F8A-9BC2-4647-A9EB-4DC86C569080}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {AAE21F8A-9BC2-4647-A9EB-4DC86C569080}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {AAE21F8A-9BC2-4647-A9EB-4DC86C569080}.Release|Any CPU.Build.0 = Release|Any CPU
- {283EACC9-3AF6-4DAE-9C1C-0F7F8C8CD70D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {283EACC9-3AF6-4DAE-9C1C-0F7F8C8CD70D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {283EACC9-3AF6-4DAE-9C1C-0F7F8C8CD70D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {283EACC9-3AF6-4DAE-9C1C-0F7F8C8CD70D}.Release|Any CPU.Build.0 = Release|Any CPU
- {43AD2D78-024C-4D96-A70B-915CF519965A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {43AD2D78-024C-4D96-A70B-915CF519965A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {43AD2D78-024C-4D96-A70B-915CF519965A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {43AD2D78-024C-4D96-A70B-915CF519965A}.Release|Any CPU.Build.0 = Release|Any CPU
- {FA526AF6-95BC-4AC0-8B46-A304FD06689D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FA526AF6-95BC-4AC0-8B46-A304FD06689D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {FA526AF6-95BC-4AC0-8B46-A304FD06689D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FA526AF6-95BC-4AC0-8B46-A304FD06689D}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {E5592DC2-0542-45B2-A0CF-C6B1EDC72B87}
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {584E06A9-CEB4-476A-85CC-6A8FF3974AE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {584E06A9-CEB4-476A-85CC-6A8FF3974AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {584E06A9-CEB4-476A-85CC-6A8FF3974AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {584E06A9-CEB4-476A-85CC-6A8FF3974AE2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D85FEBB4-B651-466F-85CC-FD902378D4D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D85FEBB4-B651-466F-85CC-FD902378D4D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D85FEBB4-B651-466F-85CC-FD902378D4D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D85FEBB4-B651-466F-85CC-FD902378D4D2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {32CC09CC-26E3-4FCE-8932-C0513C4AD766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {32CC09CC-26E3-4FCE-8932-C0513C4AD766}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {32CC09CC-26E3-4FCE-8932-C0513C4AD766}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {32CC09CC-26E3-4FCE-8932-C0513C4AD766}.Release|Any CPU.Build.0 = Release|Any CPU
+ {20B1B5F1-8C36-4668-B0AE-951C13AE197B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {20B1B5F1-8C36-4668-B0AE-951C13AE197B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {20B1B5F1-8C36-4668-B0AE-951C13AE197B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {20B1B5F1-8C36-4668-B0AE-951C13AE197B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B6D3EB11-63B6-430F-B526-E1981B3D8214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B6D3EB11-63B6-430F-B526-E1981B3D8214}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B6D3EB11-63B6-430F-B526-E1981B3D8214}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B6D3EB11-63B6-430F-B526-E1981B3D8214}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {B6D3EB11-63B6-430F-B526-E1981B3D8214} = {A8D9AE68-24E3-476C-BB98-244541BB4B43}
EndGlobalSection
EndGlobal
diff --git a/SyntheticVendor/SyntheticVendor.cs b/SyntheticVendor/SyntheticVendor.cs
new file mode 100644
index 00000000..58ad336b
--- /dev/null
+++ b/SyntheticVendor/SyntheticVendor.cs
@@ -0,0 +1,1133 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using TradingPlatform.BusinessLayer;
+using TradingPlatform.BusinessLayer.Integration;
+
+namespace SyntheticVendorNamespace
+{
+ public class SyntheticVendor : Vendor
+ {
+ private readonly List exchanges;
+ private readonly List assets;
+ private readonly List symbols;
+
+ public SyntheticVendor()
+ {
+ exchanges = new List
+ {
+
+ //Spike,
+ //Impulse,
+ //Triangle,
+ //Sawtooth
+ //Sine
+ //Chirp
+ //White
+ //Gauss
+ //B
+ //HF
+ //Impulse+HF,
+ //Sawtooth+HF
+ //Sine+G
+ //Chirp+G
+ //Complex
+ //Market
+
+ new MessageExchange { Id = "PU", ExchangeName = "1 Pulse" },
+ new MessageExchange { Id = "WA", ExchangeName = "2 Wave" },
+ new MessageExchange { Id = "MD", ExchangeName = "3 Modulation" },
+ new MessageExchange { Id = "NO", ExchangeName = "4 Noise" },
+ new MessageExchange { Id = "BR", ExchangeName = "5 Brownian" },
+ new MessageExchange { Id = "QT", ExchangeName = "6 QuanTAlib" }
+ };
+
+ assets = new List
+ {
+ new MessageAsset { Id = "USD", Name = "USD" },
+
+ };
+
+ symbols = new List
+ {
+ CreateMessageSymbol(id: "W1", name: "1 Digital spike", exchangeId: "QT", assetId: "USD", type: SymbolType.Crypto,
+ description: "Sudden sharp spike in the signal"),
+ CreateMessageSymbol("W2", "2 Dirac delta spike", "QT", "USD", SymbolType.Crypto),
+ CreateMessageSymbol("W8", "4 Sinc pulse", "QT", "USD", SymbolType.Crypto),
+
+ CreateMessageSymbol("W3", "1 Square Wave", "QT", "USD", SymbolType.ETF),
+ CreateMessageSymbol("W4", "2 Sawtooth Wave", "QT", "USD", SymbolType.ETF),
+ CreateMessageSymbol("W5", "3 Inverse sawtooth Wave", "QT", "USD", SymbolType.ETF),
+ CreateMessageSymbol("W6", "4 Triangle Wave", "QT", "USD", SymbolType.ETF),
+ CreateMessageSymbol("W7", "5 Sine Wave", "QT", "USD", SymbolType.ETF),
+
+ CreateMessageSymbol("W11", "1 Amplitude modulation", "QT", "USD", SymbolType.Forex),
+ CreateMessageSymbol("W10", "2 Frequency sweep", "QT", "USD", SymbolType.Forex),
+ CreateMessageSymbol("W12", "3 Frequency modulation", "QT", "USD", SymbolType.Forex),
+
+ CreateMessageSymbol("W13", "1 White noise", "QT", "USD", SymbolType.Indexes),
+ CreateMessageSymbol("W14", "2 Pink noise", "QT", "USD", SymbolType.Indexes),
+ CreateMessageSymbol("W15", "3 Brown noise", "QT", "USD", SymbolType.Indexes),
+
+ CreateMessageSymbol("W16", "1 Fractional Brownian motion", "QT", "USD", SymbolType.Synthetic),
+ CreateMessageSymbol("W17", "2 Geometric Brownian motion", "QT", "USD", SymbolType.Synthetic)
+ };
+
+/*
+ Bond,
+ CFD,
+ Crypto,
+ Debentures,
+ Equities,
+ ETF,
+ FixedIncome,
+ Forex,
+ Forward,
+ Futures,
+ Indexes,
+ Options,
+ Spot,
+ Synthetic,
+ Swap,
+ Warrants,
+
+*/
+
+
+
+ }
+
+ private MessageSymbol CreateMessageSymbol(
+ string id,
+ string name,
+ string exchangeId,
+ string assetId,
+ SymbolType type,
+ string description)
+ {
+ var messageSymbol = new MessageSymbol(id)
+ {
+ Name = name,
+ Description = description,
+ SymbolType = type,
+ ExchangeId = exchangeId,
+ ProductAssetId = assetId,
+
+ // Setting some default values
+ QuotingCurrencyAssetID = "USD",
+ HistoryType = HistoryType.Last,
+ DeltaCalculationType = DeltaCalculationType.TickDirection,
+ LotSize = 1,
+ VariableTickList = new List
+ {
+ new VariableTick(0.01) // Default tick size
+ }
+ };
+
+ return messageSymbol;
+ }
+
+ public static VendorMetaData GetVendorMetaData()
+ {
+ return new VendorMetaData()
+ {
+ VendorName = "Synthetic Vendor",
+ VendorDescription = "A synthetic vendor for testing and demonstration purposes",
+ GetDefaultConnections = () =>
+ {
+ var defaultConnection = Vendor.CreateDefaultConnectionInfo(
+ "Synthetic Connection",
+ "Synthetic Vendor",
+ "", // Replace with actual path if you have a logo
+ allowCreateCustomConnections: true
+ );
+ return new List { defaultConnection };
+ }
+ };
+ }
+
+
+ private MessageSymbol CreateMessageSymbol(string id, string name, string exchangeId, string assetId, SymbolType type)
+ {
+ return new MessageSymbol(id)
+ {
+ Name = name,
+ ExchangeId = exchangeId,
+ ProductAssetId = assetId,
+ QuotingCurrencyAssetID = "USD",
+ QuotingType = SymbolQuotingType.LotSize,
+ LotSize = 1,
+ NettingType = NettingType.OnePosition,
+ VolumeType = SymbolVolumeType.Volume,
+ AllowCalculateRealtimeTicks = true,
+ AllowCalculateRealtimeTrades = false,
+ AllowCalculateRealtimeVolume = true,
+ AllowCalculateRealtimeChange = true,
+ AllowAbbreviatePriceByTickSize = false,
+ NotionalValueStep = 0.01,
+ DeltaCalculationType = DeltaCalculationType.AggressorFlag, // Changed from None to AggressorFlag
+ MinVolumeAnalysisTickSize = 0.01,
+ MaturityDate = DateTime.MaxValue, // Set to max value for non-expiring symbols
+ HistoryType = HistoryType.Last,
+ MinLot = 0.01,
+ LotStep = 0.01,
+ MaxLot = 1000000,
+ SymbolType = type
+/*
+ SymbolType.Unknown,
+ [EnumMember] Forex,
+ [EnumMember] Equities,
+ [EnumMember] CFD,
+ [EnumMember] Indexes,
+ [EnumMember] Futures,
+ [EnumMember] Options,
+ [EnumMember] ETF,
+ [EnumMember] Crypto,
+ [EnumMember] Synthetic,
+ [EnumMember] Spot,
+ [EnumMember] Forward,
+ [EnumMember] FixedIncome,
+ [EnumMember] Warrants,
+
+ [EnumMember] Debentures,
+ [EnumMember] Bond,
+ [EnumMember] Swap,
+*/
+ };
+ }
+
+ public override ConnectionResult Connect(ConnectRequestParameters connectRequestParameters)
+ {
+ // Simulating connection process
+ Thread.Sleep(100); // Simulate some connection delay
+
+ return ConnectionResult.CreateSuccess("Successfully connected to Synthetic Vendor");
+ }
+
+ public override void Disconnect()
+ {
+ // Simulating disconnection process
+ Thread.Sleep(500); // Simulate some disconnection delay
+
+ }
+
+ public override PingResult Ping()
+ {
+ return new PingResult()
+ {
+ State = PingEnum.Connected,
+ PingTime = TimeSpan.FromMilliseconds(2),
+ RoundTripTime = TimeSpan.FromMilliseconds(2)
+ };
+ }
+
+
+
+
+ public override void OnConnected(CancellationToken token)
+ {
+ // This method is called after a successful connection
+ // You can initialize resources or start any necessary processes here
+ base.OnConnected(token);
+
+ // For example, you might want to push some initial messages or data
+ // PushMessage(new MessageVendorEvent("SyntheticVendor connected successfully"));
+ }
+
+
+
+ public override IList GetExchanges(CancellationToken token)
+ {
+ return exchanges;
+ }
+
+ public override IList GetAssets(CancellationToken token)
+ {
+ return assets;
+ }
+
+ public override IList GetSymbols(CancellationToken token)
+ {
+ return symbols;
+ }
+
+ public override void SubscribeSymbol(SubscribeQuotesParameters parameters)
+ {
+ // Empty method for data subscription to be filled later
+ }
+
+ public override void UnSubscribeSymbol(SubscribeQuotesParameters parameters)
+ {
+ // Empty method for data unsubscription to be filled later
+ }
+
+
+ public override IList LoadHistory(HistoryRequestParameters requestParameters)
+ {
+ var historyItems = new List();
+ var symbolId = requestParameters.SymbolId;
+
+ if (string.IsNullOrEmpty(symbolId)) return historyItems;
+
+ DateTime from = requestParameters.FromTime;
+ DateTime to = requestParameters.ToTime;
+
+ TimeSpan periodTimeSpan = requestParameters.Aggregation.GetPeriod.Duration;
+
+ // Define the maximum number of items to generate per request
+ const int MAX_ITEMS_PER_REQUEST = 10000;
+
+ Func waveGenerator = GetWaveGenerator(symbolId);
+
+ DateTime currentTime = from;
+ while (currentTime < to)
+ {
+ DateTime intervalEnd = currentTime.AddTicks(periodTimeSpan.Ticks * MAX_ITEMS_PER_REQUEST);
+ if (intervalEnd > to)
+ intervalEnd = to;
+
+ while (currentTime <= intervalEnd)
+ {
+ var historyItem = waveGenerator(currentTime, periodTimeSpan); //calling generator fuction
+ historyItems.Add(historyItem);
+
+ currentTime = currentTime.Add(periodTimeSpan);
+
+ if (requestParameters.CancellationToken.IsCancellationRequested) return historyItems;
+ }
+
+ currentTime = intervalEnd;
+ }
+
+ return historyItems;
+ }
+
+ private Func GetWaveGenerator(string symbolId)
+ {
+ switch (symbolId)
+ {
+ //case "W0": return GenerateConstant;
+ case "W1": return GenerateSpike;
+ case "W2": return GenerateDiracDelta;
+ case "W3": return GenerateSquareWave;
+ case "W4": return GenerateSawtoothWave;
+ case "W5": return GenerateInverseSawtoothWave;
+ case "W6": return GenerateTriangleWave;
+ case "W7": return GenerateSineWave;
+ case "W8": return GenerateSincWave;
+ case "W9": return GenerateGaussianPulse;
+ case "W10": return GenerateFrequencySweep;
+ case "W11": return GenerateAMSignal;
+ case "W12": return GenerateFMSignal;
+ case "W13": return GenerateWhiteNoise;
+ case "W14": return GeneratePinkNoise;
+ case "W15": return GenerateBrownNoise;
+ case "W16": return GenerateFBM;
+ case "W17": return GenerateGBM;
+
+ default: return GenerateSineWave;
+ }
+ }
+
+ public override HistoryMetadata GetHistoryMetadata(CancellationToken cancellationToken)
+ {
+ return new HistoryMetadata()
+ {
+ AllowedHistoryTypes = new HistoryType[]
+ {
+ HistoryType.Bid,
+ HistoryType.Ask,
+ HistoryType.Midpoint,
+ HistoryType.Last,
+ HistoryType.BidAsk,
+ HistoryType.Mark,
+ },
+ AllowedPeriods = new Period[]
+ {
+ Period.TICK1,
+ Period.SECOND1, Period.SECOND5, Period.SECOND10, Period.SECOND15, Period.SECOND30,
+ Period.MIN1, Period.MIN2, Period.MIN3, Period.MIN4, Period.MIN5,
+ Period.MIN10, Period.MIN15, Period.MIN30,
+ Period.HOUR1, Period.HOUR2, Period.HOUR3, Period.HOUR4,
+ Period.HOUR6, Period.HOUR8, Period.HOUR12,
+ Period.DAY1,
+ Period.WEEK1,
+ Period.MONTH1,
+ Period.YEAR1
+ },
+ UseHistoryLocalCache = false
+ };
+ }
+
+
+/*******************************************************************************************************************************************/
+/*******************************************************************************************************************************************/
+/*******************************************************************************************************************************************/
+/*******************************************************************************************************************************************/
+/*******************************************************************************************************************************************/
+/*******************************************************************************************************************************************/
+/*******************************************************************************************************************************************/
+
+ private HistoryItemBar GenerateSpike(DateTime time, TimeSpan slice)
+ {
+ // Ensure we're working with UTC time
+ DateTime utcTime = time.ToUniversalTime();
+
+ // Calculate the number of hours since the epoch
+ double hoursSinceEpoch = (utcTime - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalHours;
+
+ // Calculate the position within the 25-hour cycle
+ int cyclePosition = (int)Math.Floor(hoursSinceEpoch % 25);
+
+ // Determine if this is a spike hour (hour 24 in the cycle) or the hour after
+ bool isSpike = cyclePosition == 24;
+ bool isAfterSpike = cyclePosition == 0;
+
+ double openValue, closeValue;
+ if (isSpike)
+ {
+ openValue = 0;
+ closeValue = 100;
+ }
+ else if (isAfterSpike)
+ {
+ openValue = 100;
+ closeValue = 0;
+ }
+ else
+ {
+ openValue = closeValue = 0.000001;
+ }
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = openValue,
+ High = Math.Max(openValue, closeValue),
+ Low = Math.Min(openValue, closeValue),
+ Close = closeValue,
+ Volume = Math.Abs(closeValue - openValue),
+ Ticks = time.Add(slice).Ticks - time.Ticks
+ };
+ }
+
+
+
+
+ private static readonly double[] distributionValues = new double[]
+ {
+ 0.010, // Extreme left tail
+ 0.050, // Left tail
+ 0.200, // Left of center
+ 0.480, // Center (peak)
+ 0.200, // Right of center
+ 0.050, // Right tail
+ 0.010 // Extreme right tail
+ };
+
+ private HistoryItemBar GenerateDiracDelta(DateTime time, TimeSpan slice)
+ {
+ // Ensure we're working with UTC time
+ DateTime utcTime = time.ToUniversalTime();
+
+ // Calculate the start of the current day
+ DateTime dayStart = utcTime.Date;
+
+ // Determine which bar of the day we're on
+ int barOfDay = (int)((utcTime - dayStart).Ticks / slice.Ticks);
+
+ double openValue, closeValue;
+ double scaleFactor = 100; // Scale factor to convert to percentage
+
+ // Generate the spike pattern for the first 4 bars of each day
+ switch (barOfDay)
+ {
+ case 0:
+ openValue = 0.000001 * scaleFactor;
+ closeValue = 0.05 * scaleFactor;
+ break;
+ case 1:
+ openValue = 0.05 * scaleFactor;
+ closeValue = 0.50 * scaleFactor;
+ break;
+ case 2:
+ openValue = 0.50 * scaleFactor;
+ closeValue = 0.05 * scaleFactor;
+ break;
+ case 3:
+ openValue = 0.05 * scaleFactor;
+ closeValue = 0.0000001 * scaleFactor;
+ break;
+ default:
+ // Outside of the spike period, use baseline value
+ openValue = closeValue = 0.000001;
+ break;
+ }
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = openValue,
+ High = Math.Max(openValue, closeValue),
+ Low = Math.Min(openValue, closeValue),
+ Close = closeValue,
+ Volume = Math.Abs(closeValue - openValue),
+ Ticks = time.Add(slice).Ticks - time.Ticks
+ };
+ }
+
+
+
+ private HistoryItemBar GenerateSineWave(DateTime time, TimeSpan slice)
+ {
+ // Ensure we're working with UTC time
+ DateTime utcTime = time.ToUniversalTime();
+
+ // Calculate the number of hours since the epoch
+ double minutesSinceEpoch = (utcTime - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMinutes;
+
+ // Calculate the position within the 25-hour cycle
+ double cyclePosition = minutesSinceEpoch % 1500;
+
+
+ // Calculate the sine wave values
+ double frequency = 2 * Math.PI / 1500; // Complete cycle over 25 hours
+ double value = 50 + 50 * Math.Sin(cyclePosition * frequency); // Oscillate between 0 and 100
+ double nextValue = 50 + 50 * Math.Sin((cyclePosition + slice.TotalMinutes) * frequency);
+
+ double factor = 0.6 * Math.Abs (nextValue - value);
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+
+ High = Math.Max(value, nextValue)+factor,
+ Low = Math.Min(value, nextValue)-factor,
+
+ Close = nextValue,
+ Volume = Math.Abs(nextValue - value) * 100, // Volume proportional to price change
+ Ticks = time.Add(slice).Ticks - time.Ticks
+ };
+ }
+
+
+ private HistoryItemBar GenerateSquareWave(DateTime time, TimeSpan slice)
+ {
+ // Ensure we're working with UTC time
+ DateTime utcTime = time.ToUniversalTime();
+
+ // Calculate the time within the day (in hours)
+ double hoursInDay = utcTime.TimeOfDay.TotalHours;
+
+ double openValue, closeValue;
+
+ if (hoursInDay < 12)
+ {
+ // First half of the day
+ openValue = 99;
+ closeValue = 100;
+ }
+ else
+ {
+ // Second half of the day
+ openValue = 1;
+ closeValue = 0.0001;
+ }
+
+ // Handle transition bars
+ if (Math.Abs(hoursInDay - 12) < slice.TotalHours / 2)
+ {
+ // Transition from 100 to 0 at noon
+ openValue = 100;
+ closeValue = 0.0001;
+ }
+ else if (hoursInDay < slice.TotalHours / 2 || hoursInDay > 24 - slice.TotalHours / 2)
+ {
+ // Transition from 0 to 100 at midnight
+ openValue = 0.0001;
+ closeValue = 100;
+ }
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = openValue,
+ High = Math.Max(openValue, closeValue),
+ Low = Math.Min(openValue, closeValue),
+ Close = closeValue,
+ Volume = Math.Abs(closeValue - openValue),
+ Ticks = time.Add(slice).Ticks - time.Ticks
+ };
+ }
+
+ private HistoryItemBar GenerateSawtoothWave(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double period = 24; // 24-hour period
+ double position = hours % period;
+ double value = 200 * (position / period) - 100;
+ double nextValue = 200 * ((position + slice.TotalHours) % period / period) - 100;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = Math.Max(value, nextValue),
+ Low = Math.Min(value, nextValue),
+ Close = nextValue,
+ Volume = 100,
+ Ticks = 100
+ };
+ }
+
+ private HistoryItemBar GenerateInverseSawtoothWave(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double period = 24; // 24-hour period
+ double position = hours % period;
+ double value = 100 - (200 * (position / period));
+ double nextValue = 100 - (200 * ((position + slice.TotalHours) % period / period));
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = Math.Max(value, nextValue),
+ Low = Math.Min(value, nextValue),
+ Close = nextValue,
+ Volume = 100,
+ Ticks = 100
+ };
+ }
+
+ private HistoryItemBar GeneratePulseWave(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double period = 24; // 24-hour period
+ double position = hours % period;
+ double value = position < period / 5 ? 100 : -100; // 20% duty cycle
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = 100,
+ Low = -100,
+ Close = value,
+ Volume = 100,
+ Ticks = 100
+ };
+ }
+
+ private HistoryItemBar GenerateTriangleWave(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double period = 24;
+ double position = hours % period;
+ double value = 200 * (Math.Abs(position / period - 0.5) - 0.25) * 100;
+ double nextValue = 200 * (Math.Abs(((position + slice.TotalHours) % period) / period - 0.5) - 0.25) * 100;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = Math.Max(value, nextValue),
+ Low = Math.Min(value, nextValue),
+ Close = nextValue,
+ Volume = 100,
+ Ticks = 100
+ };
+ }
+
+ private HistoryItemBar GenerateSincWave(DateTime time, TimeSpan slice)
+ {
+ double minutes = (time - DateTime.UnixEpoch).TotalMinutes;
+ double period = 1500.0; // 24-hour period
+ double frequency = 2 * Math.PI / period; // Full cycle over 24 hours
+
+ // Adjust time to center the main peak at 12 hours
+ double t = minutes % period - period / 2;
+
+ // Scale factor
+ double scaleFactor = 7.0;
+
+ // Calculate Sinc value
+ double x = scaleFactor * frequency * t;
+ double sincValue = x != 0 ? 100 * Math.Sin(x) / x : 100;
+
+ // Calculate next value
+ double nextT = ((minutes + slice.TotalMinutes) % period) - period / 2;
+ double nextX = scaleFactor * frequency * nextT;
+ double nextSincValue = nextX != 0 ? 100 * Math.Sin(nextX) / nextX : 100;
+
+ // Ensure minimum value
+ double minValue = 0.00001;
+ sincValue = Math.Sign(sincValue) * Math.Max(Math.Abs(sincValue), minValue);
+ nextSincValue = Math.Sign(nextSincValue) * Math.Max(Math.Abs(nextSincValue), minValue);
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = sincValue,
+ High = Math.Max(sincValue, nextSincValue),
+ Low = Math.Min(sincValue, nextSincValue),
+ Close = nextSincValue,
+ Volume = Math.Abs(nextSincValue - sincValue), // Volume as the change in value
+ Ticks = slice.Ticks
+ };
+ }
+
+ private HistoryItemBar GenerateGaussianPulse(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double totalPeriod = 24.0; // 24-hour total cycle
+ double pulsePeriod = 12.0; // 12-hour pulse duration
+ double position = hours % totalPeriod;
+
+ // Parameters for the Gaussian pulse
+ double amplitude = 100.0; // Maximum amplitude
+ double center = pulsePeriod / 2.0; // Center of the pulse (at 6 hours within the pulse period)
+ double width = pulsePeriod / 6.0; // Width of the pulse (adjusts the spread)
+
+ double baselineValue = 0.00001; // Value outside the pulse period
+
+ // Calculate the Gaussian pulse value
+ double value;
+ if (position < pulsePeriod)
+ {
+ value = amplitude * Math.Exp(-Math.Pow(position - center, 2) / (2 * Math.Pow(width, 2))) + baselineValue;
+ }
+ else
+ {
+ value = baselineValue;
+ }
+
+ // Calculate the next value for the slice
+ double nextPosition = (hours + slice.TotalHours) % totalPeriod;
+ double nextValue;
+ if (nextPosition < pulsePeriod)
+ {
+ nextValue = amplitude * Math.Exp(-Math.Pow(nextPosition - center, 2) / (2 * Math.Pow(width, 2))) + baselineValue;
+ }
+ else
+ {
+ nextValue = baselineValue;
+ }
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = Math.Max(value, nextValue),
+ Low = Math.Min(value, nextValue),
+ Close = nextValue,
+ Volume = Math.Abs(nextValue - value), // Volume as the change in value
+ Ticks = slice.Ticks
+ };
+ }
+
+ private HistoryItemBar GenerateFrequencySweep(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double sweepPeriod = 48.0; // 48-hour period
+
+ // Starting frequency (very low)
+ double minFreq = Math.PI / 48.0;
+
+ // Calculate the ending frequency to ensure continuity
+ double maxFreq = Math.PI * 1.0 * Math.Exp(2 * Math.PI / sweepPeriod);
+
+ // Calculate the exponential factor for frequency sweep
+ double expFactor = Math.Log(maxFreq / minFreq) / sweepPeriod;
+
+ // Calculate the overall phase up to the current time
+ double totalPhase = (minFreq / expFactor) * (Math.Exp(expFactor * (hours % sweepPeriod)) - 1);
+
+ // Shift the phase to start the cycle at 100 (cosine-like behavior)
+ totalPhase += Math.PI / 2;
+
+ // Calculate the value of the signal at the current time
+ double value = 100.0 * Math.Sin(totalPhase);
+
+ // Calculate the value of the signal at the end of the slice
+ double nextPhase = (minFreq / expFactor) * (Math.Exp(expFactor * ((hours + slice.TotalHours) % sweepPeriod)) - 1);
+ nextPhase += Math.PI / 2; // Apply the same phase shift
+ double nextValue = 100.0 * Math.Sin(nextPhase);
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = Math.Max(value, nextValue),
+ Low = Math.Min(value, nextValue),
+ Close = nextValue,
+ Volume = Math.Abs(nextValue - value), // Volume as the change in value
+ Ticks = slice.Ticks
+ };
+ }
+
+
+ Random random = new Random();
+ private double currentAmplitude = 100;
+ private HistoryItemBar GenerateAMSignal(DateTime time, TimeSpan slice)
+ {
+ double hours = (time - DateTime.UnixEpoch).TotalHours;
+ double period = 12.0;
+ double frequency = 2 * Math.PI / period; // Frequency for a 5-hour period
+
+ // Determine the start of the current 5-hour cycle
+ double cycleStartTime = Math.Floor(hours / period) * period;
+
+ // Calculate the phase of the signal within the current 5-hour cycle
+ double phase = frequency * (hours % period);
+
+ // If we're at the start of a new 5-hour cycle, generate a new amplitude
+ if (hours % period == 0)
+ {
+ currentAmplitude = random.NextDouble() * 100;
+ }
+
+ // Calculate the value of the signal at the current time
+ double value = currentAmplitude * Math.Sin(phase);
+
+ // Calculate the value of the signal at the end of the slice
+ double nextPhase = frequency * ((hours + slice.TotalHours) % period);
+ double nextValue = currentAmplitude * Math.Sin(nextPhase);
+
+ // Create the HistoryItemBar
+ var historyItem = new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = value,
+ High = Math.Max(value, nextValue),
+ Low = Math.Min(value, nextValue),
+ Close = nextValue, // Set Close to the newly calculated value
+ Volume = Math.Abs(nextValue), // Volume as the change in value
+ Ticks = slice.Ticks
+ };
+
+ return historyItem;
+ }
+
+
+ private double currentFrequency = Math.PI / 220.0; // Initial frequency
+ private double accumulatedPhase = 0;
+ private double lastCloseValue = 0; // To store the last close value
+
+ private HistoryItemBar GenerateFMSignal(DateTime time, TimeSpan slice)
+ {
+ double amplitude = 100.0; // Maximum amplitude
+ double minFreq = Math.PI / 256.0;
+ double maxFreq = Math.PI / 32.0;
+
+ // Randomly adjust the frequency
+ double frequencyStep = (maxFreq - minFreq) * 0.2; // 20% of the frequency range
+ currentFrequency += (random.NextDouble() - 0.5) * 2 * frequencyStep;
+ currentFrequency = Math.Max(minFreq, Math.Min(maxFreq, currentFrequency)); // Clamp frequency
+
+ // Calculate phase increment for this slice
+ double phaseIncrement = currentFrequency * slice.TotalHours;
+
+ // Calculate the open value (which is the last close value)
+ double openValue = lastCloseValue;
+
+ // Calculate the close value
+ accumulatedPhase += phaseIncrement;
+ double closeValue = amplitude * Math.Sin(2 * Math.PI * accumulatedPhase);
+
+ // Determine high and low values
+ double midPhase = accumulatedPhase - (phaseIncrement / 2);
+ double midValue = amplitude * Math.Sin(2 * Math.PI * midPhase);
+ double highValue = Math.Max(Math.Max(openValue, closeValue), midValue);
+ double lowValue = Math.Min(Math.Min(openValue, closeValue), midValue);
+
+ // Store the close value for the next iteration
+ lastCloseValue = closeValue;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = openValue,
+ High = highValue,
+ Low = lowValue,
+ Close = closeValue,
+ Volume = Math.Abs(closeValue - openValue), // Volume as the change in value
+ Ticks = slice.Ticks
+ };
+ }
+
+
+ private HistoryItemBar GenerateWhiteNoise(DateTime time, TimeSpan slice)
+ {
+ double volatility = 2;
+ double meanReversionStrength = 0.1;
+
+ double openNoise = random.NextDouble();
+ double open = previousClose + volatility * openNoise + meanReversionStrength * (meanPrice - previousClose);
+ double closeNoise = random.NextDouble();
+ double close = open + volatility * closeNoise + meanReversionStrength * (meanPrice - open);
+
+ // Determine High and Low
+ double high = Math.Max(open, close);
+ double low = Math.Min(open, close);
+
+ // Add variation to High and Low
+ double highNoise = Math.Abs(random.NextDouble());
+ high += volatility * highNoise;
+
+ double lowNoise = Math.Abs(random.NextDouble());
+ low -= volatility * lowNoise;
+
+ double volume = Math.Abs(random.NextDouble()) * 1000 + 100;
+
+ previousClose = close;
+
+
+ // Create the HistoryItemBar
+ var historyItem = new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = open,
+ High = high,
+ Low = low,
+ Close = close,
+ Volume = volume,
+ Ticks = slice.Ticks
+ };
+
+ return historyItem;
+ }
+
+
+
+private double previousClose = 50;
+private const double meanPrice = 50;
+
+private HistoryItemBar GeneratePinkNoise(DateTime time, TimeSpan slice)
+{
+ double volatility = 2;
+ double meanReversionStrength = 0.1;
+
+ // Generate open price
+ double openNoise = GeneratePinkNoiseValue();
+ double open = previousClose + volatility * openNoise + meanReversionStrength * (meanPrice - previousClose);
+
+ // Generate close price
+ double closeNoise = GeneratePinkNoiseValue();
+ double close = open + volatility * closeNoise + meanReversionStrength * (meanPrice - open);
+
+ // Determine High and Low
+ double high = Math.Max(open, close);
+ double low = Math.Min(open, close);
+
+ // Add variation to High and Low
+ double highNoise = Math.Abs(GeneratePinkNoiseValue());
+ high += volatility * highNoise;
+
+ double lowNoise = Math.Abs(GeneratePinkNoiseValue());
+ low -= volatility * lowNoise;
+
+ double volume = Math.Abs(GeneratePinkNoiseValue()) * 1000 + 100;
+
+ // Update previous close for the next iteration
+ previousClose = close;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = open,
+ High = high,
+ Low = low,
+ Close = close,
+ Volume = volume,
+ Ticks = slice.Ticks
+ };
+}
+
+
+ private const int NumOctaves = 6;
+ private double[] pinkNoiseState = new double[NumOctaves];
+ private double GeneratePinkNoiseValue()
+ {
+ double total = 0;
+
+ for (int i = 0; i < NumOctaves; i++)
+ {
+ double white = random.NextDouble() * 2 - 1;
+ pinkNoiseState[i] = (pinkNoiseState[i] + white) * 0.5;
+ total += pinkNoiseState[i] * Math.Pow(2, -i);
+ }
+
+ // Normalize
+ return total / NumOctaves;
+ }
+
+
+
+private double lastValue = 0;
+
+private HistoryItemBar GenerateBrownNoise(DateTime time, TimeSpan slice)
+{
+ double dt = slice.TotalDays / 365.0; // Time step in years
+ double sigma = 25.0; // Annual volatility
+
+ double increment = GenerateGaussian(0, sigma * Math.Sqrt(dt));
+ double open = lastValue * (1 + GenerateGaussian(0, 0.05));
+ double close = open + increment;
+
+ // Simulate intra-period high and low
+ double high = Math.Max(open, close);
+ high += high * Math.Abs(GenerateGaussian(0, 0.06));
+ double low = Math.Min(open, close);
+ low -= low * Math.Abs(GenerateGaussian(0, 0.06));
+
+ lastValue = close;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = open,
+ High = high,
+ Low = low,
+ Close = close,
+ Volume = Math.Abs(close - open) * 1000, // Simplified volume calculation
+ Ticks = slice.Ticks
+ };
+}
+// Helper method to generate Gaussian distributed random numbers
+private double GenerateGaussian(double mean, double stdDev)
+{
+ double u1 = 1.0 - random.NextDouble(); // Uniform(0,1] random doubles
+ double u2 = 1.0 - random.NextDouble();
+ double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);
+ return mean + stdDev * randStdNormal;
+}
+
+
+
+private double GBMLastClose = 100; // Starting price
+private double GBMMu = 0.05; // Annual drift
+private double GBMSigma = 0.2; // Annual volatility
+
+private HistoryItemBar GenerateGBM(DateTime time, TimeSpan slice)
+{
+ // Convert time slice to years
+ double dt = slice.TotalDays / 365.0;
+
+ // Generate a random normal variable for the main price movement
+ double epsilon = GenerateGaussian(0, 1);
+
+ // Calculate the price movement using GBM equation
+ double drift = (GBMMu - 0.5 * GBMSigma * GBMSigma) * dt;
+ double diffusion = GBMSigma * Math.Sqrt(dt) * epsilon;
+ double returnValue = Math.Exp(drift + diffusion);
+
+ // Add variability between previous close and current open
+ double openVariability = GBMLastClose * GBMSigma * Math.Sqrt(dt) * GenerateGaussian(0, 1) * 0.1;
+ double open = GBMLastClose + openVariability;
+
+ // Calculate new close price
+ double close = open * returnValue;
+
+ // Generate High and Low values
+ double highLowRange = Math.Max(Math.Abs(close - open), GBMLastClose * GBMSigma * Math.Sqrt(dt) * Math.Abs(GenerateGaussian(0, 1)));
+ double high = Math.Max(open, close) + highLowRange * 0.5;
+ double low = Math.Min(open, close) - highLowRange * 0.5;
+
+ // Generate volume (you may want to adjust this based on your needs)
+ double volume = Math.Max(100, 1000 * Math.Abs(close - open) + 500 * GenerateGaussian(0, 1));
+
+ // Update last close for next iteration
+ GBMLastClose = close;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = open,
+ High = high,
+ Low = low,
+ Close = close,
+ Volume = volume,
+ Ticks = slice.Ticks
+ };
+}
+
+ private double FBMLastClose = 100; // Starting price
+ private double FBMHurst = 0.85; // Hurst parameter (0.5 < H < 1 for persistent fBm)
+ private double FBMSigma = 0.25; // Volatility parameter
+ private double FBMDrift = 0.001; // drift
+
+ private HistoryItemBar GenerateFBM(DateTime time, TimeSpan slice)
+ {
+ double dt = Math.Pow(slice.TotalDays / 365.0, 0.5);
+
+ double epsilon = GenerateFractionalGaussianNoise(FBMHurst);
+
+ double drift = FBMDrift * dt;
+ double diffusion = FBMSigma * Math.Pow(dt, FBMHurst) * epsilon;
+
+ double openVariability = FBMLastClose * FBMSigma * Math.Pow(dt, FBMHurst) * GenerateFractionalGaussianNoise(FBMHurst) * 0.1;
+ double open = FBMLastClose + openVariability;
+
+ double close = open * Math.Exp(drift + diffusion);
+
+ double highLowRange = Math.Max(Math.Abs(close - open),
+ FBMLastClose * FBMSigma * Math.Pow(dt, FBMHurst) * Math.Abs(GenerateFractionalGaussianNoise(FBMHurst)) * 2);
+ double high = Math.Max(open, close) + highLowRange * 0.5;
+ double low = Math.Min(open, close) - highLowRange * 0.5;
+
+ double volume = Math.Max(100, 2000 * Math.Abs(close - open) +
+ 1000 * Math.Abs(GenerateFractionalGaussianNoise(FBMHurst)));
+
+ FBMLastClose = close;
+
+ return new HistoryItemBar
+ {
+ TicksLeft = time.Ticks,
+ TicksRight = time.Add(slice).Ticks - 1,
+ Open = open,
+ High = high,
+ Low = low,
+ Close = close,
+ Volume = volume,
+ Ticks = slice.Ticks
+ };
+ }
+
+ private double GenerateFractionalGaussianNoise(double hurst)
+ {
+ double sum = 0;
+ int n = 1000; // Number of terms in the approximation
+
+ for (int i = 1; i <= n; i++)
+ {
+ double ri = GenerateGaussian(0, 1);
+ sum += (Math.Pow(i, hurst - 0.5) - Math.Pow(i - 1, hurst - 0.5)) * ri;
+ }
+
+ return sum / Math.Sqrt(n);
+ }
+
+
+
+ // Add other necessary overrides and implementations as needed
+ }
+}
\ No newline at end of file
diff --git a/SyntheticVendor/SyntheticVendor.csproj b/SyntheticVendor/SyntheticVendor.csproj
new file mode 100644
index 00000000..6703559f
--- /dev/null
+++ b/SyntheticVendor/SyntheticVendor.csproj
@@ -0,0 +1,15 @@
+
+
+ Vendor
+
+
+
+
+ ..\.github\TradingPlatform.BusinessLayer.dll
+
+
+ TradingPlatform.BusinessLayer.xml
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Basic tests/Indicators.cs b/Tests/Basic tests/Indicators.cs
deleted file mode 100644
index a9a9175e..00000000
--- a/Tests/Basic tests/Indicators.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-using Xunit;
-using System;
-using QuanTAlib;
-
-namespace Basics;
-#nullable disable
-public class Indicators
-{
- private static Type[] maSeriesTypes = new Type[]
- {
- typeof(SMA_Series),
- typeof(EMA_Series),
- typeof(DEMA_Series),
- typeof(TEMA_Series),
- typeof(WMA_Series),
- typeof(ALMA_Series),
- typeof(DWMA_Series),
- typeof(FWMA_Series),
- typeof(HMA_Series),
- typeof(ZLEMA_Series),
- typeof(RMA_Series),
- typeof(HEMA_Series),
- typeof(JMA_Series),
- typeof(CUSUM_Series),
- typeof(SMMA_Series),
- typeof(T3_Series),
- typeof(KAMA_Series),
- typeof(TRIMA_Series),
- typeof(MAMA_Series),
- typeof(HWMA_Series),
-};
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Name_exists(Type classType)
- {
- TSeries data = new("Data") {1,2,3};
-
- var MA_Series = Activator.CreateInstance(classType, data, 5, false) as TSeries;
- Assert.NotEmpty(MA_Series.Name);
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Series_Length(Type classType)
- {
- GBM_Feed feed = new(1000);
- TSeries data = feed.OHLC4;
-
- var MA_Series = Activator.CreateInstance(classType, data, 5, false) as TSeries;
- Assert.Equal(1000, MA_Series.Count);
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Return_data(Type classType)
- {
- TSeries data = new() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-
- var MA_Series = Activator.CreateInstance(classType, data, 5, false) as TSeries;
- var result = MA_Series.Add(20);
- Assert.Equal(result.v, MA_Series.Last.v);
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Update(Type classType)
- {
- TSeries data = new() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-
- var MA_Series = Activator.CreateInstance(classType, data, 5, false) as TSeries;
- var pre_update = MA_Series.Last.v;
-
- double pre_data = data.Last.v;
- data.Add(20, true);
- data.Add(pre_data, true);
-
- Assert.Equal(pre_update, MA_Series.Last.v);
- Assert.Equal(data.Count, MA_Series.Count);
-}
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Period_zero(Type classType)
- {
- GBM_Feed feed = new(100);
- TSeries data = feed.OHLC4;
-
- var MA_Series = Activator.CreateInstance(classType, data, 0, false) as TSeries;
- Assert.Equal(data.Count, MA_Series.Count);
- Assert.False(double.IsNaN(MA_Series.Last.v));
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Reset(Type classType)
- {
- GBM_Feed feed = new(10);
- TSeries data = feed.OHLC4;
- var MA_Series = Activator.CreateInstance(classType, data, 10, false) as TSeries;
- MA_Series.Reset();
- data.Add(0);
- Assert.Equal(data.Last.v, MA_Series.Last.v);
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Period_one(Type classType)
- {
- GBM_Feed feed = new(100);
- TSeries data = feed.OHLC4;
-
- var MA_Series = Activator.CreateInstance(classType, data, 1, false) as TSeries;
- Assert.InRange(MA_Series.Last.v - data.Last.v, -10e-6, 10e-6);
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void NaN_test(Type classType)
- {
- GBM_Feed feed = new(100);
- TSeries data = feed.OHLC4;
-
- var MA_Series = Activator.CreateInstance(classType, data, 10, true) as TSeries;
- Assert.True(double.IsNaN(MA_Series[0].v));
- Assert.True(double.IsNaN(MA_Series[8].v));
- Assert.False(double.IsNaN(MA_Series[9].v));
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void Edge_numbers(Type classType)
- {
- TSeries data = new() { double.Epsilon, double.PositiveInfinity, double.MaxValue, double.NegativeInfinity };
- var MA_Series = Activator.CreateInstance(classType, data, 10, true) as TSeries;
- Assert.Equal(4, MA_Series.Count);
- }
-
- [Theory]
- [MemberData(nameof(MASeriesData))]
- public void handling_NaN(Type classType) {
- TSeries data = new("Name") { 1, 2, 3, 4, 5, 6, double.NaN, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
-var MA_Series = Activator.CreateInstance(classType, data, 10, true) as TSeries;
- Assert.False(double.IsNaN(MA_Series.Last.v));
- }
-
-public static IEnumerable