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

Order Flow Cumulative Delta Candles Colours Chart

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

    Order Flow Cumulative Delta Candles Colours Chart

    Hello, thank you for the help in the last post. I hope i can recieve the help for this too.

    Im Using the "Order Flow Cumulative Delta" Indicator, and i want when OFCD close BEARISH, and Price Chart close BULLISH, that candle at Price Chart print in a Green Colour (or the colour that the user select).

    If OFCD close BULLISH, and Price Chart close BEARISH. That Candle at Price Chart print in a Red Colour (or the Colour that the user select).

    Thank you!

    #2
    Hello contrax,

    Thanks for your post.

    A bearish close of the OFCD would be defined as when the OFCD bar close is less than the Open. A price bar bullish would be when the Close is Greater than the Open. When those conditions are true you would use the BarBrush method to paint the price bar the color of your choice.

    The opposite of course for the opposite direction.

    References:



    Here is an example following the example of "Calling the OrderFlowCumulativeDelta() method by reference" in the above link:

    if (Close[0] >Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) // Price close >open (bullish) and OFCDClose < OFCDOpen (Bearish)
    {
    BarsBrush = Brushes.Green; // color the price bar green.
    }


    If you use the Ninjascript wizard>indicator to create the indicator structure, you will have the opportunity to add a color inputs that will allow you to set the colors used for the bars. Here is a link to the Ninjascript wizard: https://ninjatrader.com/support/help...?ns_wizard.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello contrax,

      Thanks for your post.

      A bearish close of the OFCD would be defined as when the OFCD bar close is less than the Open. A price bar bullish would be when the Close is Greater than the Open. When those conditions are true you would use the BarBrush method to paint the price bar the color of your choice.

      The opposite of course for the opposite direction.

      References:



      Here is an example following the example of "Calling the OrderFlowCumulativeDelta() method by reference" in the above link:

      if (Close[0] >Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) // Price close >open (bullish) and OFCDClose < OFCDOpen (Bearish)
      {
      BarsBrush = Brushes.Green; // color the price bar green.
      }


      If you use the Ninjascript wizard>indicator to create the indicator structure, you will have the opportunity to add a color inputs that will allow you to set the colors used for the bars. Here is a link to the Ninjascript wizard: https://ninjatrader.com/support/help...?ns_wizard.htm

      Thank you.. Thats looklike easy. Already tried to do this but nothing... Im going to read again and try to do it once again.

      Comment


        #4
        Originally posted by NinjaTrader_PaulH View Post
        Hello contrax,

        Thanks for your post.

        A bearish close of the OFCD would be defined as when the OFCD bar close is less than the Open. A price bar bullish would be when the Close is Greater than the Open. When those conditions are true you would use the BarBrush method to paint the price bar the color of your choice.

        The opposite of course for the opposite direction.

        References:



        Here is an example following the example of "Calling the OrderFlowCumulativeDelta() method by reference" in the above link:

        if (Close[0] >Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) // Price close >open (bullish) and OFCDClose < OFCDOpen (Bearish)
        {
        BarsBrush = Brushes.Green; // color the price bar green.
        }


        If you use the Ninjascript wizard>indicator to create the indicator structure, you will have the opportunity to add a color inputs that will allow you to set the colors used for the bars. Here is a link to the Ninjascript wizard: https://ninjatrader.com/support/help...?ns_wizard.htm

        Hello Paul, if is possible, can u help me with this? I already tried but nothing.... if not is ok, more later with a fresh head im going to try again.

        Comment


          #5
          Hello contrax,

          Thanks for your reply.

          I would suggest creating the indicator using the indicator wizard as this will get the basic structure including your color inputs.

          After you have created as much as you can in the wizard then i would copy in the example shown in "Calling the OrderFlowCumulativeDelta() method by reference" at this link: https://ninjatrader.com/support/help...ive_delta2.htm

          In the section that shows: If(BarsInProgress == 0) I would place all your code similar to:

          f (Close[0] >Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) // Price close >open (bullish) and OFCDClose < OFCDOpen (Bearish)
          {
          BarsBrush = Brushes.Green; // color the price bar green.
          }


          You will have to write the section for the opposite condition and you'll have to replace the Brushes.Green with the color input variable.



          Alternately, if you would like it created for you, we can provide references to 3rd party programmers.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Hey. It is like this. Clean and simple.

            Code:
                public class OFCDBarDiff : Indicator
                {
                    private OrderFlowCumulativeDelta cumulativeDelta;
                    protected override void OnStateChange()
                    {
                        if (State == State.SetDefaults)
                        {
                            Description                                    = @"OFCDBarDiff";
                            Name                                        = "OFCDBarDiff";
                            Calculate                                    = Calculate.OnBarClose;
                            IsOverlay                                    = true;
                            IsAutoScale                                    = false;
                            IsAutoScale                                    = true;
                            DisplayInDataBox                            = true;
                            DrawOnPricePanel                            = false;
                            DrawHorizontalGridLines                        = false;
                            DrawVerticalGridLines                        = false;
                            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;
                        }
                        else if (State == State.Configure)
                        {
                            AddDataSeries(Data.BarsPeriodType.Tick, 1);
                        } else if (State == State.DataLoaded) {
                            cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0);
                        }
                    }
            
                    protected override void OnBarUpdate()
                    {
                        if (BarsInProgress == 0) {
                            if (Close[0] > Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) {
                                HighlightBar(Brushes.Lime);
                            }
                            if (Close[0] < Open[0] && cumulativeDelta.DeltaClose[0] > cumulativeDelta.DeltaOpen[0]) {
                                HighlightBar(Brushes.Red);
                            }
                        } else if (BarsInProgress == 1)    {
                            cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                        }
                    }
            
                    protected void HighlightBar(Brush barColor, double opacity = 1.0, int barsAgo = 0) {
                        if (Close[0] < Open[0]) {
                            Brush ColorWithOpacity = barColor.Clone();
                            ColorWithOpacity.Opacity = opacity;
                            ColorWithOpacity.Freeze();
                            BarBrushes[barsAgo] = ColorWithOpacity;
                        }
                        Brush HighlightCandleOutlineBrushWithOpacity = barColor.Clone();
                        HighlightCandleOutlineBrushWithOpacity.Opacity = opacity;
                        HighlightCandleOutlineBrushWithOpacity.Freeze();
                        CandleOutlineBrushes[barsAgo] = HighlightCandleOutlineBrushWithOpacity;
                    }
            Attached Files

            Comment


              #7
              Originally posted by Gorkhaan View Post
              Hey. It is like this. Clean and simple.

              Code:
              public class OFCDBarDiff : Indicator
              {
              private OrderFlowCumulativeDelta cumulativeDelta;
              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              Description = @"OFCDBarDiff";
              Name = "OFCDBarDiff";
              Calculate = Calculate.OnBarClose;
              IsOverlay = true;
              IsAutoScale = false;
              IsAutoScale = true;
              DisplayInDataBox = true;
              DrawOnPricePanel = false;
              DrawHorizontalGridLines = false;
              DrawVerticalGridLines = false;
              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;
              }
              else if (State == State.Configure)
              {
              AddDataSeries(Data.BarsPeriodType.Tick, 1);
              } else if (State == State.DataLoaded) {
              cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Session, 0);
              }
              }
              
              protected override void OnBarUpdate()
              {
              if (BarsInProgress == 0) {
              if (Close[0] > Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) {
              HighlightBar(Brushes.Lime);
              }
              if (Close[0] < Open[0] && cumulativeDelta.DeltaClose[0] > cumulativeDelta.DeltaOpen[0]) {
              HighlightBar(Brushes.Red);
              }
              } else if (BarsInProgress == 1) {
              cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
              }
              }
              
              protected void HighlightBar(Brush barColor, double opacity = 1.0, int barsAgo = 0) {
              if (Close[0] < Open[0]) {
              Brush ColorWithOpacity = barColor.Clone();
              ColorWithOpacity.Opacity = opacity;
              ColorWithOpacity.Freeze();
              BarBrushes[barsAgo] = ColorWithOpacity;
              }
              Brush HighlightCandleOutlineBrushWithOpacity = barColor.Clone();
              HighlightCandleOutlineBrushWithOpacity.Opacity = opacity;
              HighlightCandleOutlineBrushWithOpacity.Freeze();
              CandleOutlineBrushes[barsAgo] = HighlightCandleOutlineBrushWithOpacity;
              }

              Hello, thank you for ur reply Gorkhaan. I just add the Indicator and i see the Red Candles Painted but is not correct.

              I mean:

              OFCD Panel, Normally the Candle colours is, Bullish -close above of the open- green colour. Bearish -close bellow of the open- Red Colour.

              In my Price Data Chart, Normally the Candle Colour is, Bullish White and Bearish Black.


              When OFCD Close Bearish Red, and Price Data Chart close Bullish White. Then the Indicator is going to paint in a Green Colour in the Price Data Chart.

              *

              When OFCD Close Bullish Green, and Price Data Chart close Bearish Black. Then the Indicator is going to paint in a Red Colour in the Price Data Chart.


              -------------------

              The Indicator only plots in one direction i think. Can u help me with that? Thank you!

              Comment


                #8
                Oh i see the Green Candle Painted by ur Indicator, is Painted only "OutLine" of the Candle.

                Comment


                  #9
                  Hey.

                  Programatically it is correct. If the logic is not what you want, change the "<" and ">" around.
                  Add colors to your liking. All colors are under:
                  Code:
                  Brushes.
                  Indeed I do paint the outline of the candles, otherwise it would look weird. I use DimGray color for my candles. With DimGray, it looks great for me.

                  Best,

                  G.

                  Comment


                    #10
                    Originally posted by Gorkhaan View Post
                    Hey.

                    Programatically it is correct. If the logic is not what you want, change the "<" and ">" around.
                    Add colors to your liking. All colors are under:
                    Code:
                    Brushes.
                    Indeed I do paint the outline of the candles, otherwise it would look weird. I use DimGray color for my candles. With DimGray, it looks great for me.

                    Best,

                    G.


                    Yes for change the colour is in:
                    ************************************************** ******


                    protected override void OnBarUpdate()
                    {
                    if (BarsInProgress == 0) {
                    if (Close[0] > Open[0] && cumulativeDelta.DeltaClose[0] < cumulativeDelta.DeltaOpen[0]) {
                    HighlightBar(Brushes.Lime);
                    }
                    if (Close[0] < Open[0] && cumulativeDelta.DeltaClose[0] > cumulativeDelta.DeltaOpen[0]) {
                    HighlightBar(Brushes.Red);
                    }
                    } else if (BarsInProgress == 1) {
                    cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                    }
                    }


                    ************************************************** **********

                    Already testing change things but still the same, i mean.

                    The Red Bar, is a full printed Red Bar. Outline Red, And inside the candle Red Body, Full Red.


                    The Lime Bar, is only the OutLine Lime Colour without body colour. Im trying to figured out where is that for i start changing on my own.



                    Click image for larger version  Name:	Test.png Views:	1 Size:	48.1 KB ID:	1068754

                    Other Example of Red Candles with Body Colour, And Lime only Outline.

                    Click image for larger version

