SmartQuant Discussion http://www.smartquant.com/forums/ |
|
How to program the following formula into QD http://www.smartquant.com/forums/viewtopic.php?f=44&t=10528 |
Page 1 of 1 |
Author: | Kreangast [ Fri Jun 14, 2013 4:18 pm ] |
Post subject: | How to program the following formula into QD |
//amibroker PPF=Ref(H1,barslast(A1));//barslast(x): count the period number since the last x != 0. // |
Author: | Baraz Sergey [ Sat Jun 15, 2013 3:30 am ] |
Post subject: | Re: How to program the following formula into QD |
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. |
Author: | Kreangast [ Sat Jun 15, 2013 10:13 am ] |
Post subject: | Re: How to program the following formula into QD |
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. |
Page 1 of 1 | All times are UTC + 3 hours |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |