SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Sep 24, 2018 7:17 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Displaying data on chart
PostPosted: Thu Aug 21, 2014 12:19 am 
Offline

Joined: Sun Sep 01, 2013 9:31 pm
Posts: 22
Hello Support,

I have following question related to displaying data on chart:
1- Is there any way I can display my values in the form of candle/bar on the chart?
2- How can we scale the panel on chart. For example I want my indicator panel to range from -25 to 25?

Thanks
Wajeeha


Top
 Profile  
 
PostPosted: Fri Aug 22, 2014 1:33 pm 
Offline

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

are you talking about OQ2013 or 2014?

Regards,
Anton


Top
 Profile  
 
PostPosted: Fri Aug 22, 2014 3:01 pm 
Offline

Joined: Sun Sep 01, 2013 9:31 pm
Posts: 22
I am using OQ 2014

Thanks


Top
 Profile  
 
PostPosted: Sat Aug 23, 2014 12:03 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6808
OK. Do you mean bars from zero line to data point values (as standard Volume chart) or something else? You can use group.Add("Style", "Bar");

Regards,
Anton


Top
 Profile  
 
PostPosted: Sun Aug 24, 2014 7:57 pm 
Offline

Joined: Sun Sep 01, 2013 9:31 pm
Posts: 22
Here are some explanations of what I want to achieve:
Quote:
1- How can we scale the panel on chart. For example I want my indicator panel to range from -25 to 25?

Attached is an indicator output. You can see that y-axis has range from 1840.6 to 1841.8. What method should I use if I want to scale y axis to some other values i.e from 1835 to 1845?

Quote:
2- Is there any way I can display my values in the form of candle/bar on the chart?

Consider following piece of code :
Code:
BarSeries barseries = new BarSeries();
Bar bar = new Bar(DateTime.Now,5,6,2,1,0,3);
barseries.Add(bar);

Now how can I display this barseries on chart in candlestick pattern ?

Thanks,


Attachments:
IndicatorOutput.png
IndicatorOutput.png [ 7.83 KiB | Viewed 4100 times ]
Top
 Profile  
 
PostPosted: Mon Aug 25, 2014 11:13 am 
Offline

Joined: Mon Aug 01, 2011 9:31 am
Posts: 62
Hi, Wajeeha.

The range of y-axis depends on values in the current pad. You could add some additional values to extend the range.

For example:
Code:
public class MyStrategy : InstrumentStrategy
{
   private EMA ema;
   private Group barsGroup;
   private Group emaGroup;
   private Group upLineGroup;
   private Group downLineGroup;
   
   public MyStrategy(Framework framework, string name)
      : base(framework, name)
   {
   }

   protected override void OnStrategyStart()
   {
      ema = new EMA(Bars, 5);
      
      barsGroup = new Group("Bars");
      barsGroup.Add("Pad", 0);
      barsGroup.Add("SelectorKey", Instrument.Symbol);

      emaGroup = new Group("EMA");
      emaGroup.Add("Pad", 1);
      emaGroup.Add("SelectorKey", Instrument.Symbol);
      emaGroup.Add("Color", Color.White);
      
      upLineGroup = new Group("UpLine");
      upLineGroup.Add("Pad", 1);
      upLineGroup.Add("SelectorKey", Instrument.Symbol);
      upLineGroup.Add("Color", Color.Red);
      
      downLineGroup = new Group("DownLine");
      downLineGroup.Add("Pad", 1);
      downLineGroup.Add("SelectorKey", Instrument.Symbol);
      downLineGroup.Add("Color", Color.Red);
      
      GroupManager.Add(barsGroup);
      GroupManager.Add(emaGroup);
      GroupManager.Add(upLineGroup);
      GroupManager.Add(downLineGroup);
   }

   protected override void OnBar(Instrument instrument, Bar bar)
   {
      Bars.Add(bar);
      Log(bar, barsGroup);
      
      if(ema.Count > 0)
      {
         // Extend y-axis by adding up/down lines.
         Log(ema.Last + 10, upLineGroup);
         Log(ema.Last - 10, downLineGroup);
         
         Log(ema.Last, emaGroup);
      }
   }
}


You'll see the extended y-axis:
Attachment:
1.png
1.png [ 7.61 KiB | Viewed 4096 times ]

You could use chart's background color (Color.MidnightBlue) for up/down lines:
Code:
upLineGroup.Add("Color", Color.MidnightBlue);
...
downLineGroup.Add("Color", Color.MidnightBlue);

As a result you'll see this:
Attachment:
2.png
2.png [ 5.53 KiB | Viewed 4096 times ]

2. There is one limitation for gapless chart - you could show only one bar series on the chart.
This code add bar to the Bars and barsGroup:
Code:
protected override void OnBar(Instrument instrument, Bar bar)
{
   Bars.Add(bar);
   Log(bar, barsGroup);
}

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Mon Aug 25, 2014 2:33 pm 
Offline

Joined: Sun Sep 01, 2013 9:31 pm
Posts: 22
Thank you for you detailed reply but I am using OQ 2013 for my this particular project. Will this work in OQ 2013 as well?

Thanks,


Top
 Profile  
 
PostPosted: Mon Aug 25, 2014 9:39 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6808
Wajeeha wrote:
I am using OQ 2014

Thanks


Top
 Profile  
 
PostPosted: Mon Aug 25, 2014 10:29 pm 
Offline

Joined: Sun Sep 01, 2013 9:31 pm
Posts: 22
Yes I know I apologize on mistake.

Please let me know how this can be achieved in OQ 2013?

Thanks,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 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:  
cron
Powered by phpBB® Forum Software © phpBB Group