Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Plugins;

public readonly record struct TradeEventArgs(int Volume, TradeType TradeType);
public readonly record struct TradeEventArgs(int Volume, TradeType TradeType, string SymbolName);

public class TradeControl : CustomControl
{
Expand Down Expand Up @@ -58,17 +59,22 @@ public TradeControl()
AddChild(_panel);
}

public Symbol Symbol { get; set; }

public event EventHandler<TradeEventArgs> Trade;

private void ExecuteButtonOnClick(ButtonClickEventArgs obj)
{
if (Symbol is null)
return;

if (!int.TryParse(_volumeTextBox.Text, out var volume))
return;

if (!Enum.TryParse(_tradeTypeComboBox.SelectedItem, out TradeType tradeType))
return;

Trade?.Invoke(this, new TradeEventArgs(volume, tradeType));
Trade?.Invoke(this, new TradeEventArgs(volume, tradeType, Symbol.Name));
}

private TextBlock GetTextBlock(string text = null) => new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TradeWatchTabSample : Plugin
private TradeControl _tradeControl;

protected override void OnStart()
{
{
var tab = TradeWatch.AddTab("Active Chart Symbol Stats");

var panel = new StackPanel
Expand All @@ -42,17 +42,15 @@ protected override void OnStart()

private void TradeControlOnTrade(object sender, TradeEventArgs e)
{
if (ChartManager.ActiveFrame is not ChartFrame chartFrame)
return;

ExecuteMarketOrder(e.TradeType, chartFrame.Symbol.Name, e.Volume);
ExecuteMarketOrder(e.TradeType, e.SymbolName, e.Volume);
}

private void SetSymbolStats()
{
if (ChartManager.ActiveFrame is not ChartFrame chartFrame)
return;

_tradeControl.Symbol = chartFrame.Symbol;
_symbolStatsControl.Symbol = chartFrame.Symbol;
}
}
Expand Down