Any guidance would be helpful. Thanks.
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!
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
NinjaTrader
10 minute Rolling Volume
Collapse
X
-
10 minute Rolling Volume
I would like to code and indicator that calculates the last 10 minute Avg. Volume at close of bar, using UniRenko Bars. So it would be a Rolling 10 minute average (Using Calculate.OnIncomingTick). Can anybody lead me in the right direction with code, without using a MTF indicator.
Any guidance would be helpful. Thanks.Tags: None
-
Hello woodyfox,
Thanks for your post.
As you are using non time based bars your concept literally would be hit or miss regarding a 10 minute moving average without using another data series.
One approach would be to get the current bars close time and compare that to previous bars until you are equal (not likely) to 10 minutes or just over (most likely). Then using those bars between the current and the +10 minutes ago find the average volume over the number of bars between the current bar and the +10 minute ago bar. The issue here is if you have a bar that is like 9 minute and 30 seconds ago you would then use the next bar back but if that bar has a duration of 6 minutes, for example, your averaging would then be of a 15+ minute period. If you are using a large reversal bar setting the times could be even more skewed.
We can also keep this thread open for any forum members who would like to contribute other ideas or approaches.
To be clear, In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients.
If you would like this coded for you, we can provide reference links to 3rd party coders who can provide coding services.Paul H.NinjaTrader Customer Service
-
So the MTF approach would be more accurate?
Something like this...
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 1);
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < BarsRequiredToPlot)
return;
EV[0]= ((VOLMA(BarsArray[1], 10)[0])*10);
}
Thanks, Woody.
Comment
-
Paul,
Is it possible to use the BarsArray in Bars.GetVolume(barIndex);
This doesn't seem to work?
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 10);
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 0)
return;
EVA[0]= Bars.GetVolume(BarsArray[1],144);
}
Thanks, Woody.
Comment
-
Paul,
This doesn't seem to work either?
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 10);
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 0)
return;
if (BarsInProgress == 1)
{
EVA[0]= Bars.GetVolume(144);
}
}
Thanks, Woody.
Comment
-
Hello woodyfox,
Thanks for your replies.
Bars.GetVolume() would only provide the volume from the chart bars and not from the added dataseries.
In addition, you are not checking for an appropriate number of bars to have been processed before checking for the 144th bar of the added data series.
I'm not certain what you are trying to do in your last two posts but you may want to use the VOL() volume indicator set to the added data series. If you need the volume of a specific 10-minute bar, you can calculate the bars ago value or use VOL()[0] for the current 10 minute bar volume. reference: https://ninjatrader.com/support/help...us/?volume.htmPaul H.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Paul View PostHello woodyfox,
Thanks for your replies.
Bars.GetVolume() would only provide the volume from the chart bars and not from the added dataseries.
In addition, you are not checking for an appropriate number of bars to have been processed before checking for the 144th bar of the added data series.
I'm not certain what you are trying to do in your last two posts but you may want to use the VOL() volume indicator set to the added data series. If you need the volume of a specific 10-minute bar, you can calculate the bars ago value or use VOL()[0] for the current 10 minute bar volume. reference: https://ninjatrader.com/support/help...us/?volume.htm
if (CurrentBars[0] < ?) Not Sure?
Thanks in advance, Woody.
Comment
-
Hello woodyfox,
Thanks for your reply.
The conditional statement: if (CurrentBars[0] < 0) is checking to see if the chart bars (BarsArray[0]) are less than zero. In your previous posts, you wanted to check the 144th bar of the added data series. The added data series is BarsArray[1], so you would need to ensure that CurrentBars[1] is at least at bar 143. However, if you are only checking the current bar Volume then you would not need to check for 143 bars but would need to check for at least 1 bar.
Reference: https://ninjatrader.com/support/help...urrentbars.htmPaul H.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Paul View PostHello woodyfox,
Thanks for your reply.
The conditional statement: if (CurrentBars[0] < 0) is checking to see if the chart bars (BarsArray[0]) are less than zero. In your previous posts, you wanted to check the 144th bar of the added data series. The added data series is BarsArray[1], so you would need to ensure that CurrentBars[1] is at least at bar 143. However, if you are only checking the current bar Volume then you would not need to check for 143 bars but would need to check for at least 1 bar.
Reference: https://ninjatrader.com/support/help...urrentbars.htm
Since there are 144 10 minute bars in a day.
I tried...
AddPlot(new Stroke(Brushes.Blue, 1), PlotStyle.Line, "EVA");
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 10);
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[1] > 1)
return;
if (BarsInProgress == 1)
{
EVA[0]= (VOL()[144] + VOL()[288])/2;
}
}
Any suggestions would be helpful? Thanks, Woody.
Comment
-
Hello woodyfox,
Thanks for your reply.
Thanks for clarifying the ultimate goal here.
What I would suggest is using a simple moving average (SMA) of the Volume of the 10 minute bars. You can specify the average period you wish to use.
I've created an example and added it as a picture for your review. Please note that as you are plotting, you need to plot on BarsInProgress =0 and In the VOL() indicator I am pointing to BarsArray[1] (the 10 minute bars). I am using a 10 period SMA of the volume and this is why I am doing a CurrentBars[1] check against < 10 bars.Paul H.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Paul View PostHello woodyfox,
Thanks for your reply.
Thanks for clarifying the ultimate goal here.
What I would suggest is using a simple moving average (SMA) of the Volume of the 10 minute bars. You can specify the average period you wish to use.
I've created an example and added it as a picture for your review. Please note that as you are plotting, you need to plot on BarsInProgress =0 and In the VOL() indicator I am pointing to BarsArray[1] (the 10 minute bars). I am using a 10 period SMA of the volume and this is why I am doing a CurrentBars[1] check against < 10 bars.
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Second, 1);
}
}
protected override void OnRender(ChartControl chartControl, ChartScale
chartScale)
{
base.OnRender(chartControl, chartScale);
foreach (Plot plot in Plots)
{
// make the plots width match the chart style bar width
plot.Width = (float) 1.25*(chartControl.GetBarPaintWidth(ChartBars));
}
}
protected override void OnBarUpdate()
{
///if (State==State.Historical) { return;}
if (CurrentBars[0] < BarsRequiredToPlot)
return;
EV[0]= ((VOLMA(BarsArray[1], 600)[0])*600);
Now what I'm trying to accomplish is getting the average for the past n days for each certain ten minute plot. So 12:00 to 12:10 today, 12:00 to 12:10 yesterday, etc....
AddPlot(new Stroke(Brushes.Blue, 1), PlotStyle.Line, "EVA");
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 10);
}
}
protected override void OnBarUpdate()
{
///if (State==State.Historical) { return;}
if (CurrentBars[1] > 1)
return;
if (BarsInProgress == 1)
{
EVA[0]= (VOL()[144] + VOL()[288])/2;
}
}
I could then plot the two values on the chart. This would help me see if the rolling 10 minute volume is exceeding expectations at that certain 10 minute period.
Any suggestions, Thanks, Woody.
Comment
-
Hello woodyfox,
Thanks for your reply.
You might look at GetBar() where you specify the time and it returns the absolute bar number which you can then calculate the bars ago by subtracting the absolute bar number returned by GetBar() from the CurrentBar (as the example in the helpguide shows).
Reference: https://ninjatrader.com/support/help...us/?getbar.htmPaul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
5 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
8 responses
61 views
0 likes
|
Last Post Yesterday, 10:45 AM | ||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
4 responses
3,289 views
1 like
|
Last Post
by jgualdronc
Today, 10:02 AM
|
||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 09:55 AM | ||
Started by halgo_boulder, 04-20-2024, 08:44 AM
|
2 responses
24 views
0 likes
|
Last Post Today, 09:41 AM |
Comment