### C# Indicator Setup Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Basic C# code demonstrating the setup for a custom ATAS indicator by inheriting from the `IndicatorBase` class. This is a fundamental step in indicator development. ```csharp public class CustomIndicator : IndicatorBase { // Required indicator setup } ``` -------------------------------- ### C# Project Setup for ATAS Strategy Source: https://github.com/jaggerxtrm/atas-docs/blob/master/DeltaAnalysisStrategy_Development_Notes.txt This code snippet demonstrates the initial setup for a C# class library project designed for developing trading strategies within the ATAS platform. It outlines the necessary steps, including creating the project, setting the target framework, and referencing required NuGet packages and ATAS assemblies. This ensures the project is correctly configured to interact with the ATAS platform's functionalities. ```csharp ```csharp ATAS.Platform.SDK ``` ``` -------------------------------- ### Citing Documentation Sources in Markdown Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Provides an example of how to cite documentation sources when responding to queries, enhancing transparency and verifiability. This includes referencing specific sections or files. ```markdown Based on [documentation section X], the correct implementation is... I've verified this pattern in: - symbols.json: [reference] - methods.json: [reference] - common_patterns.json: [reference] ``` -------------------------------- ### C# Parameter Management Pattern Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Example of a C# property implementation for managing indicator parameters, including attributes for display name, description, and range, along with logic to trigger recalculation on value change. ```csharp [DisplayName("Period")] [Description("Calculation period")] [Range(1, 999)] public int Period { get => period; set { period = value; RecalculateValues(); } } ``` -------------------------------- ### C# Strategy Base Class and Constructor Source: https://github.com/jaggerxtrm/atas-docs/blob/master/DeltaAnalysisStrategy_Development_Notes.txt Demonstrates the selection of base classes and constructor setup for creating trading strategies in C#. It illustrates the use of `ChartStrategy` or `Strategy` based on the need for chart visualization and initializes the strategy with a real-time calculation setting. ```csharp ```csharp public class MyStrategy : ChartStrategy { public MyStrategy() : base(true) // true enables real-time calculation { // Initialize here } } ``` ``` -------------------------------- ### Documentation Structure JSON Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md This JSON snippet illustrates the hierarchical structure of the ATAS documentation, mapping core concepts and API references to their respective file paths. ```json { "documentation_map": { "core_concepts": { "indicators": "indicators/index.json", "strategies": "strategies/index.json", "data_series": "data_series/index.json", "graphics": "graphics/index.json", "chart_management": "chart_management/index.json" }, "api_reference": {...}, "search_indexes": {...}, "relationships": {...}, "quick_access": {...} } } ``` -------------------------------- ### Markdown for Custom Implementation Notes Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Provides standardized markdown formats for noting custom implementations, deviations from documented patterns, and for requesting user confirmation on implementing custom solutions versus documented patterns. These are used to ensure clarity when extending or altering existing documentation. ```markdown NOTE: This is a custom implementation extending the documented pattern at [reference]. ``` ```markdown CUSTOM: This approach differs from documented patterns because [reason]. ``` ```markdown Please confirm if you want to: [ ] Follow documented pattern [reference] [ ] Implement custom solution ``` -------------------------------- ### Incorrect vs. Correct Method Signature in C# Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Illustrates the importance of verifying method signatures against documentation. Incorrect signatures can lead to runtime errors, while correct ones ensure proper implementation based on documented requirements. ```csharp // WRONG - Don't assume parameter types public void OnCalculate(double value) // CORRECT - Verify in documentation first public override void OnCalculate(int bar, decimal value) ``` -------------------------------- ### Incorrect vs. Correct Property Attributes in C# Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Demonstrates the difference between inventing property attributes and using documented ones. Adhering to documented attributes ensures that properties function as intended within the system. ```csharp // WRONG - Don't invent attributes [CustomRange(0, 100)] // CORRECT - Use documented attributes [Range(1, 999)] [DisplayName("Period")] ``` -------------------------------- ### Implement Moving Average Indicator with ValueDataSeries in C# Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Shows how to create a Moving Average indicator using `ValueDataSeries` in C#. This example defines two data series for fast and slow MAs, configures their visual properties, and implements the `OnCalculate` method to compute and store the moving average values. ```csharp using ATAS.Indicators; using System.Windows.Media; public class MovingAverageIndicator : Indicator { private readonly ValueDataSeries _fastMA; private readonly ValueDataSeries _slowMA; private readonly SMA _smaFast = new SMA(); private readonly SMA _smaSlow = new SMA(); public MovingAverageIndicator() { // Configure default data series ((ValueDataSeries)DataSeries[0]).Color = Colors.Blue; ((ValueDataSeries)DataSeries[0]).VisualType = VisualMode.Line; ((ValueDataSeries)DataSeries[0]).Width = 2; // Add second data series for slow MA _slowMA = new ValueDataSeries("Slow MA") { Color = Colors.Red, VisualType = VisualMode.Line, Width = 2 }; DataSeries.Add(_slowMA); _smaFast.Period = 10; _smaSlow.Period = 20; } protected override void OnCalculate(int bar, decimal value) { var fastValue = _smaFast.Calculate(bar, value); var slowValue = _smaSlow.Calculate(bar, value); this[bar] = fastValue; _slowMA[bar] = slowValue; } } ``` -------------------------------- ### Verifying Component Existence in Indices (JSON) Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Before implementing any feature, verify the existence of classes and methods by checking the symbols and methods indices. This prevents assumptions about component availability and ensures adherence to documented structures. ```json { "symbols": "indexes/symbols.json" } { "methods": "indexes/methods.json" } ``` -------------------------------- ### Relationship Navigation JSON Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md JSON object detailing navigation paths for understanding relationships between ATAS components, including class hierarchy, interface implementations, and component dependencies. ```json { "class_hierarchy": "relationships/class_hierarchy.json", "interface_implementations": "relationships/interface_implementations.json", "component_dependencies": "relationships/component_dependencies.json" } ``` -------------------------------- ### Checking Class Hierarchy for Inheritance (JSON) Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Verify inheritance chains and base class capabilities by consulting the class hierarchy index. This is crucial for understanding method overrides and required interface implementations. ```json { "class_hierarchy": "relationships/class_hierarchy.json" } ``` -------------------------------- ### Search Index JSON Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md JSON structure for ATAS search indexes, providing file paths for symbols, methods, properties, and keywords to facilitate component discovery. ```json { "symbols": "indexes/symbols.json", "methods": "indexes/methods.json", "properties": "indexes/properties.json", "keywords": "indexes/keywords.json" } ``` -------------------------------- ### Import ATAS Strategy DLLs in C# Source: https://github.com/jaggerxtrm/atas-docs/blob/master/Guide_work_atas.txt This snippet details the DLLs required and the 'using' statements necessary to import them for ATAS strategy development in a C# WPF project. Ensure you have Visual Studio 2022 installed and locate the ATAS folder for the DLLs. ```csharp using System.ComponentModel.DataAnnotations; using System.Resources; using System.Runtime.Intrinsics.X86; using System.Windows.Controls; using System.Windows.Media; using System.Drawing; using ATAS.Strategies; using ATAS.Indicators; using ATAS.Types; using ATAS.Indicators.Technical; using ATAS.Indicators.Other; using ATAS.DataFeedsCore; using ATAS.QuikStarter; using ATAS.Indicators.Technical.Properties; using Utils.Common; using Utils.Common.Logging; using Utils.Windows; using OFT.Core; using OFT.Platform; using OFT.Platform.Core; using OFT.Platform.DrawingObjects; ``` -------------------------------- ### Incorrect vs. Correct Data Types in C# Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md Highlights the necessity of using documented data types for variables. Using incorrect types can lead to data integrity issues and unexpected behavior. ```csharp // WRONG - Don't assume types private List values; // CORRECT - Use documented types private DataSeries values; ``` -------------------------------- ### C# Data Processing Pattern Source: https://github.com/jaggerxtrm/atas-docs/blob/master/ai_agent_prompt.md A common C# pattern for the `OnCalculate` method in ATAS indicators. It includes steps for validating input, retrieving data, performing calculations, and storing results. ```csharp protected override void OnCalculate(int bar, decimal value) { // 1. Validate input if (bar < RequiredBars) return; // 2. Get required data var dataPoints = GetDataPoints(bar); // 3. Perform calculations var result = CalculateIndicator(dataPoints); // 4. Store results ResultValues[bar] = result; } ``` -------------------------------- ### Create Basic Custom Indicator in C# Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Demonstrates how to create a simple custom indicator by extending the `IndicatorBase` class in C#. It includes initialization of data series and the core `OnCalculate` method for processing bar data. This snippet is useful for understanding the fundamental structure of custom indicators. ```csharp using ATAS.Indicators; public class MyCustomIndicator : Indicator { private int period = 10; public MyCustomIndicator() { // Add additional data series if needed DataSeries.Add(new ValueDataSeries("Values")); } protected override void OnCalculate(int bar, decimal value) { // Validate we have enough bars if (bar < period - 1) return; // Calculate maximum value for the last 10 bars var start = Math.Max(0, bar - period + 1); var count = Math.Min(bar + 1, period); var max = (decimal)SourceDataSeries[start]; for (var i = start + 1; i < start + count; i++) { max = Math.Max(max, (decimal)SourceDataSeries[i]); } // Store result for this bar this[bar] = max; } } ``` -------------------------------- ### C# Project Structure for ATAS Strategies Source: https://github.com/jaggerxtrm/atas-docs/blob/master/DeltaAnalysisStrategy_Development_Notes.txt Illustrates the recommended directory structure for organizing a C# project used for developing trading strategies within the ATAS platform. The structure includes directories for properties, custom indicators, utility classes, and strategy classes, promoting a modular and organized approach to project development. ```csharp ```csharp ProjectName/ ├── Properties/ │ └── AssemblyInfo.cs ├── Indicators/ # Custom indicators if needed ├── Utils/ # Helper classes └── Strategies/ # Strategy classes ``` ``` -------------------------------- ### C# Assembly Configuration for ATAS Strategy Source: https://github.com/jaggerxtrm/atas-docs/blob/master/DeltaAnalysisStrategy_Development_Notes.txt Defines the assembly configuration settings within the AssemblyInfo.cs file of a C# project. This includes setting the assembly title, description, company, product, copyright, version, and file version. These configurations provide important metadata for the strategy. ```csharp ```csharp [assembly: AssemblyTitle("Your Strategy Name")] [assembly: AssemblyDescription("Strategy Description")] [assembly: AssemblyCompany("Your Company")] [assembly: AssemblyProduct("Your Strategy Name")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] ``` ``` -------------------------------- ### C# Trading Strategy: Calculate Statistics and Generate Signals Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Calculates Bollinger Bands (mean, upper, lower) based on delta values. Implements trading signal logic for upper and lower band crosses, considering fade mode and pending orders. Handles order processing asynchronously. ```csharp mean = deltaValues.Average(); var sumSquares = deltaValues.Sum(d => (d - mean) * (d - mean)); stdDev = (decimal)Math.Sqrt((double)(sumSquares / deltaValues.Count)); meanLine[bar] = mean; upperBand[bar] = mean + (StdDevMultiplier * stdDev); lowerBand[bar] = mean - (StdDevMultiplier * stdDev); // Trading signal logic if (CanProcess(bar) && bar == CurrentBar - 1 && _pendingOrders.Count == 0) { // Upper band cross - bullish signal (or fade to short) if (lastDelta < upperBand[bar] && delta >= upperBand[bar]) { var direction = FadeMode ? OrderDirections.Sell : OrderDirections.Buy; _ = ProcessSignalAsync(direction); } // Lower band cross - bearish signal (or fade to long) else if (lastDelta > lowerBand[bar] && delta <= lowerBand[bar]) { var direction = FadeMode ? OrderDirections.Buy : OrderDirections.Sell; _ = ProcessSignalAsync(direction); } } lastDelta = delta; } } protected override void OnInitialize() { deltaSeries.Clear(); deltaValues.Clear(); lastCalculatedBar = -1; lastDate = DateTime.MinValue; mean = 0; stdDev = 0; lastDelta = 0; _pendingOrders.Clear(); base.OnInitialize(); } protected override void OnStopping() { if (CurrentPosition != 0 && ClosePositionOnStopping) { _ = ProcessClosePositionAsync(); } base.OnStopping(); } protected override void OnNewOrder(Order order) { base.OnNewOrder(order); if (order?.Id != null && !_pendingOrders.ContainsKey(order.Id)) _pendingOrders.Add(order.Id, order); } protected override void OnOrderChanged(Order order) { base.OnOrderChanged(order); if (order?.Id == null) return; switch (order.Status()) { case OrderStatus.Filled: _pendingOrders.Remove(order.Id); this.LogInfo($"Order {order.Id} filled: Direction={order.Direction}, Quantity={order.QuantityToFill}"); break; case OrderStatus.Canceled: _pendingOrders.Remove(order.Id); this.LogInfo($"Order {order.Id} canceled"); break; case OrderStatus.PartlyFilled: this.LogInfo($"Order {order.Id} partially filled: Unfilled={order.Unfilled}"); break; } } private async Task ProcessSignalAsync(OrderDirections direction) { try { var order = new Order { Portfolio = Portfolio, Security = Security, Direction = direction, Type = OrderTypes.Market, QuantityToFill = Volume }; await OpenOrderAsync(order); this.LogInfo($"Order placed: Direction={direction}, Volume={Volume}"); } catch (Exception ex) { this.LogInfo($"Failed to open position: {ex.Message}"); } } private async Task ProcessClosePositionAsync() { if (CurrentPosition == 0) return; try { var order = new Order { Portfolio = Portfolio, Security = Security, Direction = CurrentPosition > 0 ? OrderDirections.Sell : OrderDirections.Buy, Type = OrderTypes.Market, QuantityToFill = Math.Abs(CurrentPosition) }; await OpenOrderAsync(order); this.LogInfo($"Close position order placed: Volume={Math.Abs(CurrentPosition)}"); } catch (Exception ex) { this.LogInfo($"Failed to close position: {ex.Message}"); } } } } ``` -------------------------------- ### C# Required Method Overrides for ATAS Strategies Source: https://github.com/jaggerxtrm/atas-docs/blob/master/DeltaAnalysisStrategy_Development_Notes.txt This code snippet outlines the essential method overrides required when developing trading strategies within the ATAS platform. It includes the `OnCalculate`, `OnStarted`, and `OnStopping` methods, which are crucial for defining the strategy's core logic, initialization, and termination behaviors. ```csharp ```csharp protected override void OnCalculate(int bar, decimal value) protected override void OnStarted() protected override void OnStopping() ``` ``` -------------------------------- ### Delta Analysis Strategy in C# Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt This C# code implements a delta analysis trading strategy using the ATAS platform. It calculates delta values, visualizes them along with mean and standard deviation bands, and manages trading orders based on configurable parameters. It handles day changes by resetting calculations and allows for a 'fade mode' to take opposite positions. ```csharp using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; using System.Windows.Media; using ATAS.DataFeedsCore; using ATAS.Indicators; using ATAS.Strategies.Chart; using OFT.Attributes; using OFT.Localization; using Utils.Common.Logging; namespace TestStrategy { [DisplayName("Delta Analysis Strategy")] [Description("Analyzes delta movements relative to standard deviation bands")] public class DeltaAnalysisStrategy : ChartStrategy { private CandleDataSeries deltaSeries = new("DeltaSeries", Strings.Candles) { UseMinimizedModeIfEnabled = true, ResetAlertsOnNewBar = true }; private ValueDataSeries meanLine; private ValueDataSeries upperBand; private ValueDataSeries lowerBand; private List deltaValues = new(); private Dictionary _pendingOrders = new(); private decimal mean; private decimal stdDev; private int lastCalculatedBar = -1; private DateTime lastDate = DateTime.MinValue; private decimal lastDelta = 0; [DisplayName("Trade Volume")] [Description("Number of contracts to trade per position")] [Range(0.1, 1000)] [Parameter] public decimal Volume { get; set; } = 1; [DisplayName("Lookback Period")] [Description("Number of bars for mean and standard deviation calculation")] [Range(5, 200)] [Parameter] public int LookbackPeriod { get; set; } = 20; [DisplayName("StdDev Multiplier")] [Description("Multiplier for standard deviation bands")] [Range(0.1, 5.0)] [Parameter] public decimal StdDevMultiplier { get; set; } = 2.0m; [DisplayName("Reset Daily")] [Description("Reset calculations at start of each trading day")] [Parameter] public bool ResetDaily { get; set; } = true; [DisplayName("Fade Mode")] [Description("Takes opposite positions from standard signals")] [Parameter] public bool FadeMode { get; set; } = false; [Display(ResourceType = typeof(Strings), Name = "ClosePositionOnStopping", Description = "Automatically close position when strategy stops", Order = 40)] [Parameter] public bool ClosePositionOnStopping { get; set; } = true; public DeltaAnalysisStrategy() : base(true) { Panel = IndicatorDataProvider.NewPanel; DataSeries[0] = deltaSeries; meanLine = new ValueDataSeries("Mean") { Color = Colors.Yellow, Width = 1, VisualType = VisualMode.Line }; DataSeries.Add(meanLine); upperBand = new ValueDataSeries("Upper Band") { Color = Colors.Red, Width = 1, VisualType = VisualMode.Line }; DataSeries.Add(upperBand); lowerBand = new ValueDataSeries("Lower Band") { Color = Colors.Red, Width = 1, VisualType = VisualMode.Line }; DataSeries.Add(lowerBand); DataSeries.ForEach(x => x.IsHidden = false); } protected override void OnCalculate(int bar, decimal value) { if (bar == 0) { deltaSeries.Clear(); return; } var candle = GetCandle(bar); if (candle == null) return; // Check for day change if (ResetDaily && lastDate.Date != candle.Time.Date) { deltaValues.Clear(); mean = 0; stdDev = 0; lastDate = candle.Time.Date; } // Visualize delta as candle deltaSeries[bar].High = candle.MaxDelta; deltaSeries[bar].Low = candle.MinDelta; deltaSeries[bar].Open = 0; deltaSeries[bar].Close = candle.Delta; decimal delta = candle.Delta; // Update rolling window of delta values if (bar != lastCalculatedBar || bar == CurrentBar - 1) { if (bar != lastCalculatedBar) { deltaValues.Add(delta); if (deltaValues.Count > LookbackPeriod) deltaValues.RemoveAt(0); lastCalculatedBar = bar; } else if (deltaValues.Count > 0) { ``` -------------------------------- ### Bollinger Bands Indicator using RangeDataSeries (C#) Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Implements the Bollinger Bands technical analysis indicator. It uses SMA and StdDev for calculations and RangeDataSeries to visually represent the bands with a background fill. Dependencies include ATAS.Indicators and System.Windows.Media. ```csharp using ATAS.Indicators; using System.Windows.Media; public class BollingerBands : Indicator { private readonly RangeDataSeries _band = new RangeDataSeries("BackGround"); private readonly StdDev _dev = new StdDev(); private readonly SMA _sma = new SMA(); private decimal _width = 2.0m; [DisplayName("Period")] [Range(1, 999)] public int Period { get => _sma.Period; set { if (value <= 0) return; _sma.Period = _dev.Period = value; RecalculateValues(); } } [DisplayName("Width")] [Range(0.1, 5.0)] public decimal Width { get => _width; set { if (value <= 0) return; _width = value; RecalculateValues(); } } public BollingerBands() { ((ValueDataSeries)DataSeries[0]).Color = Colors.Green; DataSeries.Add(new ValueDataSeries("Upper Band") { Color = Colors.Red, VisualType = VisualMode.Line }); DataSeries.Add(new ValueDataSeries("Lower Band") { Color = Colors.Red, VisualType = VisualMode.Line }); DataSeries.Add(_band); Period = 20; Width = 2.0m; } protected override void OnCalculate(int bar, decimal value) { var sma = _sma.Calculate(bar, value); var dev = _dev.Calculate(bar, value); // Store middle line this[bar] = sma; // Store upper and lower bands DataSeries[1][bar] = sma + dev * Width; DataSeries[2][bar] = sma - dev * Width; // Fill range between bands _band[bar].Upper = sma + dev * Width; _band[bar].Lower = sma - dev * Width; } } ``` -------------------------------- ### C# Chart Manager for ATAS Platform Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Manages chart appearance including bar spacing, width, visual modes, and row height. It allows customization of chart elements through properties and updates the chart in real-time. The indicator does not require OnCalculate but handles cleanup in OnDispose. ```csharp using ATAS.Indicators; using System.ComponentModel.DataAnnotations; public class ChartManager : Indicator { private decimal _barsSpacing = 1; private decimal _barsWidth = 1; private ChartVisualModes _modes; private FootprintVisualModes _visualMode; private FootprintContentModes _contentMode; private int _moveChartUpAndDown; private decimal _changeRowsHeight = 3; [Range(1, 1000)] [DisplayName("Bars Spacing")] public decimal BarsSpacing { get => _barsSpacing; set { _barsSpacing = value; ChartInfo?.PriceChartContainer?.SetCustomBarsSpacing(_barsSpacing); RedrawChart(); } } [Range(1, 1000)] [DisplayName("Bars Width")] public decimal BarsWidth { get => _barsWidth; set { _barsWidth = value; ChartInfo?.PriceChartContainer?.SetCustomBarsWidth(_barsWidth, false); RedrawChart(); } } [DisplayName("Chart Mode")] public ChartVisualModes ChartMode { get => _modes; set { _modes = value; if (ChartInfo != null) ChartInfo.ChartVisualMode = value; RedrawChart(); } } [DisplayName("Footprint Content")] public FootprintContentModes FootprintContentMode { get => _contentMode; set { _contentMode = value; if (ChartInfo != null) ChartInfo.FootprintContentMode = value; } } [DisplayName("Move Chart Vertical")] public int MoveChartUpAndDown { get => _moveChartUpAndDown; set { var diff = _moveChartUpAndDown - value; ChartInfo?.CoordinatesManager?.MoveChartUpAndDown(diff); _moveChartUpAndDown = value; } } [Range(1, 100)] [DisplayName("Row Height")] public decimal ChangeRowsHeight { get => _changeRowsHeight; set { _changeRowsHeight = value; ChartInfo?.CoordinatesManager?.ChangeRowsHeight(value); } } protected override void OnCalculate(int bar, decimal value) { // Chart management doesn't require calculation } protected override void OnDispose() { // Reset to default chart settings ChartInfo?.PriceChartContainer?.SetCustomBarsSpacing(null); ChartInfo?.PriceChartContainer?.SetCustomBarsWidth( ChartInfo.PriceChartContainer.BarsWidth, false); } } ``` -------------------------------- ### Heiken Ashi Indicator for Custom Candle Rendering (C#) Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Implements the Heiken Ashi candlestick visualization. It customizes candle rendering by calculating new open, high, low, and close values based on previous candle data. This indicator uses CandleDataSeries and PaintbarsDataSeries. ```csharp using ATAS.Indicators; using System.Windows.Media; public class HeikenAshi : Indicator { private readonly CandleDataSeries _candles = new CandleDataSeries("Heiken Ashi"); private readonly PaintbarsDataSeries _bars = new PaintbarsDataSeries("Bars") { IsHidden = true }; public HeikenAshi() : base(true) { DenyToChangePanel = true; DataSeries[0] = _bars; DataSeries.Add(_candles); } protected override void OnCalculate(int bar, decimal value) { var candle = GetCandle(bar); _bars[bar] = Colors.Transparent; if (bar == 0) { _candles[bar] = new Candle() { Close = candle.Close, High = candle.High, Low = candle.Low, Open = candle.Open }; } else { var prevCandle = _candles[bar - 1]; var close = (candle.Open + candle.Close + candle.High + candle.Low) * 0.25m; var open = (prevCandle.Open + prevCandle.Close) * 0.5m; var high = Math.Max(Math.Max(close, open), candle.High); var low = Math.Min(Math.Min(close, open), candle.Low); _candles[bar] = new Candle() { Close = close, High = high, Low = low, Open = open }; } } } ``` -------------------------------- ### C# Bar Coloring with Volume Filter - ATAS Indicator Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt Implements a custom ATAS indicator to color bars based on their volume, ticks, delta, bid, or ask values falling within a specified range. It utilizes PaintbarsDataSeries for visual output and allows configuration of the volume type, minimum and maximum filter values, and the color to be applied. ```csharp using ATAS.Indicators; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Windows.Media; [DisplayName("Bar's volume filter")] public class BarVolumeFilter : Indicator { public enum VolumeType { Volume, Ticks, Delta, Bid, Ask } private readonly PaintbarsDataSeries _paintBars = new PaintbarsDataSeries("Paint bars"); private int _minFilter = 0; private int _maxFilter = 100; private Color _color = Colors.Orange; private VolumeType _volumeType; [Display(Name = "Type", Order = 5)] public VolumeType Type { get => _volumeType; set { _volumeType = value; RecalculateValues(); } } [Display(Name = "Minimum", Order = 10)] public int MinFilter { get => _minFilter; set { _minFilter = value; RecalculateValues(); } } [Display(Name = "Maximum", Order = 20)] public int MaxFilter { get => _maxFilter; set { _maxFilter = value; RecalculateValues(); } } [Display(Name = "Color", Order = 30)] public Color FilterColor { get => _color; set { _color = value; RecalculateValues(); } } public BarVolumeFilter() : base(true) { DataSeries[0] = _paintBars; _paintBars.IsHidden = true; DenyToChangePanel = true; } protected override void OnCalculate(int bar, decimal value) { var candle = GetCandle(bar); decimal volume = Type switch { VolumeType.Volume => candle.Volume, VolumeType.Ticks => candle.Ticks, VolumeType.Delta => candle.Delta, VolumeType.Bid => candle.Bid, VolumeType.Ask => candle.Ask, _ => throw new ArgumentOutOfRangeException() }; if (volume > _minFilter && volume <= _maxFilter) { _paintBars[bar] = _color; } else { _paintBars[bar] = null; } } } ``` -------------------------------- ### C# Cluster Search with Volume Filter - ATAS Indicator Source: https://context7.com/jaggerxtrm/atas-docs/llms.txt This C# code defines a custom ATAS indicator named 'ClusterSearch' that identifies and highlights price levels within bars where the volume exceeds a specified minimum filter. It iterates through each price level of a candle, checks its associated volume, and if it meets the filter criteria, visually marks it using PriceSelectionDataSeries. ```csharp using ATAS.Indicators; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; public class ClusterSearch : Indicator { private readonly PriceSelectionDataSeries _priceSelectionSeries = new PriceSelectionDataSeries("Clusters Selection"); private int _filter = 100; [DisplayName("Minimum Volume")] [Range(1, 100000)] public int Filter { get => _filter; set { _filter = value; RecalculateValues(); } } public ClusterSearch() { DataSeries.Add(_priceSelectionSeries); } protected override void OnCalculate(int bar, decimal value) { var candle = GetCandle(bar); // Iterate through all price levels in the bar for (decimal price = candle.High; price >= candle.Low; price -= TickSize) { var volumeInfo = candle.GetPriceVolumeInfo(price); if (volumeInfo == null) continue; // Highlight prices with volume exceeding filter if (volumeInfo.Volume > _filter) { var values = _priceSelectionSeries[bar]; var priceSelection = values.FirstOrDefault(t => t.MinimumPrice == volumeInfo.Price); if (priceSelection == null) { values.Add(new PriceSelectionValue(volumeInfo.Price) { VisualObject = ObjectType.Rectangle, Size = 10 }); } } } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.