SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Feb 27, 2020 8:11 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: moving average on volume
PostPosted: Wed Apr 20, 2011 6:35 am 
Offline

Joined: Thu Jul 23, 2009 2:02 pm
Posts: 22
Hi, could you tell me how to take moving average on volume bar ? Thanks,C


Top
 Profile  
 
PostPosted: Wed Apr 20, 2011 7:43 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
Hi,

perhaps I am missing something in your question but you can just add volume bars in the market data folder of your solution and create SMA in your strategy as usual.

Regards,
Anton


Top
 Profile  
 
PostPosted: Wed Apr 20, 2011 9:56 pm 
Offline

Joined: Thu Jul 23, 2009 2:02 pm
Posts: 22
could anyone help me how to create moving average on 1 min volume bar ?
I added volume bars (Bars 60 vol) in the market data folder of my solution and create SMA in your strategy. But I don't see moving average on volume... And this just resets every 60 vol.
What I am trying to do is to calculate 10 bar volume moving average and draw line chart on on 1 min time frame volume window.

public class MyStrategy : Strategy
{
Instrument stock;

BarSeries pBar1;
BarSeries vBar1;

public override void OnStrategyStart()
{

stock = InstrumentManager.Instruments["ES ESM1"];
tBars1 = GetBars(stock,BarType.Time,60);
vBars1 = GetBars(stock,BarType.Volume,60); <--- this just resets at every 60 volume.

SMA sma_pbar = new SMA(pBars1,10);
sma_price.Color = Color.White;
Draw(sma_price,0);

SMA sma_vol = new SMA(vBars1,10);
sma_vol.Color = Color.White;
Draw(sma_vol,1);
}


Top
 Profile  
 
PostPosted: Fri Apr 22, 2011 4:23 am 
Offline

Joined: Thu Jul 23, 2009 2:02 pm
Posts: 22
Hi, Does anyone know how to create a moving average on bar volume ? Thanks


Top
 Profile  
 
PostPosted: Fri Apr 22, 2011 11:37 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

Do you see the SMA line on the BarChart when Volume bars are displayed?

I have tried to run a test strategy on built-in MSFT trades, adding two market data requests (Bars 10 min and Bars 6000 vol):
Quote:
public class MyStrategy : Strategy
{
public override void OnStrategyStart()
{
BarSeries timeBars = GetBars(BarType.Time, 600);
BarSeries volBars = GetBars(BarType.Volume, 6000);

SMA sma1 = new SMA(timeBars, 14);
sma1.Color = Color.Red;
Draw(sma1, 0);

SMA sma2 = new SMA(volBars, 14);
sma2.Color = Color.Green;
Draw(sma2, 0);
}
}


Both red and green lines are visible on the BarChart when 10 Min bar series is displayed.

In fact it is not a good idea to view indicators created from one bar type on the BarChart displaying another bar type series. The problem is that the Chart defines a "grid" intenally, each bar is one point of this grid. Only those elements of indicators that exactly fit to this grid are visible on the Chart. One solution could be:
- create a temporary series and draw it in OnStrategyStart:
- in OnBar method check that the "bar" parameter is a Time bar and put the latest value of the volume SMA to this temp series with the current bar timestamp.

Regards,
Sergey.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group