Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Regarding DrawObject in Ninjatrader 8.
Collapse
X
-
Regarding DrawObject in Ninjatrader 8.
I am interested in creating an indicator that when I manually draw a rectangle, I know the exact position of it in terms of bars ago. The reason is so that i can return the bar closes than fall within the rectangle. I am able to detect the rectangle, but I am not able to figure out what properties to access, in order to calculate the position of he rectangle in relationship to the BarsArray. I was able to do it in Ninjatrader 7, but the properties seem to have changed. -
Hello,
Thank you for the post.
I am not sure I fully understand the question. If you have the BarsAgo already what value are you trying to get instead that you were able to get in NT7? It may be helpful if you could post the specific syntax you were using in NT7 that you are trying to recreate.
You said you cannot calculate the position of the rectangle in relation to the BarsArray, the Position would be related by the BarsAgo being used by the tool. Are you instead referring to getting the objects X and Y values?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Thank you for your reply:
I dont know the BarsAgo, Thats exactly what I am trying to accomplish. It was a typo in my first question.
Imagine that I see a price pattern in the chart that interests me. I want to be able to draw a rectangle aground it, and the indicator will return the closing price of the bars enclosed by the rectangle.
Right now this is what i can do:
I can draw the rectangle, the indicator that I have right now, finds the rectangle and makes it available to me to access its properties and methods. However, I can not find any property or methods in the rectangle object, that will return the current position of the rectangle in the chart, nor its location with respect to the Bars Array. I am looking for an example that does the following:
Returns the x and y coordinates of the four corners of the rectangle( can be the BarsAgo vs price, DateTime vs price, or X vs Y coordinates( as long as I can convert X and Y coordinates to Barsago vs Price)).
Finds which bars are located within these x,y coordinates.
Returns the closing prices of the bars within those coordinates.
Attached you will see pictures of the objects properties for ninjatrader 7 and ninjatrader 8, noticed that the properties startbarsago and endbarsago are no longer available for ninjatrader 8.
Thank you very muchLast edited by Yandychang; 07-07-2017, 09:52 AM.
Comment
-
Hello,
Thank you for the reply and clairifing.
To gather the BarsAgo and Price, you would need to use the objects Anchors.
Rather than just having a set of default properties, each object can have its own unique properties along with multiple anchors.
I would suggest using the following page and its examples to Get objects:
Also if you plan to export this as a compiled assembly, there would be a different approach to finding objects and their properties here: http://ninjatrader.com/support/helpG...assemblies.htm
Code:protected override void OnBarUpdate() { foreach (DrawingTool draw in DrawObjects) { // Finds line objects that are attached globally to all charts of the same instrument if (draw is DrawingTools.Rectangle) { DrawingTools.Rectangle rec = draw as DrawingTools.Rectangle; foreach (var globalLineAnchor in rec.Anchors) { int barsAgo = globalLineAnchor.BarsAgo; } // or int startAnchor = rec.StartAnchor.BarsAgo; double startAnchorPrice = rec.StartAnchor.Price; int endAnchor = rec.EndAnchor.BarsAgo; double endAnchorPrice = rec.EndAnchor.Price; } } }
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Thank you for your response:
I tried that in the past. The problem that I find is that the property BarsAgo is not available for objects created manually, which is the object that I draw on the chart. what other ways are there to achieve this?
Comment
-
Hello,
In the case of manually drawing the rectangle, you could use the Slot index rather than the BarsAgo, and ChartControl to get a Time from that. Using the time you could get a Bar index and then use math or the Get methods to get specific values.
Code:double startAnchorSlotIndex = rec.StartAnchor.SlotIndex; DateTime startAnchorTime = ChartControl.GetTimeBySlotIndex(startAnchorSlotIndex); int startAnchorBarIndex = ChartBars.GetBarIdxByTime(ChartControl, startAnchorTime);
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
23 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
22 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment