Drawing tool for swing highs and swing lows

I want to create two manual drawing tools: one that draws a 1-bar wide green arc (∩ shape) above a candle to mark swing highs, and one that draws a 1-bar wide red arc (∪ shape) below a candle for swing lows. These should be manually placed on click, with fixed arc size. Could you help me with the correct code to draw a simple bezier arc or semi-circle using SharpDX?

This will have more added value than the swing indicator strength1 which signals the turning points automatically?

Hi Dirk. Much appreciated. Sure I can try that. I just wanted to mark my swing highs and lows and if you feel would work better that’s great.
This is my first time posting so maybe let me know how to download and implement the code if you don’t mind. Thanks again!!

NT has a number of builtin chart markers that you can use for this purpose without having to go through the hassle of building your own. There are up/down arrows, up/down triangles, etc.

These reside under Drawing Tools > Chart Markers and they all have keyboard shortcuts so you can quickly place one on your chart.

I’m not trying to discourage you from building your own custom drawing tools if that’s your intention. Just saying there’s a free existing alternative that can be used if all you want to do is manually mark turning points on your chart.

Hi Dirk. Not sure if you had a code for this type of request I was looking for?
Thank you.

Hi. Thanks for your reply. I do know there are those icons but I use this for other parameters. I know there is an arc tool but not what I am looking for. I did attempt to use ChatGPT and did provide a code but wouldn’t work on ninja and had a bunch of errors.
Thank you

The Swing is a built-in indicator in NT. Add it to your charts with a strength of 1 for example and you’ll see the swing highs and lows. Standard it’s a bullet sign but I assume you can change that.
If you really want an arc on that, indeed, it should be possible to ask this to GPT. The errors the code give can be solved too, normally.

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