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
Coding Help Needed
Collapse
X
-
Hello Jesse!
I have been able to pinpoint the object. But it's not set to null, so no clue why it is happening. Commenting out that code block allows me to get the indicator visible on indicator list and does it things "primarily". Will keep working on it, and see if I can reproduce it.
Meanwhile, what should be used while converting ChartControl.Controls.Find() to NT8?
Thanking
Mukaddim
Comment
-
Hello Mukaddim,
Thank you for the reply.
Glad to know you were able to pinpoint the object, what is the offending syntax and what state was it found in?
For finding controls it is suggested to use automation ID's. I have a post that shows how to locate these ids here: https://ninjatrader.com/support/foru...44&postcount=7
Using the Inspect tool from Microsoft will allow you to pull ID's from any control that may have one. Please note that not all controls have these ids, it is more or less the major controls in each window.
Once you have an id and know what object is the parent of that control, you can use the FindFirst method to locate the control. This is shown in the link above to find the ChartTraderControl. The parent of the chart control is used ChartControl.Parent which the FindFirst can then traverse to find the id.
For items that do not have an id, we would suggest submitting a feature request to see if one can be added because the alternative is traversing the visual tree of controls which can become messy. You can search online for WPF/C# ways to do this a sample search is "wpf find control visual tree".
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello Jesse!
Thanks very very much. It was a TimeSpan object in the State.Defaults. Though I'm not sure why it says null, since it's initialized propertly, I'm still trying to figure it out. But blocking out that code block cosisting TimeSpan object solves the issue in discussion for now. I'll update you on this more, once I get to the bottom of it.
Regarding the ChartControl.Find, I'll go through the link you've provided to figure it out.
Thanking
Mukaddim.
Comment
-
Hi Jesse,
One of the indicators that I converted is plotting slightly differently. It plots the mark on every high/low according to set strength, while it is supposed to do it once price makes new high/low according to strength, not just every high/low. If you'd like I can send you a copy of it via email. Also please let me know the equivalence of the followings:
1. chartControl.LastBarPainted (Replaced by ChartBars.ToIndex ?)
2. chartControl.Width (Replaced by chartControl.BarWidth ?))
3. chartControl.BarMarginRight (Found BarMarginLeft, but not the one intended)
4. chartControl.BarSpace
Please let me know of next step.
Thanking
MukaddimLast edited by Mukaddim; 10-04-2018, 05:28 AM.
Comment
-
Hello Mukaddim,
Thank you for the reply.
I am not sure what you are asking with the first item, are you saying that it should plot based on the condition but you are instead seeing it on every bar? I wouldnt nessasrily want the script at this point as I am uncertain what the problem is. Very likely the solution is going to involve reducing the logic or adding Prints to locate the specifics surrounding the problem.
For the items you are asking about, the chart is actually all documented now and it has been split into multiple parts. You can find the specific documentation in the following sections.
The Chart page has links and visuals about the split parts of the chart.
chartControl.LastBarPainted (Replaced by ChartBars.ToIndex ?)
For the chartControl.Width, are you trying to get the width of the ChartControl or the width of each individual Bar?
For the charts width, you can use the ChartPanel object and its W, H, X, Y properties to get its dimentions:
chartControl.BarMarginRight (Found BarMarginLeft, but not the one intended)
chartControl.BarSpace
A float measuring the distance (in pixels) between the left or right edge of one bar and the corresponding edge of the previous or subsequent bar
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello Mukaddim,
Possibly, but if I do not know what your expectation is that may not be helpful. If you are unable to explain what you are intending to happen that is likely a better place to start.
Let's start with what specifically is going wrong versus what you expect:
are you saying that it should plot based on the condition but you are instead seeing it on every bar?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello Jesse!
Thank you. Yes you are mostly correct. Let's take an example from the NT swing indicator. Suppose the strength is set to 1. so the mark should be beneath the low of a bar once the next bar closes higher. Exact opposite to the mark above high. So, if the next candle does not make a higher low, the mark shouldn't be under the previous bar's low.
Now what it does is, it plots the mark on the low, then if the next bar closes lower it moves the mark to the new low. Opposite for high marking. It doesn't always happen, and. pressing F5 makes the mark disappear.
Please let me know if it's clear enough!
In regard to another conversion of Plot method, which is now OnRender, I ran into an issue. The following NT7 code is where I"m stuck at.
SizeF ef = graphics.MeasureString(text, font);
Now SizeF is somewhat similar to Size2F() that has two overloads, if I'm not wrong. But can't find anything on graphics.MeasureString conversion equivalence. To my knowledge, RenderTarget can achieve similar result to graphics, isn't it? Any suggestions to graphics.MeasureString() conversion?
Thanking
MukaddimLast edited by Mukaddim; 10-05-2018, 05:19 AM.
Comment
-
Hello Mukaddim,
Thank you for clarifying.
Based on the reply it sounds like you have a few problems to solve.
First is the plotting on each bar which also sounds like It doesn't always happen, this may be related to the overall condition and input you are using to control that. The example you noted with the swing indicator and its strength would be one area to check if you are doing something similar. Prints could assist with this or checking the values being seen by the condition on each bar.
You also noted pressing F5 clears the drawing which leads me to the question, where is the logic that calculates happening?
We have been discussing OnRender, is the logic to find the low and high in OnBarUpdate or somewhere else? If pressing F5 essentially resets the indicator that indicates to me that the logic to calculate the values needs to be moved to where it can run historically. This is only a high-level observation, now that we have more details on the problem seeing the logic would be more relevant.
Regarding SizeF and the measuring of text, SizeF is just a structure to hold data which was relevant toward the Graphics in NT7. In NT8 you can review the SampleCustomRender for an example that includes measuring text. Take a look at the notes starting on line 271:
// the textLayout object provides a way to measure the described font through a "Metrics" object
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello Mukaddim,
Thank you for the reply.
Yes if you have a small sample of the logic in question feel free to post it here or email it in. If you have an entire script that contains other than what you are asking about I would recommend trying to further isolate the problem first. I would always suggest reducing the script to only demonstrate the problem if you are going to share code so we can just address that. This also help in locating the issue which in turn may provide direction for a solution.
Very likely you will need to use Prints to find what specifically is happening in the logic in the test you are doing. I could try to highlight areas in what you provide for you to further debug.
I look forward to being of furtrher assistance.JesseNinjaTrader Customer Service
Comment
-
Hi Jesse,
I'm yet to narrow down the code block that could be sent for your examination. So, it might take a while. Would you please let me know what would it be for the following?
!Historical is equivalent to
!(State == State.Historical) or
(State != State.Historical)?
Thanking
Mukaddim
Comment
-
Hello
In this case, it would be the second usage or:
Code:(State [B]![/B]= State.Historical)
There are also a few general samples on the following page and its sub pages: https://ninjatrader.com/support/help...tatechange.htm
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by TraderBCL, Today, 02:37 AM
|
0 responses
1 view
0 likes
|
Last Post
by TraderBCL
Today, 02:37 AM
|
||
Started by mangel2000, Today, 02:23 AM
|
0 responses
5 views
0 likes
|
Last Post
by mangel2000
Today, 02:23 AM
|
||
Started by mangel2000, Today, 01:30 AM
|
0 responses
13 views
0 likes
|
Last Post
by mangel2000
Today, 01:30 AM
|
||
Started by Doxxxx, Today, 01:24 AM
|
0 responses
5 views
0 likes
|
Last Post
by Doxxxx
Today, 01:24 AM
|
||
Started by ezekilany, Today, 01:10 AM
|
0 responses
4 views
0 likes
|
Last Post
by ezekilany
Today, 01:10 AM
|
Comment