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

Supertrend by Ninjatrader_ChelseaB

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

    Supertrend by Ninjatrader_ChelseaB

    I usually use Supertrend with 10 bars and a 1.5 multiplier.

    I can't seem to get that 1.5 into your indicator. This may be a NT thing but I was hoping it might be something you can amend.

    Could you let me know please?

    cheers
    Michael Colantoni​

    #2
    Hello mcolantoni,

    To confirm, you are referring to the specific SuperTrend indicator linked below?
    The Supertrend indicator as published in the July 2023 Technical Analysis of Stocks and Commodities article “Staying On Track With The Supertrend Indicator.” by Barbara Star, PhD.


    The Multiplier was defined as an integer (int).

    On line 107, you could choose to define this as a double instead.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, that's the one. Can you change it so we can use 1.5 etc.
      Thanks for your reply.
      cheers

      Comment


        #4
        Hello mcolantoni,

        I will add the request for the script to be changed.

        In the meantime, if you have any difficulty changing the int to double on line 107 I would be happy to provide guidance.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I made the following changes to that part of the code but it has not changed anything.

          Click image for larger version

Name:	Clipboard02.jpg
Views:	104
Size:	124.0 KB
ID:	1270854
          Attached Files

          Comment


            #6
            Hello mcolantoni,

            Compile by right-clicking and selecting Compile.

            Then reload the script on the chart. Then you should be able to use decimals.

            Note, if you want a value of less than 1, set the Range attribute to start at 0.
            [Range(0, 10)]
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I really love this indicator. Does what it needs and simple coding. But would be nice if the author can make it dual color. Bullish line and Bearish Lines in two different colors? If someone can give me the snippets to do that, I can kind of add it to the code myself. Thanks a lot!

              Comment


                #8
                Hello Handclap0241,

                Welcome to the NinjaTrader forums!

                You can either add a second plot with a different color and set the other plot values, or set the color of the plot for specific bars.

                To add a second plot use AddPlot() and in a condition that checks for "bullish" or "bearish" with your custom logic set the Values[plot index][barsAgo index].
                Below is a link to a support article with details.


                To change the plot color (of a single plot), in a condition that checks for "bullish" or "bearish" with your custom logic, set the PlotBrushes[plot index][barsAgo index].
                Below is a link to the help guide with further details.


                I am also providing a link to a support article with helpful resources on getting started with C# and NinjaScript.


                You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you Chelsea B.
                  Much appreciated. I am new to NT. Know my way around Pine script though. What would be the Bullish/Bearish condition here? Could you please help? The following plots everything blue. Thanks a lot.

                  Code:
                  if (Close[0] < topValue)
                  {
                  Plots[0].Brush = Brushes.Blue;
                  Plots[0].Width = 2;
                  }
                  else
                  {
                  Plots[0].Brush = Brushes.Red;
                  Plots[0].Width = 2;
                  }​

                  Comment


                    #10
                    Hello Handclap0241,

                    This would depend, what logic do you consider bullish or bearish?

                    For bullish, do you mean the current bars value is greater than the previous bar's value, so the plot is rising?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi, Thanks for your quick reply.

                      Basically when it comes to supertrend, when the supertrend line is above the price, then it’s bearish, the supertrend is plotted in say red.
                      When the supertrend line is below the price, then it’s bullish, the supertrend is plotted in say green.

                      When the price crosses above or cross below the supertrend line, the trend changes from bullish to bearish and vice versa. Thanks

                      Comment


                        #12
                        like this.

                        Comment


                          #13
                          Hello Handclap0241,

                          The plot is above the close price:

                          if (Default[0] > Close[0])

                          Setting the PlotBrushes:

                          PlotBrushes[0][0] = Brushes.Blue;
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Worked like a charm. Thanks for spoon feeding me on this. Much appreciated.

                            Ninja Coding is not all that difficult, I guess the interface is a little scary and different (when compared to pine) at first. I am going to try hacking some code over weekends.

                            If anybody who wants this color change tweak, please add this to the bottom portion of the onboarupdate() block.

                            Code:
                                        if (Default[0] > Close[0])
                                            {
                                            PlotBrushes[0][0] = Brushes.Blue;
                                            }
                                            else
                                            {
                                            PlotBrushes[0][0] = Brushes.Red;
                                            }
                            ​
                            Thanks Chelsea once again.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by burtoninlondon, Today, 12:38 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post burtoninlondon  
                            Started by AaronKoRn, Yesterday, 09:49 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post AaronKoRn  
                            Started by carnitron, Yesterday, 08:42 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post carnitron  
                            Started by strategist007, Yesterday, 07:51 PM
                            0 responses
                            12 views
                            0 likes
                            Last Post strategist007  
                            Started by StockTrader88, 03-06-2021, 08:58 AM
                            44 responses
                            3,982 views
                            3 likes
                            Last Post jhudas88  
                            Working...
                            X