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!
See more
See less

Partner 728x90

Collapse

Coding Help Needed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #76
    I will keep you posted 😁

    Comment


      #77
      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


        #78
        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


          #79
          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


            #80
            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
            Mukaddim
            Last edited by Mukaddim; 10-04-2018, 05:28 AM.

            Comment


              #81
              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 ?)
              This is replaced with the FromIndex and ToIndex correct. Here is an example loop over that set of data:



              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)
              This is still BarMarginRight but is under the Properties now



              chartControl.BarSpace
              I believe this would be the BarDistance
              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


                #82
                Hi Jesse!
                Thank you very much for the detailed and quick response. I'm not sure how to describe in more detail, may be sending you some screenshots will help?

                Thanking
                Mukaddim

                Comment


                  #83
                  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?
                  Is the intended goal to have the condition only draw on some bars and the current outcome is that it draws on every bar?



                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #84
                    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
                    Mukaddim
                    Last edited by Mukaddim; 10-05-2018, 05:19 AM.

                    Comment


                      #85
                      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
                      then demonstrates the syntax for that.


                      I look forward to being of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #86
                        Thank you so very much Jesse!

                        In regard to the text measuring issue, I've found out the same samplerenderexample, but now that you've noted where to look, it gets better for me .

                        In regard to seeing the logic, can I email it to you, please?

                        Thanking
                        Mukaddim

                        Comment


                          #87
                          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


                            #88
                            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


                              #89
                              Hello

                              In this case, it would be the second usage or:

                              Code:
                              (State [B]![/B]= State.Historical)
                              The State object is both a Property and an Enum in a script so you can compare it using standard comparitive operators like not equal !=

                              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


                                #90
                                Hello Jesse!
                                Thank you for your response.
                                Please let me know the email ID I have to send the code to.

                                Thanking
                                Mukaddim

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by algospoke, Yesterday, 06:40 PM
                                2 responses
                                19 views
                                0 likes
                                Last Post algospoke  
                                Started by ghoul, Today, 06:02 PM
                                3 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                3 responses
                                45 views
                                0 likes
                                Last Post jeronymite  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                7 responses
                                21 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                10 responses
                                181 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X