Drawing tool for swing highs and swing lows

Be Much simpler to just render U as a Text,
and rotate 180 degrees when it’s Swing High.
Use FontSize in TextFormat to control Size.

Sample script below can be placed in any OnRender.
Renders Text U w/Arial 36p font and rotated 180d.

You’ll Adjust your startX/startY accordingly,
as well as any Rotation Placement Adjustment.

using(SharpDX.DirectWrite.TextFormat textFormat = new SharpDX.DirectWrite.TextFormat(Core.Globals.DirectWriteFactory, "Arial", 36))
using(SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, "U", textFormat, textFormat.FontSize, textFormat.FontSize))
{
	//Render Normal Text U
	float startX = (ChartPanel.W - ChartPanel.X) / 2f; 
	float startY = (ChartPanel.H - ChartPanel.Y) / 2f;
	SharpDX.Vector2 startVec = new SharpDX.Vector2(startX, startY);
	SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.LimeGreen);
	RenderTarget.DrawTextLayout(startVec, textLayout, customDXBrush);
	
	//Render and Rotate U 180 Degrees 
	SharpDX.Matrix3x2 sm = RenderTarget.Transform; //Save Current Transform
	//SharpDX.Vector2 startVecR = new SharpDX.Vector2(startX + textLayout.Metrics.Width, startY + textLayout.Metrics.Height); //Adjust Rotation Point
	SharpDX.Vector2 startVecR = new SharpDX.Vector2(startX + textLayout.Metrics.Width, startY); //Adjust Rotation Point
	RenderTarget.Transform	= SharpDX.Matrix3x2.Rotation(NinjaTrader.NinjaScript.DrawingTools.DrawingTool.MathHelper.DegreesToRadians(180), startPointR); //Rotate 180 degrees
	customDXBrush.Color = SharpDX.Color.Red;
	RenderTarget.DrawTextLayout(startVecR, textLayout, customDXBrush);
	RenderTarget.Transform	= sm; //Set Back to Saved Transform

	customDXBrush.Dispose();
	textLayout.Dispose();
	textFormat.Dispose();
}

After tinkering, it’s growing on me.
I tend to always have too many lines.
This might be slightly cleaner look.

Might add option to my Swings Drawing Tool. (Line/U one/both/none)

Be Safe in this Crazy World!
:smiling_face_with_sunglasses:

2 Likes