SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Fri Nov 24, 2017 1:18 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Aug 03, 2012 11:23 am 
Offline

Joined: Sun Jul 08, 2012 10:44 am
Posts: 11
Is it correct?
runned?
The code is :



using System;
using System.Drawing;

using OpenQuant.API;
using OpenQuant.API.Indicators;

public class MyStrategy : Strategy
{
Instrument Testa=Instruments["AAPL"];//set Testa;
//************************************************
[Parameter("Number of RSI")]
int NumRsi=14;
RSI TestRsi;
SMA TestSma;
//***********************************************
public override void OnStrategyStart()
{
TestRsi=new RSI(Testa,NumRsi,Color.Red);
Draw(TestRsi);
}
}


Top
 Profile  
 
PostPosted: Mon Aug 06, 2012 7:11 pm 
Offline

Joined: Wed Aug 08, 2007 6:32 pm
Posts: 207
Try this:
Draw(TestRsi, 2);


Top
 Profile  
 
PostPosted: Tue Aug 07, 2012 6:32 am 
Offline

Joined: Sun Jul 08, 2012 10:44 am
Posts: 11
It does not work.
Many errors.
?????? :(
Try again..... :evil:


Top
 Profile  
 
PostPosted: Tue Aug 07, 2012 5:16 pm 
Offline

Joined: Wed Aug 08, 2007 6:32 pm
Posts: 207
Sorry but there are lots of problems with your instrument code here including syntax which i didn't notice on first look.

It would be quicker to remove it and add it to the instrument list.

If you still want to write it programmatically look at the openquantFAQ or the strategy guide on multi leg trading.

using System;
using System.Drawing;

using OpenQuant.API;
using OpenQuant.API.Indicators;

public class MyStrategy : Strategy
{
Instrument Testa;

[Parameter("Number of RSI")]
int NumRsi=14;

RSI TestRsi;

public override void OnStrategyStart()
{
Testa = Instruments["AAPL"];

TestRsi=new RSI(Bars, NumRsi, Color.Red);
Draw(TestRsi, 2);
}


public override void OnBar(Bar bar)
{

}
}

PS add the timeframe you want in marketdata.


Top
 Profile  
 
PostPosted: Thu Aug 09, 2012 9:11 am 
Offline

Joined: Sun Jul 08, 2012 10:44 am
Posts: 11
Thank you for your attention.

In the code:
TestRsi=new RSI(Bars,NumRsi,Color.Red);
The Bars is meaning the close of TestA,or close of APPL,is that correct?


There are some other question I can not find answer by myself or I am not sure about it:

a,Should every code or strategy have OnBar event,or should a strategy only have Onstrategy Strat Event?

b, Can I use indicator like this:
SMA sma1;
SMA sma2;
SMA sma3;
sma1=new SMA(....);
sma2=new SMA(...);
sma3=sma1-sma2;

The question is :can I calculate the indicator?

c,defined the instrument
Instrument instrument1=Instruments["AAPL"];
Instrument Instrument2=Instruments["QQQQ"];
How can I get RSI of AAPL and QQQQ respectively?
Beacuse I don't know how to get instrument's barseries.

RSI(instrument1);
RSI(instrument2);
Is that wrong,right?

instrument1.bar is just one bar.AM I right?


If these questions are too easier,I feel sorry about it .
I just start to learn it and try to use it.


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 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