Use a Controller object to add the generator to a chart:
const tradeVisualizationGenerator = controller.addGenerator('TradeVisualization');
type BaseTransaction = {
ts: number;
units: number;
quote: number;
currency: string;
};
type BuyTransaction = BaseTransaction & {
direction: 'buy';
};
type SellTransaction = BaseTransaction & {
direction: 'sell';
profitLoss: number;
};
type Transaction = BuyTransaction | SellTransaction;
type Trade = {
id: number;
visualizeQuotes: boolean;
transactions: Transaction[];
};
The generator exposes the following public method.
Type
interface TradeVisualizationGenerator {
addTrade(trade: Trade): boolean;
}
Details
addTrade takes a Trade object and adds it to the chart. Each transaction in the trade will be rendered at its corresponding timestamp position on the chart. The method returns true if the trade was successfully added, or false if chart data or input is not available.
When visualizeQuotes is set to true, vertical markers will be drawn at the quote price for each transaction.
The trade visualization includes: