Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Capturing daily volume SMA onto 3 minute chart

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

    Capturing daily volume SMA onto 3 minute chart

    Hi guys,
    I have a query. I would like to extract daily average volume and use it in Ninja script which runs on 3 minute chart. Right now I have added Add(PeriodType.Day,1); as my secondary data series with barsinprogress index as 1.

    Following is the code for the initialize() function :

    Code:
    protected override void Initialize()
            {
                CalculateOnBarClose = false;
    			stopLossPercent = 0.15;
    			Add(PeriodType.Day,1); 
    			Add(PeriodType.Minute,1); 
    			[B]averageDailyVolume = SMA(Volumes[1],20);[/B]
    			slowMovingAverage = SMA(Closes[0],slowmovingaverage);
    			maEnvelopes = MAEnvelopes(Closes[0],envelopeoffset,3,envelopemovingaverage);					
    			SetStopLoss(CalculationMode.Percent,stopLossPercent);
    		}
    Now inside my OnBarUpdate() function, I am comparing this average volume with a thresholdVolume value of 2 million shares. But for some reason, I don't seem to get the correct values for averageDailyVolume[1] and "if conditions" don't execute as averageDailyVolume[1] values are below 2 million shares which is not correct as my Esignal data feed gives correct values of daily volumes for stock NUAN and they almost always run into million shares a day.

    Code :

    Code:
    protected override void OnBarUpdate()
            {
    			if (CurrentBars[1] < 20)
    				return;
    
    						
    			    if(nStatus == 0 && entryFlag == 0)
    				{
    					if(this.checkShortEntry())
    					{
    							[B]if(averageDailyVolume[1] >= thresholdVolume)[/B]
    							{
    								entryFlag = -1;
    							}
    					
    					}
    					else if(this.checkLongEntry())
    					{
    							[B]if(averageDailyVolume[1] >= thresholdVolume)[/B]
    							{
    								entryFlag = 1;
    							}
    					}
    				}
    }
    Can any one explain me why I am not getting correct values for the daily volume on 3 minutes chart. I urgently need to get this thing resolved. Please get back to me as soon as possible.

    Thanks and Regards,
    Vipin

    #2
    Hi Vipin_cpp,

    Thank you for posting.

    What kind of time interval chart are you running the script on?

    How many days to load to you have set?

    Do you receive any errors in the Log Tab in the Control Center?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hi Vipin_cpp,

      Thank you for posting.

      What kind of time interval chart are you running the script on?

      How many days to load to you have set?

      Do you receive any errors in the Log Tab in the Control Center?
      I am running it on 3 minute chart. I load 1500 days of 3 minutes data .No, I dont receive any error. Its just the values of averageVolume[1] I receive are not right.

      Comment


        #4
        Vipin,

        What values is the script printing and what values do you expect from eSignal?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Vipin,

          What values is the script printing and what values do you expect from eSignal?
          I am getting the most recent averageDailyVolume value in the range of 18-20K which is completely wrong. NUAN has more than a million shares of daily volume so in that case averageDailyVolume should be above 2 million shares. There is no issue with eSignal because when I ran the script on daily chart on Ninja Trader, I was getting correct values for averageDailyVolume. Its just I need to have those values on 3 minute time frame.

          Comment


            #6
            Originally posted by vipin_cpp View Post
            I am getting the most recent averageDailyVolume value in the range of 18-20K which is completely wrong. NUAN has more than a million shares of daily volume so in that case averageDailyVolume should be above 2 million shares. There is no issue with eSignal because when I ran the script on daily chart on Ninja Trader, I was getting correct values for averageDailyVolume. Its just I need to have those values on 3 minute time frame.
            Right now this (18861.7) is the averageDailyVolume value printed by Ninja's output console.
            9/11/2013 1:12:00 PM 18861.7

            9/11/2013 4:00:00 PM 18861.7

            9/11/2013 1:10:00 PM 18861.7

            9/11/2013 1:12:00 PM 18861.7

            9/11/2013 4:00:00 PM 18861.7

            9/11/2013 1:10:00 PM 18861.7

            9/11/2013 1:12:00 PM 18861.7

            9/11/2013 4:00:00 PM 18861.7

            9/11/2013 1:10:00 PM 18861.7

            9/11/2013 1:12:00 PM 18861.7

            9/11/2013 4:00:00 PM 18861.7

            9/11/2013 1:10:00 PM 18861.7

            9/11/2013 1:12:00 PM 18861.7

            9/11/2013 4:00:00 PM 18861.7
            Last edited by vipin_cpp; 09-11-2013, 11:22 AM.

            Comment


              #7
              Vipin,

              I have been testing this out on my end and found that I was able to get the correct values by having the CurrentBars check be < 1 and not 20.

              Additionally, I threw the averageDailyVolume in the OnBarUpdate() rather then the initialize.

              Code:
              if(CurrentBars[1] < 1)
              			return;
              				
              			averageDailyVolume = SMA(Volumes[1],20);
              			Print(averageDailyVolume[0]);
              Let me know if this works for you
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                Ahha that worked!!! Thank you so much.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by andrewtrades, Today, 04:57 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                6 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                7 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X