- Accounts & Connection Management
- Data Management & Analysis
- Price Monitoring
- Charting
- Trading
- Scanners
-
Builders
-
Manual Strategy Builder
- Main Concept
- Operand Component
- Algo Elements
-
Use Cases
- How to create a condition on something crossing something
- How to create an indicator based on another indicator
- How to calculate a stop loss based on indicator
- How to submit stop order based on calculated price
- How to calculate a current bar price using a price type from inputs
- How to Use a Closed Bar Price
- Automatic Strategy Builder
-
Manual Strategy Builder
- Autotrading
- FinScript
- Trade Analysis
- Media Feeds
- Logs & Notifications
- UI & UX
OnRender - gives a user and access to chart canvas and allows to draw anything user wants. It is an advanced tools which requires understanding such objects like ChartControl, ChartViewPort and ChartPanel. The following snippet of code shows how to draw price channel
protected override void OnRender(IChartControlCanvas chartControlCanvas)
{
double GetY(double price) { return ChartViewport.GetValueOrThrow().GetYByValue(price); }
//Actually it is possible only some inheritor will call the method explicitly
if (ChartControl == null || ChartViewport == null || ChartPanel == null || _atr == null)
return;
var firstIndexToDraw = Input.Count - 10;
if (ChartViewport.ToIndex < firstIndexToDraw)
return;
var textColor = Colors.LightGray;
var levelsColor = Colors.DarkGoldenrod;
var priceColor = Colors.Aqua;
var x1 = ChartPanel.Width;
var x2 = ChartControl.GetValueOrThrow().GetXByBarIndex(Input, firstIndexToDraw);
var priceMiddle = this.Input.GetLastValue().Close;
var yMiddle = GetY(priceMiddle);
// Middle
chartControlCanvas.DrawLine(new Point(x1, yMiddle), new Point(x2, yMiddle), new Stroke(priceColor, 2));
chartControlCanvas.DrawText($"Current price: " +
$"{Instrument?.Definition.FormatPrice(priceMiddle, ApplicationSettings.FormatCulture)}",
new Point(x1, yMiddle), textColor, HorizontalOrigin.Right,VerticalOrigin.Bottom);
var distance = _atr.GetLastValue() * Multiplier;
// Top
var priceTop = priceMiddle + distance;
var yTop = GetY(priceTop);
chartControlCanvas.DrawLine(new Point(x1, yTop), new Point(x2, yTop), new Stroke(levelsColor, 2));
chartControlCanvas.DrawText($"Channel's top: " +
$"{Instrument?.Definition.FormatPrice(priceTop, ApplicationSettings.FormatCulture)}",
new Point(x1, yTop), textColor, HorizontalOrigin.Right,
VerticalOrigin.Bottom);
// Bottom
var priceBottom = priceMiddle - distance;
var yBottom = GetY(priceBottom);
chartControlCanvas.DrawLine(new Point(x1, yBottom), new Point(x2, yBottom), new Stroke(levelsColor, 2));
chartControlCanvas.DrawText($"Channel's bottom: " +
$"{Instrument?.Definition.FormatPrice(priceBottom, ApplicationSettings.FormatCulture)}",
new Point(x1, yBottom), textColor, HorizontalOrigin.Right,
VerticalOrigin.Bottom);
}
- Accounts & Connection Management
- Data Management & Analysis
- Price Monitoring
- Charting
- Trading
- Scanners
-
Builders
-
Manual Strategy Builder
- Main Concept
- Operand Component
- Algo Elements
-
Use Cases
- How to create a condition on something crossing something
- How to create an indicator based on another indicator
- How to calculate a stop loss based on indicator
- How to submit stop order based on calculated price
- How to calculate a current bar price using a price type from inputs
- How to Use a Closed Bar Price
- Automatic Strategy Builder
-
Manual Strategy Builder
- Autotrading
- FinScript
- Trade Analysis
- Media Feeds
- Logs & Notifications
- UI & UX