Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Today's volume larger than highest down volume day in 10 days

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

    Today's volume larger than highest down volume day in 10 days

    In my strategy, i would like to include the following condition: Today's volume is larger than the highest down volume day over the prior 10 days. Up volume days should not be considered. In my code below i do the inverse way, so i'm searching for a potential higher down volume day than today's volume.

    bool isVolumeHigher = false;
    for (int i = 1; i < 10; i++)
    {
    if (Close[i] < Open[i] && Volume[0] < Volume[i])
    isVolumeHigher = false;
    else
    isVolumeHigher = true;

    if (isVolumeHigher == true)
    break;
    }

    Thanks...

    #2
    Hello Sweet&Sour,
    Thanks for your post.

    When you reference the volume on a down day- would you like to reference what the bid volume is or the total volume for that down day?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      No Bid or Ask dependancy.

      Once the close of the price is less than the previous day, the vol of this day will be a "negative vol day".

      Comment


        #4
        Hello Sweet&Sour,

        You could do this without a loop by storing the volume values in a custom series and then comparing that to the previous 10 down values. Something similar to the following snippet would store a "0" in the custom series on all up volume days and then store the current volume on down volume days. This eliminates up volumes days and allows you to compare the 10 highest values over a period of 10.

        Code:
        private Series<double> MyDownVolSeries;
        protected override void OnStateChange()
        {
        	else if (State == State.DataLoaded)
        	{
        		MyDownVolSeries = new Series<double>(this);
        	}
        }
        protected override void OnBarUpdate()
        {
        	if (Close[0] > Open[0])
        		MyDownVolSeries[0] = 0;
        	
        	else if (Close[0] < Open[0])
        	{
        		MyDownVolSeries[0] = Volume[0];		
        		int highestBar = HighestBar(MyDownVolSeries,10);
        		double highestVolume = Volume[highestBar];
        		
        		if (Volume[0] >= highestVolume)
        		{
        			//today is the highest down volume day in the last 10 days
        		}
        	}
        }

        Help Guide-- Series<T>

        Help Guide-- HighestBar()

        Please let me know if you have any questions.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,

          Thanks for the snippet. Will have a look on it in the next few days.

          Krgds...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          56 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          132 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X