Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, howardR), 472 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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