Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RSI Indicator over 70 below 30

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

    RSI Indicator over 70 below 30

    Hi,

    I'm trying to develop an indicator that draw a number 1 when RSI is above 70 and -1 when it's below 30.

    int above =(RSI(14, 3)[0] >= 70 ? 1:0);
    int below =(RSI(14, 3)[0] <= 30 ? -1:0);


    Over70.Set(above);
    Below30.Set(below);

    Ok. Everything works. But now I'd like to for example, when RSI crossses above 70 remains on 1 as far RSI crosses below 30, and again, remains drown -1 as far RSI goes above 70.

    I mean only 1111111111 or -1-1-1-1-1-1 plotted on the chart.

    Thanks for help.

    #2
    fercho, then just don't set the int to 0 if the condition is not valid anymore, so it would only change on cross of the RSI of 30 / 70.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      well how to code that?

      I can´t figure out your idea sorry

      thanks

      Comment


        #4
        We could unfortunately not custom code or modify this for you - but there are a number of certified NinjaScript consultants available that could assist in this : http://www.ninjatrader.com/partners#...pt-Consultants
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by fercho View Post
          well how to code that?

          I can´t figure out your idea sorry

          thanks
          It might be simpler, and definitely less resource intensive, if you used a single line and a single plot instead.

          Code:
           
          private int plotSetter = 0; // this must be declared outside the [I]OnBarUpdate()[/I] method; best in the [I]Variables[/I] section.
           
          plotSetter = (RSI(14, 3)[0] >= 70) ? 1 : (RSI(14, 3)[0] <= 30) ? -1 : plotSetter;
           
          ExtemeValue.Set(plotSetter);

          Comment


            #6
            Perfect!

            Thanks konagam for the code !

            I was coded st more complex and more resources consumer

            Initialize

            BarsRequired = 2000;

            OnBarUpdate

            int x = (MRO(delegate {return RSI(Period, 3)[0] >= 70;},1, 2000) < MRO(delegate {return RSI(Period, 3)[0] <= 30;},1, 2000) ? 1 : -1);
            Bull.Set(x);

            Comment


              #7
              Originally posted by fercho View Post
              Thanks konagam for the code !

              I was coded st more complex and more resources consumer

              Initialize

              BarsRequired = 2000;

              OnBarUpdate

              int x = (MRO(delegate {return RSI(Period, 3)[0] >= 70;},1, 2000) < MRO(delegate {return RSI(Period, 3)[0] <= 30;},1, 2000) ? 1 : -1);
              Bull.Set(x);
              Your code looks workable: there are usually many ways to code the same thing. But, did you really mean to say that no calculations should be done until there are 2000 bars available?! That is an awful lot of bars before starting, especially when the NT default lookback is only 256 bars.

              Comment


                #8
                Yeap, it was on beta v.007 -

                Thanks again for the simpliest way!

                Now I'm working on using MACD as stop loss reference.

                For ex, when BUY signal happens, set the MACD value at this entrypoint as StopLoss. So if after that MACD goes lower than the entry MACD value, the exit and close position...

                if (CrossAbove(RSI(14, 3), 30, 1))
                {
                EnterLong(DefaultQuantity, "Long");
                SetStopLoss(CalculationMode.Price, MACD(12,26,9)[0]);
                }

                But MACD goes lower than MACD entry point and Nothing happens

                Comment


                  #9
                  Originally posted by fercho View Post
                  Yeap, it was on beta v.007 -

                  Thanks again for the simpliest way!

                  Now I'm working on using MACD as stop loss reference.

                  For ex, when BUY signal happens, set the MACD value at this entrypoint as StopLoss. So if after that MACD goes lower than the entry MACD value, the exit and close position...

                  if (CrossAbove(RSI(14, 3), 30, 1))
                  {
                  EnterLong(DefaultQuantity, "Long");
                  SetStopLoss(CalculationMode.Price, MACD(12,26,9)[0]);
                  }

                  But MACD goes lower than MACD entry point and Nothing happens
                  The part that I have highlighted in red means that you are setting your StopLoss to the value of the MACD, which rarely goes above 10, if that. After all it is just the difference between 2 EMA's! In fact, many times, your StopLoss is going to end up being negative for Long positions, as the MACD is often beneath zero when a bullish cross takes place, and even if you choose to use the zero-line cross instead, then your StopLoss is going to be very close to zero, and so will almost never trigger except on some really low-priced penny stock.

                  You want to use some corresponding price to your planned MACD point at which you are setting the StopLoss.

                  Comment


                    #10
                    Well the Idea was on Gerald Appeld (MACD Book "Power Tools for Active Investors"), he talks about using the MACD entry level as stop loss point.

                    See the chart attached.

                    thanks for reply!
                    Attached Files

                    Comment


                      #11
                      Originally posted by fercho View Post
                      Well the Idea was on Gerald Appeld (MACD Book "Power Tools for Active Investors"), he talks about using the MACD entry level as stop loss point.

                      See the chart attached.

                      thanks for reply!
                      I repeat: "You want to use some corresponding price to your planned MACD point at which you are setting the StopLoss. "

                      Which, incidentally is what your picture shows. The StopLoss is predicated on the Price at the time that the MACD crossed over, NOT the value of the MACD. Reread the book,

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by funk10101, Today, 09:43 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post funk10101  
                      Started by pkefal, 04-11-2024, 07:39 AM
                      11 responses
                      36 views
                      0 likes
                      Last Post jeronymite  
                      Started by bill2023, Yesterday, 08:51 AM
                      8 responses
                      44 views
                      0 likes
                      Last Post bill2023  
                      Started by yertle, Today, 08:38 AM
                      6 responses
                      26 views
                      0 likes
                      Last Post ryjoga
                      by ryjoga
                       
                      Started by algospoke, Yesterday, 06:40 PM
                      2 responses
                      24 views
                      0 likes
                      Last Post algospoke  
                      Working...
                      X