SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Sep 26, 2020 6:28 pm

All times are UTC + 3 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Question about indicator
PostPosted: Wed Sep 08, 2010 8:10 pm 

Joined: Sat Jul 24, 2004 12:40 am
Posts: 77
Location: Odessa, Florida
Hello all,
I am trying to implement something simple, yet am not quite sure about how to go about it.
Here is my problem.
I am computing the average true range over a period N by using the following where bs is some BarSeries
OpenQuant.API.Indicators.ATR avgTR = new OpenQuant.API.Indicators.ATR(bs, N);

I now wish to take this indicator (avgTR) and multiply it by a factor F and compute a moving average of the product (avgTR * F) over some period P, where P < N
In other words I wish to have an indicator which will give me
OpenQuant.API.Indicators.SMA  avgOfavgTRF = new OpenQuant.API.Indicators.SMA(avgTR * F, P);

I know how to get avgTR as simply being:
 avgTR = Indicators.ATR(bs,N)

But I am stuck on figuring out how to make a Simple Moving Average (SMA) of an already existing indicator (avgTR) that needs to be multiplied by a number F.
If I had simply wanted the Simple Moving Average of avgTR over a period P, things would have been easy as I would simply had written
Indicators.SMA avgOfavgTR = new Indicators.SMA(avgTR,P);

But I want the moving average of another moving average that is multiplied by a factor and I know that
Indicators.SMA avgOfavgTRF = new Indicators.SMA(avgTR * F,P);

Would be a syntax error.
Does any one have a way to do this?

Thank you in advance

 Post subject:
PostPosted: Thu Sep 09, 2010 12:55 pm 

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817

one possibility is to write a simple custom indicator that multiplies input by a number. Then you can create indicator from indicator construction right in the OnStrategyStart.

Or alternatively you can create a time series in OnStrategyStart, use this series as SMA input and then add entries to this time series in OnBar

series.Add(bar.DateTime, atr * F)

Do you see what I mean?


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours

Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group