Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 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