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

outside bar indicator

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

    outside bar indicator

    Hello,I want to transform this indicator of inside bar on a outside bar indicator.I try do to it myself but end up by bugging my platform,for now I need more practice.
    A outside bar is just high0 >high1 and low0<low1
    Can I have some help to where I have to make changes for that works please
    Thx for any help

    the code is :

    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class InsideBarforJA : Indicator
    {

    /// <summary>
    ///Indicator will paint an inside bar RoyalBlue
    /// </summary>
    ///

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Paints an InsideBar ";
    Name = "InsideBarforJA";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    AddPlot(Brushes.Transparent, "InsideBarFound");
    BarColor = Brushes.RoyalBlue;
    }

    }

    protected override void OnBarUpdate()
    {
    if(CurrentBar<2) return;

    if(High[0]<High[1] && Low[0]>Low[1])
    {
    BarBrush = BarColor;
    InsideBarFound[0] = 1;
    }
    else
    InsideBarFound[0] = 0;

    }

    #region Properties

    [XmlIgnore()]
    [Browsable(false)]
    public Series<double> InsideBarFound
    {
    get {return Values[0];}
    }

    [XmlIgnore()]
    [Display(Name = "BorderBrush", GroupName = "NinjaScriptParameters", Order = 0)]
    public Brush BarColor
    { get; set; }

    // Serialize our Color object
    [Browsable(false)]
    public string BarColorSerialize
    {
    get { return Serialize.BrushToString(BarColor); }
    set { BarColor = Serialize.StringToBrush(value); }
    }
    #endregion
    }
    }

    #region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private InsideBarforJA[] cacheInsideBarforJA;
    public InsideBarforJA InsideBarforJA()
    {
    return InsideBarforJA(Input);
    }

    public InsideBarforJA InsideBarforJA(ISeries<double> input)
    {
    if (cacheInsideBarforJA != null)
    for (int idx = 0; idx < cacheInsideBarforJA.Length; idx++)
    if (cacheInsideBarforJA[idx] != null && cacheInsideBarforJA[idx].EqualsInput(input))
    return cacheInsideBarforJA[idx];
    return CacheIndicator<InsideBarforJA>(new InsideBarforJA(), input, ref cacheInsideBarforJA);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.InsideBarforJA InsideBarforJA()
    {
    return indicator.InsideBarforJA(Input);
    }

    public Indicators.InsideBarforJA InsideBarforJA(ISeries<double> input )
    {
    return indicator.InsideBarforJA(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.InsideBarforJA InsideBarforJA()
    {
    return indicator.InsideBarforJA(Input);
    }

    public Indicators.InsideBarforJA InsideBarforJA(ISeries<double> input )
    {
    return indicator.InsideBarforJA(input);
    }
    }
    }

    #endregion

    Attached Files

    #2
    Hi janio973, thanks for posting. I tested the indicator and it is painting bars a different color. Is there a specific issue you wanted to resolve with this script?

    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      If you just want to have it paint blue and an outside bar just flip the < to > if(High[0]<High[1] && Low[0]>Low[1]) so like this... if(High[0]>High[1] && Low[0]<Low[1])



      But if you want something much better like have it paint green for outside up and red for outside down copy paste below.

      This one is for an OutSideUp bar and you can paint it a darker green to stand apart from normal bull bars:

      if(Close[0]>=Open[0] && High[0]>=High[1] && Low[0]<=Low[1])



      This one is for an OutSideDown bar and you can paint it a darker red to stand apart from normal bear bars:

      if(Close[0]<=Open[0] && High[0]>=High[1] && Low[0]<=Low[1])


      This one is for InSideDown bar:

      if(Close[0]<=Open[0] && Close[0]>=Low[1] && Open[0]<=High[1])

      This one for InSideUp bar:


      if(Close[0]>=Open[0] && Close[0]<=High[1] && Open[0]>=Low[1])

      Now these bars are what is known as a variant inside outside bars, the real bodies of the candles are the one's that are inside or outside so the tails will may will be beyond the previous candle.
      Say then, if you rather have the entire candle including the H & L inside / outside just change the word from Close to High and Open to Low


      if(High[0]>=(Low[0] && for each one. But it's actually better to see the candles body verses the entire candles H & L within a prev candle. When u start to see those variant candles consolidation could be starting then when you get a breakout candle it will be a regular color so it stands out. Place a stop entry & go !
      Attached Files

      Comment


        #4
        hello NinjaTrader_ChrisL ,no there is no problem,I am just looking for make changes to this indicator as I say above.Instead of inside bar I want it to become a outside bar indicator. Anyways thanks for your attention.
        Hello
        trdninstyle that is what I was looking for ,thanks for the help and the great update \o/ ,going to test this right now

        Comment


          #5
          Hello janio973,

          Anyone that knows how to read could see that you just wanted to flip from inside to outside. And I'm like, ya, I know how to do that.

          Honestly, I think these support guys must read over our questions so fast that they miss the question? They are helping hundreds of poor saps that don't know jack about C Script! I'll give them that, but they suck when it comes to actually helping you, other than giving u stuff to read so u can figure it out on your own lol. Unless you already have a PHD in C Script they move you along saying "Sorry we're helping other ppl that are more advanced, here u go, go learn more so we can help you"

          I mean go back and read the dudes response to your question, they either do this stuff on purpose or their idiots! It's comical. When u get a support person that is worth their salt you need to keep his/her name and stick w/ that person otherwise u end up frustrated. They might be able to write code in their sleep but doesn't mean they can comprehend your question correctly.

          Anyway, I haven't figured out how to place two functions on one application, so I don't have to end up with 4 indicators. I need to tell the program to do two separate things, either & or and it's just a matter of laying it out. Will they tell me? Big fat No lol but will give me riddles instead and eventually something to read & tell me they need to help other more advance coders. Your basically on your own until you get good at it unless someone like me just steps up and just shows you.

          Somehow you can put a InSideUp and a OutSideUp on one indicator, both being Up because there the same color. And same for Inside / Outside Down. And have only two indicators not four. You can have all 4 functions on one indicator, but I don't have a degree in C script. Now some other struggling retail trader like us sees this and is more advance in code, decides to show us then we can learn and get what were actually wanting.

          Comment


            #6
            yeah bro ,
            sometimes it's really difficult, but fortunately there are always people like you,who give a hand in the community,
            sometimes the staff people are cool too, it depends on the day, I don't know...
            throw a look, I managed to make the outside indicator, now I have my inside and outside quietly, thank you again
            Attached Files

            Comment


              #7
              Looks pretty good. Let's see how this works I imported all 4 indicators then u can open up the code and just copy/paste or just use these indicators, make adjustments to your own liking with colors and stuff.

              If the import doesn't work, then I'll do one at a time. Just let me kno bra. I saw a nice buy stop entry just above that blue inside bar right after the 2 big bear bars from your pic... money.
              And some other ones, I placed a Green Line one tick above them. Do u know how to average your trades after they move against you? To get out breakeven on the loser and profit on the 2nd one.


              In case it didnt work here's InSideDown

              if(Close[0]<=Open[0] && Close[0]>=Low[1] && Open[0]<=High[1])

              InSideUp

              if(Close[0]>=Open[0] && Close[0]<=High[1] && Open[0]>=Low[1])
              Attached Files

              Comment


                #8
                I forgot to mention. Why the importance of the real body inside vs the whole candle inside, help u to understand what's behind the reasoning.

                The open & close is a settled issue and the H & L (Wicks or tails) of that same time frame is negotiation. It's more important of what got settled.

                Pay attention to how long a price bar stays in an upper area or lower area during its duration (say) 5-minute bar, making it appear as a bull bar then in the last 30 seconds slams down into a bear bar trapping eager bulls! You sell that bear at close while those bull's panic. Considering the context of course.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by PaulMohn, Today, 12:36 PM
                2 responses
                16 views
                0 likes
                Last Post PaulMohn  
                Started by Conceptzx, 10-11-2022, 06:38 AM
                2 responses
                53 views
                0 likes
                Last Post PhillT
                by PhillT
                 
                Started by Kaledus, Today, 01:29 PM
                0 responses
                4 views
                0 likes
                Last Post Kaledus
                by Kaledus
                 
                Started by yertle, Yesterday, 08:38 AM
                8 responses
                37 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Started by rdtdale, Today, 01:02 PM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X