SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Nov 21, 2018 7:28 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jun 14, 2013 4:18 pm 
Offline

Joined: Fri Jun 14, 2013 2:45 pm
Posts: 2
//amibroker
PPF=Ref(H1,barslast(A1));//barslast(x): count the period number since the last x != 0.
//


Last edited by Kreangast on Sat Aug 10, 2013 10:31 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Jun 15, 2013 3:30 am 
Offline

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

I am not familar with amibroker syntax, but in OQ it looks something like this:
Quote:
using System;
using System.Drawing;

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

public class MyStrategy : Strategy
{
double lastPPFWhenA1IsZero = double.NaN;

public override void OnBar(Bar bar)
{
if (Bars.Count < 20)
return;

double TR= Math.Max(Math.Max((bar.High-bar.Low),Math.Abs(Bars.Ago(1).Close-bar.High)),Math.Abs(Bars.Ago(1).Close-bar.Low));

bool A1 = bar.High == Bars.HighestHigh(20);

double H1=TR*0.5;

if (!A1)
lastPPFWhenA1IsZero = H1;

double PPF=lastPPFWhenA1IsZero;

Console.WriteLine(bar + " PPF = " + PPF);

}
}


Regards,
Sergey.


Top
 Profile  
 
PostPosted: Sat Jun 15, 2013 10:13 am 
Offline

Joined: Fri Jun 14, 2013 2:45 pm
Posts: 2
Hi Baraz Sergey
Thank you very much!
But I do not quite understand,Ref(),BarsLast(),C # statement to express
,Indicators are invoked with multi-cycle values ​​written in C # how.Thank explain my puzzled.

Kreangast
2013/6/15
Baraz Sergey wrote:
Hi,

I am not familar with amibroker syntax, but in OQ it looks something like this:
Quote:
using System;
using System.Drawing;

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

public class MyStrategy : Strategy
{
double lastPPFWhenA1IsZero = double.NaN;

public override void OnBar(Bar bar)
{
if (Bars.Count < 20)
return;

double TR= Math.Max(Math.Max((bar.High-bar.Low),Math.Abs(Bars.Ago(1).Close-bar.High)),Math.Abs(Bars.Ago(1).Close-bar.Low));

bool A1 = bar.High == Bars.HighestHigh(20);

double H1=TR*0.5;

if (!A1)
lastPPFWhenA1IsZero = H1;

double PPF=lastPPFWhenA1IsZero;

Console.WriteLine(bar + " PPF = " + PPF);

}
}


Regards,
Sergey.


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:  
cron
Powered by phpBB® Forum Software © phpBB Group