-
-
Save Zz9uk3/4c3f62f8363c120e137a3ba0a178e395 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CreateOhlcPlot(ChartControl chartControl, ChartScale chartScale, int barIndex) | |
{ | |
float x = chartControl.GetXByBarIndex(ChartBars, barIndex); | |
float barPixelWidth = (float)chartControl.BarWidth; | |
float openX = x - barPixelWidth * 1.5f; | |
float closeX = x + barPixelWidth * 1.5f; | |
var open = O.GetValueAt(barIndex); | |
var high = High.GetValueAt(barIndex); | |
var low = Low.GetValueAt(barIndex); | |
var close = C.GetValueAt(barIndex); | |
var yHigh = chartScale.GetYByValue(high); | |
var yLow = chartScale.GetYByValue(low); | |
var yOpen = chartScale.GetYByValue(open); | |
var yClose = chartScale.GetYByValue(close); | |
var cl = Brushes.Pink; | |
var color = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, new SharpDX.Color(cl.Color.R, cl.Color.G, cl.Color.B)); | |
var highVector = new Vector2(x, yHigh); | |
var lowVector = new Vector2(x, yLow); | |
RenderTarget.DrawLine(lowVector, highVector, color, barPixelWidth); | |
var openStart = new Vector2(openX, yOpen); | |
var openEnd = new Vector2(x, yOpen); | |
RenderTarget.DrawLine(openStart, openEnd, color, barPixelWidth); | |
var closeStart = new Vector2(closeX, yClose); | |
var closeEnd = new Vector2(x, yClose); | |
RenderTarget.DrawLine(closeStart, closeEnd, color, (float)ChartControl.BarWidth); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment