Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,184 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Indicator for time periods since given range? #429110
09/09/13 08:29
09/09/13 08:29
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, is there a built in indicator that gives the time periods since a given range (high-low) occurred? Something like the inverse of average true range, but without time averaging.

So one might give an input of 0.01 as a 1 cent move for EUR/USD, and the number of time periods to the first time High-Low exceeded 1 cent is returned.

I tried to code this in an indicator using:
int i=1; var HL=0.0;
while(HL<0.01) {
HL=HH(Data[i])-LL(Data[i];
i=i+1; }
return (i-1)

However, this hung Zorro, and even when I tried with 4 hour data for just a few months, Zorro still hung with the message "compiling.........."

Thanks for any guidance.

Re: Indicator for time periods since given range? [Re: CL1] #429136
09/09/13 12:25
09/09/13 12:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
This code, if I understand it right, can cause an endless loop or even a crash. If you program an indicator with a loop, you must build in some stop criteria for preventing that it exceeds the Lookback period.

Re: Indicator for time periods since given range? [Re: jcl] #429139
09/09/13 12:35
09/09/13 12:35
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, yes that is true. However, I actually tried it with an extremely low range, like 10 pips which should be triggered within just a few 1m periods. I also never specified a Lookback, and started with i=1 and incremented i instead.

Shouldn't this work?

Re: Indicator for time periods since given range? [Re: CL1] #429150
09/09/13 13:12
09/09/13 13:12
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi again, I added a Period limit and as mentioned, it stops Zorro from crashing. However, the code is not executed properly. It seems like for small difference (like 1 pip), 1 period is returned. However, increasing to 5 pips gives 1 period for most points, and spiking to the maximum allowed (1440) at points. The following code was run for EUR/USD:

var fxn_HL(var* Data, int Period)
{
int i=1; var HL=0.0;
while(HL<0.0005 and i<Period)
{
HL=HH(Data[i])-LL(Data[i]);
i=i+1;
}
return (i-1);
}

function run()
{
StartDate = 2013; // start the simulation with September 2005
LookBack=1440;
BarPeriod=60;
set(PLOTPRICE+PLOTNOW);
PlotBars = 20000;
var* Price = series(price());

vars HL_ser = series(fxn_HL(Price,1440));
vars HH_ser=series(HH(24));
vars LL_ser=series(LL(24));
plot("HL",HL_ser[0],NEW,BLUE);
plot("HH",HH_ser[0],NEW,BLUE);
plot("LL",LL_ser[0],NEW,BLUE);
}

The graph of HH and LL for the last 24 hours is plotted. As you can imagine, a 5 pip range must be obtained in every given past hour.

Am I making some huge mistake??

Re: Indicator for time periods since given range? [Re: CL1] #429155
09/09/13 13:51
09/09/13 13:51
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Hint: have a look at your call of the HH and LL functions.

Re: Indicator for time periods since given range? [Re: jcl] #429158
09/09/13 14:05
09/09/13 14:05
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Thanks man, that was much more kind than just calling me an idiot! Substituting period for Price at period.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1