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:

    https://ninjatrader.com/support/foru...app-submission

    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]
            [Range(1, int.MaxValue)]
            [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:	76
Size:	54.6 KB
ID:	1171833

                Scale Justification ---> OVERLAY

                Click image for larger version

Name:	CL Overlay.png
Views:	73
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

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by DouglasHogan, Today, 02:12 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post DouglasHogan  
                      Started by SydniBuck, Today, 12:54 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post SydniBuck  
                      Started by ketostrongbuyno, Yesterday, 11:50 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post ketostrongbuyno  
                      Started by ReinaKutch, Yesterday, 11:08 PM
                      0 responses
                      9 views
                      0 likes
                      Last Post ReinaKutch  
                      Started by JackyThur, Yesterday, 10:51 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post JackyThur  
                      Working...
                      X