SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sun Sep 15, 2019 8:56 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Oct 30, 2013 11:23 am 
Offline

Joined: Wed Sep 18, 2013 10:50 am
Posts: 67
Location: London
Hi

Is there an in-built method that I can use to convert an Indicator Series(or a time series) into a BarSeries ?

I am writing my own PDI and MDI indicators and wanted to know how I can calculate PDI( & MDI) for Indicator Series(or any other time series)

Any help would be greatly appreciated.

Thanks in anticipation.

M


Top
 Profile  
 
PostPosted: Wed Oct 30, 2013 12:53 pm 
Offline

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

I am not sure why you need to convert a series or indicator into a BarSeries? If your indicators can be calculated only basing on a BarSeries - you should check that the input series is a BarSeries, otherwise they can not be calculated, or I missed something?

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Wed Oct 30, 2013 1:27 pm 
Offline

Joined: Wed Sep 18, 2013 10:50 am
Posts: 67
Location: London
Hi Sergey

Thanks for your reply.

I want to be able to calculate PDI on barSeries as well as IndicatorSeries because I want to use it as an Indicator of Indicators (Just like the in-built PDI in OpenQuant)

example:
////////////////////////////////////////////////////////////////////////////////
UserPDI pdi1;
UserPDI pdi2;

OnStrategyStart()
{
pdi1 = new UserPDI(Bars, period)
pdi2 = new UserPDI(pdi1, pediod) // This should work as well.
}
////////////////////////////////////////////////////////////////////////////////

This is what I am doing at the moment.

Code:
public class UserPDI : UserIndicator
{
   int period;
   BarSeries BarSer;
   TR tr;
   PDM pdm;
   
   public UserPDI(ISeries series, int period)
      : base(series)
   {
      this.period = period;
                               
      BarSer = Input as BarSeries;
      
      tr  = new TR(BarSer);
      pdm = new PDM(BarSer);
      
      this.Name = "UserPDI";
   }

   
   public override double Calculate(int index)
   {
      double pdi    = 0;
      double sumPDM = 0;
      double sumTR  = 0;
      
      int count = Math.Min(tr.Count,pdm.Count);
      
      if(count >= period)
      {            
         for (int i = (count-period+1); i < count; i++)
         {
            sumPDM += pdm[i];
            sumTR  += tr[i];
         }
      }
      
      if (sumTR != 0)
      {
         pdi = sumPDM/sumTR * 100;
      }      
      return pdi;
   }   
}




Regards
Madhur


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

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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