Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Imhotep, opm), 785 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Higher for at least N days in a row #482547
02/22/21 07:53
02/22/21 07:53
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline OP
Newbie
strimp099  Offline OP
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
How might I test if a price series is higher for at least N days in a row?

This gives my a price series higher for five days in a row starting yesterday...

Code

bool risingFiveDays = (Prices[1] > Prices[2]) && 
				    (Prices[2] > Prices[3]) && 
				    (Prices[3] > Prices[4]) && 
				    (Prices[4] > Prices[5]) &&
				    (Prices[5] > Prices[6]);


How to generalize this to _at least_ five days starting yesterday?

Last edited by strimp099; 02/22/21 08:21.
Re: Higher for at least N days in a row [Re: strimp099] #482639
03/11/21 18:50
03/11/21 18:50
Joined: Mar 2021
Posts: 6
Z
ZorroTradeAA Offline
Newbie
ZorroTradeAA  Offline
Newbie
Z

Joined: Mar 2021
Posts: 6
Hi,

I would say you can use a for-loop.
Something like that:

Code
int dayLookBackStart = 1;
int lookBackPeriod = 5;
int i;

bool risingXDays = true;

for(i=dayLookBackStart ; i<lookBackPeriod-1; i++){
 if(Prices[i]<Prices[i+1]){
  risingXDays = false;
  break;
 }
}


risingXDays is true if during the lookBackPeriod you have continues higher Prices or false if the series is broken in one of the days.
Try it out it should work.

Cheers


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