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

GRTMultiLines User Apps Share NT7 to NT8 convert

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

    #16
    Hello PaulMohn,

    Thank you for your reply.

    Ah, I assumed you wanted the lines to remain at the same points throughout the day and not update. If you want them to update with the new hourly bar, just remove the bool variable and just assign MidPoint without checking it's been previously set:

    Code:
    public class GRTMultiLines : Indicator
    {
    
    private double MidPoint;
    
    protected override void OnStateChange()
    {
    Code:
    protected override void OnBarUpdate()
    {
    //if (CurrentBar < 10) return;
    if (CurrentBars[1] < 1) return;
    
    MidPoint = CurrentDayOHL(BarsArray[1]).CurrentOpen[0];
    I can't post this to the User App Share for you, but you're welcome to post it yourself here:

    Upload tools and add-ons that you build to share through the NinjaTrader Ecosystem User App Share.


    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #17
      Hello NinjaTrader_Kate and thank you very much again for your help. I'll test both versions tomorrow and see which requires the least management. Thank you for both versions.
      Do you know if I can post the code right now, or should I first ask permission to zacharydw00? I don't know how to contact zacharydw00. Or could you perhaps ask on my behalf if not too much trouble? The code is public here https://ninjatraderecosystem.com/use...ad/multilines/ .
      I just partially converted it, more credits to you really for the improvements to the original, that's why I thought you might post it.

      Comment


        #18
        Hello PaulMohn,

        Thank you for your reply.

        All the scripts from the User App Share are open source and may be modified without the permission of the original author, though it is generally considered best practice to mention the original author in the body of the post. You can go ahead and post it, I'd just mention it is a conversion of that original version for NinjaTrader 7 by zacharydw00.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #19
          Hello NinjaTrader_Kate and thank you for the detailed info. I've updated the script to include 121 lines instead of the default 21. The script seems ok, it compiles, but I get a log error
          20/09/2021 19:05:25 Default Indicator 'GRTMultiLines': Error on calling 'OnBarUpdate' method on bar 1: Index was outside the bounds of the array.
          I do have the check
          protected override void OnBarUpdate()
          {
          //if (CurrentBar < 10) return;
          if (CurrentBars[1] < 1) return;
          at the top of OnBarUpdate for the secondary series. I don't understand why the index error is back. It works with the 21 lines but not with the 121 lines.
          I attach the script.

          Last request before uploading it to the User Apps Share. About the LineStyle = DashStyleHelper.Dash; I have it hardcoded and I can't change it in the Indicator properties window. What would be the correct way to code it so users can select whichever line style they want (Dash, Dot etc.).
          Attached Files

          Comment


            #20
            Hello PaulMohn,

            Thank you for your reply.

            You only have plots 0 through 120 set up in State.SetDefaults, but you're trying to assign to a Plot121 which does not exist. You'll need to add an additional AddPlot in State.SetDefaults:

            Code:
            AddPlot(Brushes.Magenta, "Line121");
            Also, I would recommend setting IsOverlay to true in State.SetDefaults - it's currently set to false, which makes the indicator display in a separate panel - if you want it to display over the price bars automatically, change this to true.

            Lastly, your only issue with the LineStyle input is that you're telling it that the default values have to be an int. Remove the following line that's in bold and it should work to control the DashStyle:

            Code:
            [NinjaScriptProperty]
            [B][Range(1, int.MaxValue)][/B]
            [Display(Name="LineStyle", Description="Set all Line Styles", Order=12, GroupName="Parameters")]
            public DashStyleHelper LineStyle
            { get; set; }


            Kate W.NinjaTrader Customer Service

            Comment


              #21
              Hello NinjaTrader_Kate and thanks again for your keen eye and great help and accomplishment. I've uploaded the final update to the User Apps Share https://ninjatrader.com/support/foru...multilines-nt8

              Many thanks.

              Comment


                #22
                Originally posted by PaulMohn View Post
                Hello NinjaTrader_Kate and thanks again for your keen eye and great help and accomplishment. I've uploaded the final update to the User Apps Share https://ninjatrader.com/support/foru...multilines-nt8

                Many thanks.
                Hi PaulMohn,

                Thanks for this indicator.

                The indicator does not seem to work with Crude Oil (CL) and Euro (6E) as expected. Please find below the screenshots for CL with Scale Justification set to Right and Overlay respectively. You will note that the Overlay option seems to be close to the expected Right Justification behavior, but not good enough. Can we work with the Overlay Justification ?

                Scale Justification ---> RIGHT

                Click image for larger version

Name:	CL Right.png
Views:	367
Size:	54.6 KB
ID:	1171833

                Scale Justification ---> OVERLAY

                Click image for larger version

Name:	CL Overlay.png
Views:	357
Size:	67.3 KB
ID:	1171834

                Comment


                  #23
                  Hello omololu and thanks for the comment and helpful points, I didn't know about those issues sorry. Sorry this is my 1st indicator conversion, and it was Ninjatrader_Kate who got it right.
                  The CL chart is compressed because the LineSpacing parameter value is set to 2 (2.0) as default. But CL has a tick basis point of 0.01. Try changing the LineSpacing parameter value to 0.01 (1 tick spacing) or 0.10 (10 ticks spacing) or more per your liking but less than 2.0 (200 ticks spacing).
                  Similar fix for forex. 6E pip basis point is 0.00001 or 0.0001 I think. Try the LineSpacing parameter value 0.00001 or 0.0001 (or between 1 and 50 pip points should get the chart displaying ok, test what suits you best). 2.0 means 200k or 20k pips LineSpacing I think.

                  Maybe we could add a per instrument pip / tick default basis point to solve the issue. For example hardcode ES = 2.0, Cl = 0.2, 6E = 0.002 etc. or better solution if you know one. I'll ask Ninjatrader_Kate.

                  The justification would be great also, but I don't know if or how it's possible. I'll ask Ninjatrader_Kate.

                  NinjaTrader_Kate
                  ?

                  Comment


                    #24
                    Hello PaulMohn,

                    Thank you for your note.

                    To have it adjust based on instrument tick/pip size, you can multiply what you're adding to the midpoint by TickSize:

                    if (LineCount >= 1) Line0 [0] = MidPoint;
                    if (LineCount >= 2) Line1 [0] = MidPoint + (LineSpacing * TickSize);
                    if (LineCount >= 3) Line2 [0] = MidPoint - (LineSpacing * TickSize);
                    if (LineCount >= 4) Line3 [0] = MidPoint + ((LineSpacing * 2) * TickSize);
                    if (LineCount >= 5) Line4 [0] = MidPoint - ((LineSpacing * 2) * TickSize);
                    if (LineCount >= 6) Line5 [0] = MidPoint + ((LineSpacing * 3) * TickSize);
                    if (LineCount >= 7) Line6 [0] = MidPoint - ((LineSpacing * 3) * TickSize);
                    if (LineCount >= 8) Line7 [0] = MidPoint + ((LineSpacing * 4) * TickSize);
                    if (LineCount >= 9) Line8 [0] = MidPoint - ((LineSpacing * 4) * TickSize);
                    if (LineCount >= 10) Line9 [0] = MidPoint + ((LineSpacing * 5) * TickSize);
                    //code continues

                    As far as the justification goes, I think they're saying it's not going all the way to the current bar when on Right justification. Try setting the Calculate setting to OnPriceChange so it will plot through the currently forming bar.

                    Please let us know if we may be of further assistance to you.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #25
                      Hello NinjaTrader_Kate and many thanks again for the working fixes. I got the TickSize added and it seems to work fine (I tested on CL and GBPUSD). Also the OnPriceChange is working. I changed it in the code to Calculate = Calculate.OnPriceChange; but it also needs to be set in the properties windows, screenshot attached, and update attached

                      Many thanks.
                      Attached Files

                      Comment


                        #26
                        I see that the MultiLines Indicator (with up to 121 horizontal lines, with the MidPoint set as the current day's Open)
                        Is it possible to add code with the option for the MidPoint to start at a user defined value. I have attached screen shots of Woodies Pivots where we have this option.
                        I am not a programmer, but I do think this option would greatly enhance the indicator.

                        Comment


                          #27
                          Hello mr. mike,

                          Thanks for your note.

                          You could consider sending a direct message to the developer of this indicator, PaulMohn, to request that the developer add the change you mentioned to the indicator.

                          It would be up to their discretion to decide if they want to add this modification to the script.

                          If you would like to modify the script yourself, please let me know and I will be happy to provide some direction to get you started.

                          Please let me know if I may assist further.

                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #28
                            hi BrandonH,
                            thank you for your response, as you suggested I have sent a direct message to PaulMohn, however, I would very much appreciate your help modifying thus script.

                            Comment


                              #29
                              Hello mr. mike,

                              Thanks for your note.

                              You may create a user-defined enum parameter type to allow you to select between different options in the Properties section of the indicator.

                              Then, you could create the user-defined inputs that will be used when the 'Use user-defined values' enum option is selected. The code of the indicator would then need to be modified to account for each enum option that is selected.

                              If the 'Use user-defined values' option is selected, the user-defined inputs you create would need to be used for calculations in the script. When another option is selected, you would use PaulMohn's code for the calculations.

                              See the help guide documentation and reference sample linked below for more information.

                              Creating a user-defined parameter type (enum): https://ninjatrader.com/support/help...ned_parame.htm
                              Creating user-defined input parameters: https://ninjatrader.com/support/help...d_input_pa.htm

                              Please let me know if you have further questions.
                              Brandon H.NinjaTrader Customer Service

                              Comment


                                #30
                                Hi Brandon H.
                                thank you again for your response in regards to the GRTMultilines indicator. I have not had a response from PaulMohn and I have not been able to modify the code. Can I send you a direct message ? If yes, how do i send it?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by DJ888, 04-16-2024, 06:09 PM
                                6 responses
                                18 views
                                0 likes
                                Last Post DJ888
                                by DJ888
                                 
                                Started by Jon17, Today, 04:33 PM
                                0 responses
                                1 view
                                0 likes
                                Last Post Jon17
                                by Jon17
                                 
                                Started by Javierw.ok, Today, 04:12 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post Javierw.ok  
                                Started by timmbbo, Today, 08:59 AM
                                2 responses
                                10 views
                                0 likes
                                Last Post bltdavid  
                                Started by alifarahani, Today, 09:40 AM
                                6 responses
                                41 views
                                0 likes
                                Last Post alifarahani  
                                Working...
                                X