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

LBR Paintbars Color Persist

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

    LBR Paintbars Color Persist

    Afternoon. I translated the Linda Raschke's ATR paintbar program into NT8 but I'm having trouble with a modification that I make to the indicator. Below I will show you what it looks like in NT8 and then what it is SUPPOSED to look like from my Tradestation client.

    Standard(NT8): The ATR paintbar program paints the price bars "green" when price is above a particular volatility function value, and "red" when price is below a particular volatility function value. WHEN THE PRICE IS BETWEEN THOSE VOLATILITY BANDS, the regular program will just paint the bars whatever color you have as default. I set it to white for the example below.
    Click image for larger version

Name:	Screenshot_1.png
Views:	1071
Size:	24.2 KB
ID:	1162784
    NT8 Indicator Logic:
    protected override void OnBarUpdate()
    {
    if(CurrentBar < Length) return;

    double highesthigh = High[HighestBar(High,Length)];
    double lowestLow = Low[LowestBar(Low,Length)];
    double smaATR = SMA(ATR(Period),Period)[0];
    double upperVol = highesthigh - (Factor*smaATR);
    double lowerVol = lowestLow + (Factor*smaATR);

    if(Close[0] > upperVol && Close[0] > lowerVol)
    {
    BarBrush = Upcolor;
    }
    BarBrush = BarBrush;
    if(Close[0] < lowerVol && Close[0] < upperVol)
    {
    BarBrush = Downcolor;
    }





    My Modification: I set the paint bars to persist on painting the last color applied to the plot UNTIL the other color value is triggered by the volatility function. So the bars will stay green until red is triggered and never revert to the default chart color.
    Click image for larger version

Name:	Screenshot_2.png
Views:	860
Size:	26.7 KB
ID:	1162785



    I cannot figure out how to do this in NT8. Can anyone help me? The above modification is done in Tradestation.

    #2
    Hello Noongun,

    Thanks for your post.

    To get the same performance you would need to create and use a bool variable that is set to one state or the other by the conditions then use the bool to select which brush to paint with.

    For example:

    if(Close[0] > upperVol && Close[0] > lowerVol)
    {
    myBool = true;
    }
    if(Close[0] < lowerVol && Close[0] < upperVol)
    {
    myBool = false;
    }

    BarBrush = myBool ? UpColor : DownColor;

    The bar brush will be painted on every bar based on the state of the bool which is controlled by the conditions.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you, Paul.

      I'll make those modifications whenever I get back home. Will give an update afterwards

      Comment


        #4
        Works perfectly, thank you.

        Comment


          #5
          Originally posted by Noongun View Post
          Works perfectly, thank you.
          Could you please post/share the NT7 paintbar version that you converted to NT8, I can't seem to find it anywhere.

          Omololu

          Comment


            #6
            Omololu I THINK this is the nt7 version
            Attached Files

            Comment


              #7
              Originally posted by NinjaTrader_PaulH View Post
              Hello Noongun,

              Thanks for your post.

              To get the same performance you would need to create and use a bool variable that is set to one state or the other by the conditions then use the bool to select which brush to paint with.

              For example:

              if(Close[0] > upperVol && Close[0] > lowerVol)
              {
              myBool = true;
              }
              if(Close[0] < lowerVol && Close[0] < upperVol)
              {
              myBool = false;
              }

              BarBrush = myBool ? UpColor : DownColor;

              The bar brush will be painted on every bar based on the state of the bool which is controlled by the conditions.
              Hey bro. I don't supposed you would know how to add a statement in there that would paint the bar a different color on close outside of the Keltner channel? I don't think I can do it with the Boolean function right now unless I embed something into the "If" statement that redirects to another paint function if the price closes outside of the channel.

              Comment


                #8
                Hello Noongun,

                Thank you for your reply.

                Paul is out of the office today, but I'm happy to assist.

                You could add another if statement after the initial setting of the bar brush that would reassign a different color only if the bar closes outside the Keltner Channel:

                For example:

                if(Close[0] > upperVol && Close[0] > lowerVol)
                {
                myBool = true;
                }
                if(Close[0] < lowerVol && Close[0] < upperVol)
                {
                myBool = false;
                }

                BarBrush = myBool ? UpColor : DownColor;

                if ((Close[0] > KeltnerChannel(Close, 1.5, 10).Upper[0])
                || (Close[0] < KeltnerChannel(Close, 1.5, 10).Lower[0]))
                {
                BarBrush = Brushes.Fuchsia;
                }

                This would only paint the bars that close outside the Keltner Channel fuchsia, otherwise, they would be painted according to the bool that is set.

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

                Comment


                  #9
                  Originally posted by NinjaTrader_Kate View Post
                  Hello Noongun,

                  Thank you for your reply.

                  Paul is out of the office today, but I'm happy to assist.

                  You could add another if statement after the initial setting of the bar brush that would reassign a different color only if the bar closes outside the Keltner Channel:

                  For example:

                  if(Close[0] > upperVol && Close[0] > lowerVol)
                  {
                  myBool = true;
                  }
                  if(Close[0] < lowerVol && Close[0] < upperVol)
                  {
                  myBool = false;
                  }

                  BarBrush = myBool ? UpColor : DownColor;

                  if ((Close[0] > KeltnerChannel(Close, 1.5, 10).Upper[0])
                  || (Close[0] < KeltnerChannel(Close, 1.5, 10).Lower[0]))
                  {
                  BarBrush = Brushes.Fuchsia;
                  }

                  This would only paint the bars that close outside the Keltner Channel fuchsia, otherwise, they would be painted according to the bool that is set.

                  Please let us know if we may be of further assistance to you.
                  Thank you so much, Kate, It works perfectly.

                  Comment


                    #10
                    Originally posted by Noongun View Post
                    Omololu I THINK this is the nt7 version
                    Thanks very much.

                    Comment


                      #11
                      Noongun , NinjaTrader_Kate & NinjaTrader_PaulH - Is there any chance you could share the NinjaScript code for the NT8 version of this indicator?

                      Thanks

                      Comment


                        #12
                        Hello burtoninlondon,

                        Thank you for your reply.

                        I don't believe Noongun ever posted this particular indicator either on the forum or on the User App Share as I'm not seeing it. You might try sending them a private message, however, and see if they are willing to share with you. I do not have a working copy of the indicator.

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

                        Comment


                          #13
                          Hello Noongun,

                          I would really appreciate it if you could you please post/share the NT8 paintbar version.

                          Thanks a lot!

                          Comment


                            #14
                            NT8 version:
                            https://ninjatrader.com/support/foru...ntbars-for-nt8

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by RubenCazorla, 08-30-2022, 06:36 AM
                            3 responses
                            77 views
                            0 likes
                            Last Post PaulMohn  
                            Started by f.saeidi, Yesterday, 12:14 PM
                            9 responses
                            23 views
                            0 likes
                            Last Post f.saeidi  
                            Started by Tim-c, Today, 03:54 AM
                            0 responses
                            3 views
                            0 likes
                            Last Post Tim-c
                            by Tim-c
                             
                            Started by FrancisMorro, Today, 03:24 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post FrancisMorro  
                            Started by Segwin, 05-07-2018, 02:15 PM
                            10 responses
                            1,772 views
                            0 likes
                            Last Post Leafcutter  
                            Working...
                            X