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

Color Slope Multiple Lines

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

    Color Slope Multiple Lines

    I copied most of this code but can't get the references right. Bottom line, I'm trying to Color the lines based on last slope or rising-falling. If flat use last line color.

    As an example' I've copied the Donchain Cannel Indicator and I want each line(Plot) "Mean,Upper,Lower" to refer to private Color "risingChannel,fallingChannel" based on it's value rising/falling == true or >< [1] ago.

    I've tried Multiple ways to get each line to reference these colors based on rising falling conditions but can't seem to get the code right.

    If anyone at this form can help with one Plot, I might be able to manage the rest.

    Thanks
    Attached Files

    #2
    Hi BryanGriggs,

    I am not seeing any logic in this file that looks for rising or falling values.

    The code I think you are looking for is something like:


    if (Rising(Upper))
    PlotColors[1][0] = Color.ForestGreen;

    This would color the upper band green when the value is rising.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ChelseaB,

      Thank You for your response!
      I removed any all logic that I had put in because I couldn't get anything to work without compile errors.

      Two things;

      1)
      Where would that go? I had tried that before and I tried inserting that exact line in but keep getting compile errors. I'm obviously not doing something right. Also I would need to do this for each line (Plot)as a hard set color, right?

      2)
      I want to be able to set the colors of each plot from the risingChannel/fallingChannel Color. How do I do this?

      Is this anywhere close to right and where in code would I insert without getting compile errors? I assume it comes in under OnBarUpdate but would it need it's own OwnBarUpdate area?

      Thanks again for your time & help.


      if (Rising(Upper))
      {

      PlotColors[1][0] = risingChannel;
      }
      else if (Falling(Upper))
      {
      PlotColors[1][0] = fallingChannel;
      }
      else PlotColors[1][0]=PlotColors[1][1];

      Comment


        #4
        Hi BryanGriggs,

        The code for the plot change would go in OnBarUpdate.

        As far as using a variable is concerned that is possible.

        For example:
        in #region Variables:
        private Color risingChannel = Color.ForestGreen;

        in OnBarUpdate():
        if (Rising(Upper))
        PlotColors[1][0] = risingChannel;


        If you are not able to get it working, post your code with the incorrect code in it so that we can see what you are trying.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          ChelseaB,

          This is what I've got.

          Thanks
          Attached Files

          Comment


            #6
            Hello BryanGriggs,

            First, the code you added is not in OnBarUpdate. OnBarUpdate is closed out with a bracket on line 49.

            Then there is a random open bracket on lines 50 and 61 and random close brackets on lines 59 and 70.

            If you are trying to place brackets to make the if (SlopeColor == true) a branching command with the plot colors change as the action block, the open bracket needs to go after the if (SlopeColor == true).

            For example:

            if (SlopColor == true)
            {
            // execute code block
            }
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              ChelseaB,

              I Truly can't thank you enough!!!
              Please see before & after attachments.
              The level of service & support that you all provide is second to none in any industry.
              Thank you sooooo Much!

              Bryan Griggs
              Attached Files

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by helpwanted, Today, 03:06 AM
              1 response
              8 views
              0 likes
              Last Post sarafuenonly123  
              Started by Brevo, Today, 01:45 AM
              0 responses
              7 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              5 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              242 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              385 views
              1 like
              Last Post Gavini
              by Gavini
               
              Working...
              X