// Add a text block for the mode message
_modeTextBlock = new TextBlock
{
Text = string.Empty,
ForegroundColor = Color.Green,
FontSize = TextSize,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
_grid.AddChild(_modeTextBlock, 1, 0);
// Attach the grid to the chart
Chart.AddControl(_grid);
}
private void Chart_KeyDown(ChartKeyboardEventArgs obj)
{
// Activate alert point setting mode when the "A" key is pressed
_isSettingAlertPoint = true;
_modeTextBlock.Text = "Click on the chart to set the alert point";
}
private void Chart_MouseDown(ChartMouseEventArgs obj)
{
// If in alert point setting mode, set the alert point to the mouse click price
if (_isSettingAlertPoint)
{
double clickedPrice = Chart.YToYValue(obj.MouseY);
Chart.RemoveObject("alertLine");
Chart.RemoveObject("alertLabel");
AlertPoint = clickedPrice;
DrawAlertLineWithLabel(AlertPoint);
_isSettingAlertPoint = false;
_modeTextBlock.Text = string.Empty;
}
}
private void DrawAlertLineWithLabel(double price)
{
// Draw the horizontal line at the alert point
Chart.DrawHorizontalLine("alertLine", price, Color.Red, 2, LineStyle.Solid);
// Draw the text label with the price
Chart.DrawText(
name: "alertLabel",
text: price.ToString("F4"),
barIndex: Bars.Count - 1, // Using the last bar index
y: price, // Y-axis value for the price
color: Color.FromName(TextColor)
);
}
}
}
از این مرجع فوق تخصصی بپرسید
وایپر گفت fl/oz روی اون شیشه یعنی چی
بعد بپرس عطر با ادکلن چه فرقی دارد
یه سوال دیگه بپرس بگو
Eue the perfume
Eue the colne
با هم چه فرقی دارن
بعد بزن زیر گوشش اگه بلد نبود
:)
خودش میفهمه چرا خورده
using cAlgo.API;
using cAlgo.API.Internals;
using System;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class CurrentPriceDisplay : Indicator
{
private TextBlock _priceTextBlock;
[Parameter("Horizontal Margin (Pixels)", DefaultValue = -632, MinValue =-1000)]
public int HorizontalMargin { get; set; }
[Parameter("Vertical Margin (Pixels)", DefaultValue = 0, MinValue = -1000)]
public int VerticalMargin { get; set; }
protected override void Initialize()
{
var stackPanel = new StackPanel
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(HorizontalMargin, VerticalMargin, 0, 0),
BackgroundColor = Color.Black,
Opacity = 0.6
};
var style = new Style();
style.Set(ControlProperty.Padding, 1);
style.Set(ControlProperty.BackgroundColor, Color.Transparent);
style.Set(ControlProperty.ForegroundColor, Color.Yellow);
style.Set(ControlProperty.FontSize, 20);
_priceTextBlock = new TextBlock
{
Text = "Prices: ",
Style = style
};
stackPanel.AddChild(_priceTextBlock);
Chart.AddControl(stackPanel);
Timer.Start(TimeSpan.FromSeconds(1));
}
protected override void OnTimer()
{
double bid = Symbol.Bid;
double ask = Symbol.Ask;
double spread = Math.Max(bid, ask) - Math.Min(bid, ask);
_priceTextBlock.Text = $"Bid: {bid:F5} | Ask: {ask:F5} | Spread: {spread:F5}";
}
public override void Calculate(int index)
{
// This example does not need to perform any calculations on every tick/bar
}
}
}