Is it possible to rotate chart markers by code?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Rotating Chat Markers
Collapse
X
-
Rotating Chat Markers
Hello,
Is it possible to rotate chart markers by code?Tags: None
-
Hello Unsuitable,
Thank you for your reply.
I'm not sure which chart markers you're referring to - do you mean like drawing objects, or the arrows and text that show when a position is entered or exited? When you say rotate them, can you give a little more detail on how you'd want to manipulate them?
Thanks in advance; I look forward to assisting you further.
-
Talking about thisOriginally posted by NinjaTrader_Kate View PostHello Unsuitable,
Thank you for your reply.
I'm not sure which chart markers you're referring to - do you mean like drawing objects, or the arrows and text that show when a position is entered or exited? When you say rotate them, can you give a little more detail on how you'd want to manipulate them?
Thanks in advance; I look forward to assisting you further.
Comment
-
Hello Unsuitable,
Thank you for your reply.
You could certainly create a custom version of the ChartMarkers drawing tools with rotated versions. I'd take a look at that original script (under Drawing Tools in the NinjaScript Editor). Looks like this version pretty much draws the same thing whether it's an up or down triangle, so you could experiment around adding a ArrowLeft or ArrowRight. The lines that actually do the transforming to make it point up or down look to be around line 384 to 390, so you might not have to reinvent the wheel here to accomplish that.
Please let us know if we may be of further assistance to you.
Comment
-
Hello Kate,
Lines 384 to 390 refer to the arrow up, lines 499 to 502 are the triangle code. It's the same code though. I'm not familiar with SharpDX. Would it be possible to apply a new transform matrix onto an existing chart marker object or does it have to be applied while it's building the object?
Tried this
The .GetPoint is having trouble. It wants arguments ie ChartControl, Panel, ChartScale. Assuming what I'm doing works, how does one get those variables in this context?Code:triangleUpObject.RenderTarget.Transform = SharpDX.Matrix3x2.Rotation(NinjaTrader.NinjaScript.DrawingTools.DrawingTool.MathHelper.DegreesToRadians(90), SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Translation(triangleUpObject.Anchor.GetPoint.ToVector2());
Comment
-
Hello Unsuitable,
Thank you for your reply.
My mistake there. I've actually created a quick version of this with just left and right arrows - the other chart markers are stripped out. Basically, we use the same code to draw the triangles, and then just rotate that depending on the necessary direction:
You can find the version I've created below, which should help some with rotating any other chart marker objects to make your own versions.Code:// the geometry is created with 0,0 as point origin, and pointing UP by default. // so translate & rotate as needed SharpDX.Matrix3x2 transformMatrix; if (IsLeftTriangle) transformMatrix = SharpDX.Matrix3x2.Rotation(MathHelper.DegreesToRad ians(270), SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Translation(endVector); else transformMatrix = SharpDX.Matrix3x2.Rotation(MathHelper.DegreesToRad ians(90), SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Translation(endVector);
Please let us know if we may be of further assistance to you.Attached Files
Comment
-
May just do that as that's much more straightforward and require less code. For my custom text button indicator, there's a feature to add modifiers to the texts. So if the user wants to point to something specific then the user can add directional text characters.Originally posted by UltraNIX View PostAlso, another solution you may consider - using text and font with the symbols, where you can "draw" (type) any symbol that is in that font.
Comment
-
Thank you Kate for the reply.
Is it possible to apply a new transform matrix to an existing triangle chart marker? I would like to avoid copying the entire code into the indicator. From how it's codded. the transform matrix can be added up.
The chartControl, and chartScale were variables obtain from calling the OnRender method. How does one obtain in this context?Code:ChartPanel panel = chartControl.ChartPanels[chartScale.PanelIndex]; Point pixelPoint = trangleUpDrawObject.Anchor.GetPoint(chartControl, panel, chartScale); SharpDX.Vector2 endVector = pixelPoint.ToVector2(); transformMatrix = SharpDX.Matrix3x2.Rotation(MathHelper.DegreesToRadians(90), SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Translation(endVector); SharpDX.Matrix3x2 transformMatrix; trangleUpDrawObject.RenderTarget.Transform = transformMatrix
Comment
-
Hello Unsuitable,
Thank you for your reply.
I'm not sure I follow - you'd simply make a rotated version of the drawing tool like my example above that you could then use in whatever script you like, you wouldn't need to copy a bunch of code into an indicator each time you want to use it so you don't have to mess around rotating it in every script you want that way.
Please let us know if we may be of further assistance to you.
Comment
-
Hello Kate,
While creating another script and using it to draw the chart marker from whatever script I want is a solution, I want to avoid using helper scripts. Thus a possible solution would be to draw a chart marker triangle, get the object, then rotate it. I'm asking if that's possible?
This property RenderTarget.Transform property is accessible and can be set. Based on the script you provided, transform Matixs are added up together. In the script you provided (line 216), this is how to do it.Code:NinjaTrader.NinjaScript.DrawingTools.TriangleUp triangleUpObject = DrawObjects["TriangleUpID"]; triangleUpObject.RenderTarget.Transform = **Code to add rotation**;
Then it is set (line 222)Code:SharpDX.Matrix3x2 transformMatrix; transformMatrix = SharpDX.Matrix3x2.Rotation(MathHelper.DegreesToRadians(270), SharpDX.Vector2.Zero) * SharpDX.Matrix3x2.Translation(endVector);
Where I'm having trouble is with the endVector variable from line 216. The variable is based on lines 208-210. Where do we get "chartControl" and "chartScale" from within my indicator?Code:RenderTarget.Transform = transformMatrix;
Code:ChartPanel panel = chartControl.ChartPanels[chartScale.PanelIndex]; Point pixelPoint = Anchor.GetPoint(chartControl, panel, chartScale); SharpDX.Vector2 endVector = pixelPoint.ToVector2();
Comment
-
Hello Unsuitable,
Thank you for your reply.
No, that would not be possible.While creating another script and using it to draw the chart marker from whatever script I want is a solution, I want to avoid using helper scripts. Thus a possible solution would be to draw a chart marker triangle, get the object, then rotate it. I'm asking if that's possible?
I've run this by our team lead and he concurs with my assessment that you would have to clone or extend the Chart Markers drawing tool, like my above example or like this Chart Markers Plus drawing tool suite from our publicly available User App Share:
These are duplicate chart markers to what comes with the platform except you can change the size of them. The existing chart markers will remain as well. This will allow you to create custom sized chart markers that you can create and save as default so that you can draw the markers as needed to […]
Then you can add code to rotate and render in which ever direction you want, or for example add a public property that controls the direction of the drawing object in question.
Please let us know if we may be of further assistance to you.
Comment
-
Hello Kate,
Gotcha, thank you for the confirmation.
Since only the draw method is needed, I will try to strip down the code as much as possible. Is that a good idea?
Comment
-
Hello Kate,
The goal is to strip it down so it's only the right triangle with only the ability to draw it from code. Overall I'm attempting to improve the Order Transfer indicator. This indicator, for example, takes trades from the MES and then places the execution markers on the ES. Of course, these markets are not 1:1, but it's better than manually drawing the entry/exit orders every time.
Thanks for all the help!
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment