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

BB Stops From Thinkscript custom indicator

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

    BB Stops From Thinkscript custom indicator

    Hi All, I am looking for something like the cyan/ magenta dots seen on the attached chart. Basically like an ATR trailing stop but instead it uses Bollinger Bands to calculate not sure exactly. Please help! This indicator is very important to my trading visually. The code is not copyrighted or being sold anywhere. I can post here if it is not against the rules. -Chris

    #2
    Hello,
    I guess its using upper band to trail sl for short trades & lower band for long trades. This actually is simple to plot, you can use 2 plots & achieve it.

    Comment


      #3
      Originally posted by s.kinra View Post
      Hello,
      I guess its using upper band to trail sl for short trades & lower band for long trades. This actually is simple to plot, you can use 2 plots & achieve it.
      Thank you, check this out and let me know if it is any more help. It is currently set 34, EMA on my charts.

      input baseMA = {default sma, ema, wma, vwma, swma, dema, hullema, tema};
      input length = 20;
      input mult = 1; #hint mult: 0.001 to 50
      input colorFill = yes;

      def vClose = close;
      def bn = BarNumber();
      def nan = double.NaN;

      def ema1 = MovingAverage(AverageType.EXPONENTIAL, vClose, length);
      def ema2 = MovingAverage(AverageType.EXPONENTIAL, ema1, length);
      def ema3 = MovingAverage(AverageType.EXPONENTIAL, ema2, length);
      def tema = 3 * (ema1 - ema2) + ema3;

      def wma = MovingAverage(AverageType.WEIGHTED, vClose, length);

      def basis;
      switch (baseMA)
      {
      case sma: basis = MovingAverage(AverageType.SIMPLE, vClose, length);
      case ema: basis = MovingAverage(AverageType.EXPONENTIAL, vClose, length);
      case wma: basis = MovingAverage(AverageType.WEIGHTED, vClose, length);
      case vwma: basis = MovingAverage(AverageType.EXPONENTIAL, vClose, length);
      case swma: basis = wma[3]/6 + 2*wma[2]/6 + 2*wma[1]/6 + wma;
      case dema: basis = ema2;
      case hullema: basis = MovingAverage(AverageType.HULL, vClose, length);
      case tema: basis = tema;
      }

      def dev = mult * stdev(vClose, length);
      def upper = basis + dev;
      def lower = basis - dev;

      def up = if bn == 1
      then nan
      else if Crosses(vClose, upper, CrossingDirection.ABOVE)
      then 1
      else if Crosses(vClose, lower, CrossingDirection.BELOW)
      then 0
      else up[1];

      def dn = if bn == 1
      then nan
      else if Crosses(vClose, lower, CrossingDirection.BELOW)
      then 1
      else if Crosses(vClose, upper, CrossingDirection.ABOVE)
      then 0
      else dn[1];

      def changeUp = dn[1] and up;
      def changeDn = up[1] and dn;
      def stopLine = if up then lower else if dn then upper else nan;

      plot p1 = stopLine;
      p1.SetLineWeight(2);
      p1.AssignValueColor(if stopLine == upper then Color.Magenta else Color.Cyan);



      #plot pChangeDn = if changeDn then lower else nan;
      #plot pChangeUp = if changeUp then upper else nan;
      #pChangeDn.SetPaintingStrategy(PaintingStrategy.BO OLEAN_ARROW_DOWN);
      #pChangeUp.SetPaintingStrategy(PaintingStrategy.BO OLEAN_ARROW_UP);
      #pChangeDn.SetDefaultColor(Color.Red);
      #pChangeUp.SetDefaultColor(Color.Green);

      Comment


        #4
        Hello Chris,
        You can work around a new indicator for this & use the intended logic, actually its easy, if stuck anywhere will surely help. Use new indicator wizard to get started. SWMA is not available by default all others are included in NT8 so you can simply invoke them.
        Last edited by s.kinra; 10-22-2020, 01:48 AM.

        Comment


          #5
          Hello technicallydreaming,

          Thanks for your post and welcome to the NinjaTrader forums!

          If you would like to create this yourself, we can provide links to get you started in a general way with Ninjascript which is based on C# programming language.

          If you would like this created for you, we can provide a link to 3rd party programmers in the NinjaTrader Ecosystem.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_PaulH View Post
            Hello technicallydreaming,

            Thanks for your post and welcome to the NinjaTrader forums!

            If you would like to create this yourself, we can provide links to get you started in a general way with Ninjascript which is based on C# programming language.

            If you would like this created for you, we can provide a link to 3rd party programmers in the NinjaTrader Ecosystem.
            Thanks Paul, I compared the " BB Stops" side by side with the Ninja indicator "TS Supertrend" and I can't really say what I had was any better. In fact in some cases, it even provides earlier signals...so I am going to stick with the Supertrend!

            Comment


              #7
              Hello technicallydreaming,
              Here you get BbStopLoss.zip , just in case you still need it.

              Comment


                #8
                Originally posted by s.kinra View Post
                Hello technicallydreaming,
                Here you get [ATTACH]n1124174[/ATTACH] , just in case you still need it.
                That is so cool! Thank you so much. Will be testing both Supertrend and this one properly in Ninjatrader in the next few days. I have done my best to replicate my entire chart from ToS in ninja and I think I have gotten close if not exactly a match (minus the volume average becuase I am using Tick charts now). I have attached a screenshot for comparison. The Madrid ribbon is very quick way to identify the trend strength for me. Loving Ninjatrader so much. Like a fighter jet compared to every other software I have used.

                Comment


                  #9
                  Can you attach the screenshot again, I can't get it. I'll have a look.

                  Comment


                    #10
                    Can you see this one?

                    Click image for larger version  Name:	MES 12-20 (950 Tick) 2020_10_23 (12_25_28 AM).jpg Views:	0 Size:	291.3 KB ID:	1124182

                    Comment


                      #11
                      Yes, I can see it now. Thanks!

                      Comment


                        #12
                        OK, so what exactly is your doubt now? I can add Volume to tick chart as well & so the Volume MA. Let me know where are you getting stuck.

                        Comment


                          #13
                          Originally posted by s.kinra View Post
                          OK, so what exactly is your doubt now? I can add Volume to tick chart as well & so the Volume MA. Let me know where are you getting stuck.
                          No problems! Volume is not very important for my trading, don't need it at least at the moment. I am really excited to get started with Ninja... I was just showing off my new chart haha

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by zstheorist, Today, 07:52 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post zstheorist  
                          Started by pmachiraju, 11-01-2023, 04:46 AM
                          8 responses
                          149 views
                          0 likes
                          Last Post rehmans
                          by rehmans
                           
                          Started by mattbsea, Today, 05:44 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post mattbsea  
                          Started by RideMe, 04-07-2024, 04:54 PM
                          6 responses
                          33 views
                          0 likes
                          Last Post RideMe
                          by RideMe
                           
                          Started by tkaboris, Today, 05:13 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post tkaboris  
                          Working...
                          X