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 (degenerate_762, Nymphodora), 1,012 guests, and 3 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
Page 2 of 3 1 2 3
Re: Indicator coding [Re: danatrader] #480427
06/06/20 11:33
06/06/20 11:33
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Depend on the theory:

Psychological Line is an indicator developed by Ken Muranaka.
The indicator’s values may range from 0 to 100. It is a simple indicator which shows the number of increasing/decreasing prices over a specified period; thereby is a means for deter- mining the overbought/oversold price level. The standard calculation of the indicator is as follows:

PI= n/12 ∗100

where n is the number of days(period) that the price is closed higher than the previous period.
n and the number of comparison days (i.e. 12) in the above calculation are subject to change.

[Linked Image]

Attached Files
Last edited by Grat; 06/06/20 11:37.
Re: Indicator coding [Re: danatrader] #480428
06/06/20 11:35
06/06/20 11:35
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
Yes, I was originally thinking that for the Sierra Chart developer too, but a nice effect can be achieved by just switching the length of the comparision period with indicator period.
Then it would be somewhat upside down.

I will try your way, actually it needs to be smoothed, anyway, I will work on it a bit.

it is a nice sample for me to learn more coding and the behaviour of Zorro.

Just I don't get, how I would let the sumDN / sumUP shift, since comparing the complete periods is not so good.
The periods compared should be created by HTDcPeriod / DominantPeriod.

Re: Indicator coding [Re: danatrader] #480429
06/06/20 11:38
06/06/20 11:38
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Yes, for this I not finish, me code is only draft. Now I work on finish version.

Re: Indicator coding [Re: danatrader] #480430
06/06/20 11:53
06/06/20 11:53
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
I promise you, it is so simple logic, but you can pipe anything through and it is really powerful.

E.g. preprocess Data with only candles matching a given ATR condition.

NumWhiteBlack(ATR(24)/3, 0, 1) or the moving average of it.
And so on...

Just my plot looks different from yours, I assume you did already change the code postet before.

Last edited by danatrader; 06/06/20 12:02.
Re: Indicator coding [Re: danatrader] #480440
06/06/20 19:04
06/06/20 19:04
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
Grat,

I think there is something not as it should be, look at the plot below.
I did try already to change your code, eventually I will get it done, just if you say yours is not nice, mine will be horrible.... laugh

double idxPL(){
int sumUP = AssetInt[_SUM_PLUS];
int sumDN = AssetInt[_SUM_MINUS];
var pl=0;
if (priceClose() > priceClose(1)){
sumUP++;
sumDN=0;
pl=(sumUP/12.0)*100;
}

if (priceClose() < priceClose(1)){
sumUP=0;
sumDN++;
pl=-(sumDN/12.0)*100;
}
//watch("\n",sumDN,sumUP,pl);
AssetInt[_SUM_PLUS] = sumUP;
AssetInt[_SUM_MINUS]= sumDN;

return pl;

}


I think it goes too sharp down, as far I understand, the code above returns either the minus count or the plus count.
But in case to make your idea work with the down count, ther must be something like sumUP-sumDN if sumUP is bigger than sumDN, and the other way round sumDown - sumUP if sumDN is bigger than sumUP.

Of course only, if the opposite bar / close occurs.



Attached Files
PSL-Plot.png (13 downloads)
Last edited by danatrader; 06/07/20 05:29.
Re: Indicator coding [Re: danatrader] #480450
06/07/20 05:45
06/07/20 05:45
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
How would I make it to oscillate between 100 and 0.
For me it is about also about understanding the tool (Zorro functions).

The version of Petra is simple, just it goes beyond 100 as max. value.
So I would just use the Max function?

Re: Indicator coding [Re: danatrader] #480451
06/07/20 06:50
06/07/20 06:50
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
theory:

Quote
where n is the number of days(period) that the price is closed higher than the previous period.


but

zorro fce sumUp - not calculate how many is close Price higher the price older, but sumOfprice if is highers

Code
var vUp, vDn;
var ProfitFactor(var* Data,int Length)
{
	vUp = 0.,vDn = 0.;
	for(int i=1; i<Length; i++) {
		if(Data[i-1] > Data[i])
			vUp += Data[i-1]-Data[i];
		else
			vDn += Data[i]-Data[i-1];
	}
	if(vDn == 0.) 
		return vUp == 0.? 1. : 10.;
	return Clamp(vUp/vDn,0.,9.999);
}

var SumUp(var* Data,int Length)
{
	ProfitFactor(Data,Length);
	return vUp;
}

Re: Indicator coding [Re: danatrader] #480453
06/07/20 06:56
06/07/20 06:56
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
That is I assume it would need before the SumUp this

if (priceClose() > priceClose(1)){

still I really need the original version.

Can we get there together?
I can then show you why.

BTW, can you crack the EUR/CAD laugh

Re: Indicator coding [Re: danatrader] #480454
06/07/20 07:28
06/07/20 07:28
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
But even using the code from Petra, I don't get it oscillating between 0 and 100.
What would I need to do to get it / any line oscillating between 0 / 100?

Re: Indicator coding [Re: danatrader] #480455
06/07/20 07:35
06/07/20 07:35
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
I don't know, how looking the original idx. Like this?

Attached Files
Page 2 of 3 1 2 3

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