Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, VoroneTZ, PeroPero), 808 guests, and 6 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
Page 2 of 2 1 2
Re: Price clusters [Re: danatrader] #481265
08/20/20 09:42
08/20/20 09:42
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
Would you be so kind to give some example for "Make a loop and count bins by checking low and high of each bar"?

That would be really great and I am sure others may benefit a lot from it too.

Re: Price clusters [Re: danatrader] #481267
08/20/20 10:27
08/20/20 10:27
Joined: Dec 2019
Posts: 53
ozgur Offline
Junior Member
ozgur  Offline
Junior Member

Joined: Dec 2019
Posts: 53
Sure.

Code
void run()
{
        int arrayHiLoLen = 1000;
        LookBack = 1000;

	var PIP10 = PIP * 10;
	
	var high = ceil(priceHigh(0) / PIP10) * PIP10;
	var low = ceil(priceLow(0) / PIP10) * PIP10;
	
	vars highs = series(high);
	vars lows = series(low);
	
	//
	if(!is(LOOKBACK)) {
		var highest = MaxVal(highs, arrayHiLoLen);
		var lowest = MinVal(lows, arrayHiLoLen);
		
		int arrLen = ((highest - lowest) / PIP10) + 1;
		
		int *binCount = zalloc(arrLen * sizeof(int));
		
		
		//
		int i;
		for (i = 0; i < arrayHiLoLen; i++) {
			int enIdx = (highs[i] - lowest) / PIP10;
			int stIdx = (lows[i] - lowest) / PIP10;
			
			int j;
			for (j = stIdx; j <= enIdx; j++) {
				binCount[j]++;
			}
		}
	

	        if(is(EXITRUN)) {
		    printf("\n");
		
		    int i;
		    for (i = 0; i < arrLen; i++) {
		        printf("%i ", binCount[i]);
		    }
		
		    printf("\n %f %f %i %f \n\n", lowest, highest, arrLen, PIP10);
	        }
        }
}


x-axis starts from "lowest" and increments in 10 pips to "highest". Bins are in binCount array e.g lowest count is in binCount[0], Highest in binCount[arrLen - 1]

Last edited by ozgur; 08/23/20 10:11.
Re: Price clusters [Re: danatrader] #481268
08/20/20 10:36
08/20/20 10:36
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
AWESOME, I will check it tonight, thank you so much.

Page 2 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1