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

    #31
    Hello Jesse,
    Thanks for your response. SampleCustomRender.cs is what I'm venturing into. On a different note, OnStartUp() in NT7 now is OnStateChange() in NT8 if I am not wrong. Would you please consider the following codes in NT7 and advise me on the correct conversion to NT8 codes?

    //Variable initialization
    private Color barColorUp = Color.Lime;
    private SolidBrush brushUp = null;

    protected override void OnStartUp()
    {
    if (ChartControl == null || Bars == null){
    return;
    }

    brushUp = new SolidBrush(barColorUp);

    }

    Now this goes into OnStateChange (State == State.Default), as I have learnt so far. Color type variable changes to Brush type I assume, but what about conversion of the piece of code within OnStartUp(), specially the conversion between Color and SolidBrush??

    Awaiting your reply.
    Thanking
    Mukaddim
    Last edited by Mukaddim; 08-30-2018, 12:50 AM.

    Comment


      #32
      Hello Mukaddim,

      Thank you for the reply.

      In this case, I would suggest looking over the code breaking changes guide for any Color properties or methods you currently use to see how they have changed. The help guide contians samples for most items so you can compare the difference there.

      The conversion of SolidBrush and Color would depend on what your goal with the SolidBrush was, I can't tell from the sample provided what the use of SolidBrush was for. I would likely suggest to just use a Brush if possible, otherwise, you may need to use a SolidColorBrush. The help guide has a section about using Brushes here:


      Depending on what you needed SolidBrush for, you will either use a Brush or SolidColorBrush/ gradient type brush for that purpose.

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

      Comment


        #33
        Thank you Jesse,
        I am familiar with the Brush object and its functionality. But I don't actually know how to convert the Color to SolidBrush in NT 8. That's where I am stuck. The indicator is a modified HA indicator, SolidBrush is used to paint the bars with a solid color.

        Mukaddim

        Comment


          #34
          Hello Mukaddim,

          As noted the sample you provided is not enough information for me to know what you were trying to do. There is no context as to why you are using SolidBrush instead of just using a Color. As SolidBrush and Color are not present in NT8, this information is needed to know what you would need to use in NT8.

          You can use the working with Brushes page in the help guide to see how to create all the types of NT8 brushes that can be used. To convert what you had done in NT7 you would need to know what the syntax you used in NT7 does. With that in mind, you can review the Brushes that can be used in NT8 and see which fits the use case.

          As one example, if you used a SolidBrush because you needed to make a custom color, please see the working with brushes help guide page as there are considerations around creating custom brushes in NT8.

          Another example that is specific to NT8 and OnRender would be a DX brush which is used for rendering specifically, this is also explained in the working with brushes guide.

          If you can provide a more clear sample that shows what you are doing surrounding the SolidBrush creation and use, that may provide more detail on what type you need to use.


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

          Comment


            #35
            Hi Jesse,
            Thanks, I will send you the file in an email, so you could see for yourself, DX brushes were used in OnRender method(), instead of Plot() in NT7.
            Thanking
            Mukaddim

            Comment


              #36
              Hello Mukaddim,

              I wouldnt need the whole file in this case, just more context on where you used that one variable specifically. But you noted you are using this in the Plot override which means the NT8 equivalent would be a DX brush for OnRender. I would suggest reviewing how the brushes are used and created in the SampleCustomRender as that would be the suggested approach.

              The sample shows how to define an Input which is a Brush and also how that is converted into a DXBrush.

              Please let me know if I may be of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #37
                Hello Jesse,
                Thanks again. SolidBrush variable has been used in the Plot() method, as a parameter passed to graphics.FillRectangle(). In OnStartUp() The Color variable is passed to initialize the SolidBrush object. I don't understand if I need to do so in NT 8, and if I do, how.
                Thanking
                Mukaddim

                Comment


                  #38
                  Hello Mukaddim,

                  The Plot concepts from NT7 are not going to be the same in NT8, you will need to review the SampleCustomRender as I had noted for the correct syntax here.

                  The objects you previously used for rendering in NT7 like SolidBrush no longer apply so you will need to recreate this part of your script using the correct NT8 objects. NT8 also has new rendering considerations, so it is best to leave the Plot syntax and logic from NT7 out and recreate it in NT8 again by hand based on the new samples we have.

                  Because you know you want a customizable color that can be used for rendering, the SampleCustomRender already does that so you can learn from its existing logic and structure.

                  In the SampleCustomRender, it shows specifically what you are asking about and all required syntax to do that in NT8 so you should not need to reuse any of the objects from NT7, you would instead recreate what you see in the sample for each input color you wanted to use for rendering with OnRender. There are a few different brushes being used in the sample, so you will see some duplication of logic. You mainly would just need to track the syntax related to one of these brushes or AreaBrush as one example.

                  From the sample, if you review the syntax that surrounds "AreaBrush" that will explain what all is required to correctly create one of the brushes for rendering in NT8 and also have a configurable input.


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

                  Comment


                    #39
                    Thanks Jesse,
                    Have been able to do it in OnRender(). Compiled without an error, have to wait and see if any bug is sighted.
                    Mukaddim

                    Comment


                      #40
                      Hi, one of indicators is not being saved as a part of the template. The Log file shows the following error

                      "Could not save indicator 'indicatorName:' There was an error generating the XML document."

                      I have included [XmlIgnore] to all the Brush Properties, and [Browsable(False)] to the Serialization to those Brushes.

                      Any help is highly appreciated.
                      Thanking
                      Mukaddim

                      Comment


                        #41
                        Hello Mukaddim,

                        Thank you for the reply.

                        Yes, this is a serialization error so you are on the right track with [XmlIgnore]. However, it could possibly be something else in the ignored properties causing this problem. For example, a property that should serialize is trying to save a value that cannot save correctly in a certain case.

                        Generally, to locate these type of problems it is best to either create a secondary script which you can place just your public properties in or use commenting to hide properties.

                        Reducing the script will be what shows the location of the problem, so either of the methods mentioned should work. If you are creating a secondary script, you can extract all of the public properties and their defaults from State.Defaults and then check if you get the error. If so, you can further isolate which property that is using comments. You can also just use comments from your main script if you want. you would need to comment out all of the logic that uses your properties, and then you can further isolate the property causing an error.

                        Once you locate what syntax is specifically causing the error if it is not apparent why we can review that together.

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

                        Comment


                          #42
                          Dear Jesse,
                          Thanks for the reply. The issue has been resolved. Can you produce an example for me to see how I can add price plotting on swing dots? the singledot swing indicator is available here in the forum and I would like to see the price associated with the swing high/low dots, drawn according to swing strength.

                          Thanking
                          Mukaddim
                          Last edited by Mukaddim; 09-18-2018, 07:25 AM.

                          Comment


                            #43
                            Hello Mukaddim,

                            Thank you for the reply.

                            It sounds like this would be a fairly specific sample or custom development in this case. I could assist in providing information on how to draw from NinajScript or potentially assist if you are already trying something with that indicator that is not currently working.

                            Have you tried to do this already and reached a point where you could not continue? If so, could you provide a sample of what you tried?

                            If you have not tried this yourself, this would be outside of the scope of a simple sample, this would be more closely aligned with being custom development. I am unsure how that indicators logic works overall to just provide a specific sample that does what you are asking right away. I would very likely need to review that indicator and address how it was programmed to know how drawings should be done for that item in respect to what you are asking. This would be outside of our general support though as we are unable to provide custom development services.

                            If you can provide the link to the specific item you are asking about, I may be able to review the code to estimate possible ways for you to begin if you are having difficulties knowing where to start. You can copy the "send to friend" URL to link a specific file from the forum.


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

                            Comment


                              #44
                              Thank you Jesse!!!
                              Here's the indicator [SEE POST # 4]

                              https://ninjatrader.com/support/foru...d.php?p=542684

                              That indicator, modified by NinjaTrader_ChrisL, draws a single dot according to user defined strength level. I would like to have prices drawn with those dots too. So a high dot should show the dot and the price of that high and so on for the low dot.

                              Please let me know if it is clear enough to you to understand what I'm trying to achieve.

                              Thanking
                              Mukaddim

                              Comment


                                #45
                                Hello Mukaddim,

                                Thank you for the reply.

                                Yes in this indicator this would be a little more difficult to add to due to how the swing plots in general.

                                This indicator uses Plots for the dots you see and erases the plot where it is not needed. Because of this, you would need logic to both add text where needed and also remove/modify prior text's when a new swing is found similar to how it already does this with its plot. Historically would likely be simple to add texts but moving into realtime would likely be where the existing swing logic needs to be debugged to find the best location to update the last swing text.

                                Without running through the logic and seeing how this actually equates everything, the rest of this will be more or less an estimate of what to try.

                                You may be able to use the existing isSwingHigh and isSwingLow conditions to initiate the drawings. There are loops which cover the area the swing covers so you could likely know the start bar to place the text from this.

                                An alternative may be to use the collections in the script that the SwingHighBar and SwingLowBar methods use. In these methods, they iterate the swings to produce a result. You can likely use a similar tactic to iterate the swings to draw all of the objects at once. This would be another area to explore which may be less complex than the first-mentioned method.

                                As far as updating the last text for a new swing, that is something you would likely need to debug the logic using Prints to address how it reacts in realtime specifically. If everything works after your modifications you might not need to worry about this, but I wanted to mention this as the swing is special and rewrites its historical plots. This means you can run into cases where you have a value but it doesn't match what is rendered because you didn't follow the same steps the logic had to have that swings value. The methods at the bottom of the file are good examples of accessing the data in a custom way due to how this indicator works in general.




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

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by andrewtrades, Today, 04:57 PM
                                1 response
                                5 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by chbruno, Today, 04:10 PM
                                0 responses
                                3 views
                                0 likes
                                Last Post chbruno
                                by chbruno
                                 
                                Started by josh18955, 03-25-2023, 11:16 AM
                                6 responses
                                436 views
                                0 likes
                                Last Post Delerium  
                                Started by FAQtrader, Today, 03:35 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post FAQtrader  
                                Started by rocketman7, Today, 09:41 AM
                                5 responses
                                19 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Working...
                                X