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

rising/falling volume

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

    rising/falling volume

    hi
    anyone can write indicator rising/falling volume?

    THANKS

    #2
    Hello Jonson,

    Thank you for your note.

    The Rising and Falling for Volume would look similar to the code below. What plots are you looking for from the indicator?
    Code:
    			if(Rising(Volume))
    			{
    				
    			}
    			if(Falling(Volume))
    			{
    				
    			}

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello Jonson,

      Thank you for your note.

      The Rising and Falling for Volume would look similar to the code below. What plots are you looking for from the indicator?
      Code:
      			if(Rising(Volume))
      			{
      				
      			}
      			if(Falling(Volume))
      			{
      				
      			}
      hello Patrick
      i use volumeupdown, help me set this indicator for rising/falling volume
      thanks

      Comment


        #4
        somebody can help to make this indicator?
        thanks

        Comment


          #5
          Hello Jonson,

          Thank you for your response.

          So you want the VolumeUpDown to plot the values based on Rising or Falling volume rather than the current if(Close[0] > Open[0])?

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello Jonson,

            Thank you for your response.

            So you want the VolumeUpDown to plot the values based on Rising or Falling volume rather than the current if(Close[0] > Open[0])?
            yeah, colors based on volume not a price

            Comment


              #7
              Hello,

              Attached is the VolumeUpDown based on Rising or Falling volume title VolumeRiseFall. Please download to your desktop and then import via File > Utilities > Import NinjaScript.
              Attached Files

              Comment


                #8
                hi PatrickH
                I can not make a similar code indicator to NT8
                you can help me to realize this indicator for NT8?

                thanks for help

                Comment


                  #9
                  Hello Jonson,

                  Thank you for your post.

                  What items are you stuck on in your conversion?

                  I recommend using the 'Code Breaking Changes' page and it's search function to find the NinjaTrader 8 code needed. Please visit the following link for the 'Code Breaking Changes': https://ninjatrader.com/support/help...ng_changes.htm

                  Some of the items you will need are the following:
                  Please let me know if you have any questions.

                  Comment


                    #10
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello Jonson,

                    Thank you for your post.

                    What items are you stuck on in your conversion?

                    I recommend using the 'Code Breaking Changes' page and it's search function to find the NinjaTrader 8 code needed. Please visit the following link for the 'Code Breaking Changes': https://ninjatrader.com/support/help...ng_changes.htm

                    Some of the items you will need are the following:
                    Please let me know if you have any questions.
                    hi
                    unfortunately I could not understand how to make an indicator for myself, you can help me realize it?

                    Comment


                      #11
                      Hello Jonson,

                      Thanks for the reply.

                      Attached is the NT8 version of this indicator.

                      If you wish to learn more about NinjaScript, reading through the educational resources linked below is a good starting point.



                      Please let us know if we may be of any further assistance.
                      Attached Files
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        ChrisL,

                        if i wanted to add a simple moving average to this current indicator so that if volume exceeded this average by "X" percent .... it would also paint a separate color or a dot above the volume ...

                        for example if i used a 1 MA and previous volume was 100 ... and i chose 200% ... then when current bars volume exceeded the 100 volume by 200% or greater it would paint this histogram a different color or put a dot above volume.

                        i have tried overlaying moving average envelopes over volume to configure something similar but due to the other side of the envelope is below zero it doesnt plot correctly.

                        any help appreciated
                        thanks

                        Comment


                          #13
                          Hello chinapassage,

                          Thanks for the post.

                          Note the additional constructor that is available for the SMA class:

                          SMA(ISeries<double> input, int period)

                          https://ninjatrader.com/support/help...simple_sma.htm - SMA()

                          You can pass in the indicator's Values[] array as the series to tell the SMA to take the moving average of the volume series. Once you have that value, do your calculation as you normally would.

                          The following line will get the current 14 period SMA value for the UpVolume series :

                          Code:
                          double val = SMA(Values[0], 14)[0];
                          
                          if(val >= *x% of some number*)
                          {
                              //Do something;
                          }
                          Please let us know if you have any questions.
                          Chris L.NinjaTrader Customer Service

                          Comment


                            #14
                            thanks for the link... read through it ... tried to add to the code line 70-78 ...getting lots of errors... here is the code:

                            Code:
                            #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 VolumeRiseFallNT8 : Indicator
                            	{
                            		protected override void OnStateChange()
                            		{
                            			if (State == State.SetDefaults)
                            			{
                            				Description									= @"Variation of the VOL (Volume) indicator that colors the volume histogram different color depending if the current bar is up or down bar";
                            				Name										= "VolumeRiseFallNT8";
                            				Calculate									= Calculate.OnBarClose;
                            				IsOverlay									= false;
                            				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(new Stroke(Brushes.Lime), PlotStyle.Bar, "UpVolume");
                            				AddPlot(new Stroke(Brushes.Red), PlotStyle.Bar, "DownVolume");
                            				AddLine(Brushes.DarkGray, 0, "Zero Line");
                            			}
                            			else if (State == State.Configure)
                            			{
                            			}
                            			
                            		}
                            
                            		protected override void OnBarUpdate()
                            		{
                            			if (IsRising(Volume))
                            			{
                            				Values[0][0] = (Volume[0]);
                            				Values[1].Reset();
                            			}
                            			else
                            			{
                            				Values[1][0] = (Volume[0]);
                            				Values[0].Reset();
                            			}
                            		}
                            	}
                            }
                            {double val = SMA(Values[0], 14)[0];
                            
                            if(val >= *x% of some number*)
                            {
                                //Do something; //
                            	AddPlot(new Stroke(Brushes.cyan), PlotStyle.Bar, "UpVolume");}
                            }
                            
                            #region NinjaScript generated code. Neither change nor remove.
                            
                            namespace NinjaTrader.NinjaScript.Indicators
                            {
                            	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                            	{
                            		private VolumeRiseFallNT8[] cacheVolumeRiseFallNT8;
                            		public VolumeRiseFallNT8 VolumeRiseFallNT8()
                            		{
                            			return VolumeRiseFallNT8(Input);
                            		}
                            
                            		public VolumeRiseFallNT8 VolumeRiseFallNT8(ISeries<double> input)
                            		{
                            			if (cacheVolumeRiseFallNT8 != null)
                            				for (int idx = 0; idx < cacheVolumeRiseFallNT8.Length; idx++)
                            					if (cacheVolumeRiseFallNT8[idx] != null &&  cacheVolumeRiseFallNT8[idx].EqualsInput(input))
                            						return cacheVolumeRiseFallNT8[idx];
                            			return CacheIndicator<VolumeRiseFallNT8>(new VolumeRiseFallNT8(), input, ref cacheVolumeRiseFallNT8);
                            		}
                            	}
                            }
                            
                            namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                            {
                            	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                            	{
                            		public Indicators.VolumeRiseFallNT8 VolumeRiseFallNT8()
                            		{
                            			return indicator.VolumeRiseFallNT8(Input);
                            		}
                            
                            		public Indicators.VolumeRiseFallNT8 VolumeRiseFallNT8(ISeries<double> input )
                            		{
                            			return indicator.VolumeRiseFallNT8(input);
                            		}
                            	}
                            }
                            
                            namespace NinjaTrader.NinjaScript.Strategies
                            {
                            	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                            	{
                            		public Indicators.VolumeRiseFallNT8 VolumeRiseFallNT8()
                            		{
                            			return indicator.VolumeRiseFallNT8(Input);
                            		}
                            
                            		public Indicators.VolumeRiseFallNT8 VolumeRiseFallNT8(ISeries<double> input )
                            		{
                            			return indicator.VolumeRiseFallNT8(input);
                            		}
                            	}
                            }
                            
                            #endregion

                            any ideas where i am inserting this in the wrong place?
                            thank you

                            Comment


                              #15
                              Hello chinapassage,

                              Thanks for the reply.

                              I provided a quasi-pseudocode example. I am assuming some level of experience with C# for this example.

                              This part, in particular, is not C# code: *x% of some number*

                              If you replace the OnBarUpdate method from the previously attached script with the OnBarUpdate posted below, you will see dots drawn above where the 14 period SMA of those bars is greater than 90% of the bar's value at that time.

                              Code:
                              protected override void OnBarUpdate()
                              		{
                              			if (IsRising(Volume))
                              			{
                              				Values[0][0] = (Volume[0]);
                              				Values[1].Reset();
                              			}
                              			else
                              			{
                              				Values[1][0] = (Volume[0]);
                              				Values[0].Reset();
                              			}
                              			
                              			var percentile = Values[0][0] * .9;
                              			
                              			if((SMA(Values[0], 14)[0] > Values[0][0]+percentile) && (Values[0].IsValidDataPoint(0)))
                              			{
                              				Draw.Dot(this,"Signal" + CurrentBar, true, 0, Values[0][0]+100, Brushes.Red);
                              			}
                              		}
                              Please let me know if you have questions.
                              Last edited by NinjaTrader_ChrisL; 07-06-2018, 09:37 AM. Reason: Changed High[0]+TickSize*2 to Values[0][0]+100 to fit better
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Started by usazencortex, Today, 12:43 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post usazencortex  
                              Working...
                              X