Name:	test2.png
Views:	830
Size:	48.8 KB
ID:	1068755 ​​​​​​​
                    Last edited by contrax; 08-27-2019, 09:14 AM.

                    Comment


                      #11
                      It is in HighlightBar function.

                      Change this
                      Code:
                      protected void HighlightBar(Brush barColor, double opacity = 1.0, int barsAgo = 0) {
                          if (Close[0] < Open[0]) {
                              Brush ColorWithOpacity = barColor.Clone();
                              ColorWithOpacity.Opacity = opacity;
                              ColorWithOpacity.Freeze();
                              BarBrushes[barsAgo] = ColorWithOpacity;
                          }
                          Brush HighlightCandleOutlineBrushWithOpacity = barColor.Clone();
                          HighlightCandleOutlineBrushWithOpacity.Opacity = opacity;
                          HighlightCandleOutlineBrushWithOpacity.Freeze();
                          CandleOutlineBrushes[barsAgo] = HighlightCandleOutlineBrushWithOpacity;
                      }
                      To this:
                      Code:
                      protected void HighlightBar(Brush barColor, double opacity = 1.0, int barsAgo = 0) {
                          //if (Close[0] < Open[0]) {
                              Brush ColorWithOpacity = barColor.Clone();
                              ColorWithOpacity.Opacity = opacity;
                              ColorWithOpacity.Freeze();
                              BarBrushes[barsAgo] = ColorWithOpacity;
                          //}
                          Brush HighlightCandleOutlineBrushWithOpacity = barColor.Clone();
                          HighlightCandleOutlineBrushWithOpacity.Opacity = opacity;
                          HighlightCandleOutlineBrushWithOpacity.Freeze();
                          CandleOutlineBrushes[barsAgo] = HighlightCandleOutlineBrushWithOpacity;
                      }
                      Experiment with it.

                      Best,

                      G.

                      Comment


                        #12
                        Originally posted by Gorkhaan View Post
                        It is in HighlightBar function.

                        Change this
                        Code:
                        protected void HighlightBar(Brush barColor, double opacity = 1.0, int barsAgo = 0) {
                        if (Close[0] < Open[0]) {
                        Brush ColorWithOpacity = barColor.Clone();
                        ColorWithOpacity.Opacity = opacity;
                        ColorWithOpacity.Freeze();
                        BarBrushes[barsAgo] = ColorWithOpacity;
                        }
                        Brush HighlightCandleOutlineBrushWithOpacity = barColor.Clone();
                        HighlightCandleOutlineBrushWithOpacity.Opacity = opacity;
                        HighlightCandleOutlineBrushWithOpacity.Freeze();
                        CandleOutlineBrushes[barsAgo] = HighlightCandleOutlineBrushWithOpacity;
                        }
                        To this:
                        Code:
                        protected void HighlightBar(Brush barColor, double opacity = 1.0, int barsAgo = 0) {
                        //if (Close[0] < Open[0]) {
                        Brush ColorWithOpacity = barColor.Clone();
                        ColorWithOpacity.Opacity = opacity;
                        ColorWithOpacity.Freeze();
                        BarBrushes[barsAgo] = ColorWithOpacity;
                        //}
                        Brush HighlightCandleOutlineBrushWithOpacity = barColor.Clone();
                        HighlightCandleOutlineBrushWithOpacity.Opacity = opacity;
                        HighlightCandleOutlineBrushWithOpacity.Freeze();
                        CandleOutlineBrushes[barsAgo] = HighlightCandleOutlineBrushWithOpacity;
                        }
                        Experiment with it.

                        Best,

                        G.

                        Thank you!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by helpwanted, Today, 03:06 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post helpwanted  
                        Started by Brevo, Today, 01:45 AM
                        0 responses
                        6 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
                        384 views
                        1 like
                        Last Post Gavini
                        by Gavini
                         
                        Working...
                        X