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
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,031 guests, and 6 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 1 of 3 1 2 3
Indicator coding #479309
03/16/20 19:32
03/16/20 19:32
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
hi alltogether,

still I am a noob, so excuse...

I try to calculate a simple indicator.

Workshop 4a is already nice, but a bit for a beginner.

May someone assist?

Indicator formula is rather primitive, it is called "Psychology Line".

PSL=UpMovementsinthelastPeriodsn/Periodsn×100

I only got some Sierra Chart code frown

Code

float Count = 0;
		if (sc.GetBarHasClosedStatus(sc.Index) == BHCS_BAR_HAS_CLOSED) {
			for (int ictr = 1; ictr <= (perioda); ictr++)
			{
				if (sc.Close[sc.Index] > sc.Close[sc.Index-ictr])
				{
					Count++;
				}
			}

			PSL[sc.Index] = (Count / (perioda)) *100.0f;
		}
		else {
			PSL[sc.Index] = PSL[sc.Index-1];
		}


Last edited by danatrader; 03/16/20 20:27.
Re: Indicator coding [Re: danatrader] #479316
03/17/20 09:02
03/17/20 09:02
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
The code would be very similar for Zorro. Only make sure that Count is an int, not a float, and find out what sc.GetBarHasClosedStatus(sc.Index) is doing.

On Financial Hacker, Petra has written a few articles about indicator coding.

Re: Indicator coding [Re: danatrader] #479325
03/18/20 07:32
03/18/20 07:32
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
sc.Index is an array called once per bar.

if (sc.GetBarHasClosedStatus(sc.Index) == BHCS_BAR_HAS_CLOSED) is just making sure the actual bar is closed, since SC offers many different bars.

More simple pine script from tradingview:

xPSY = sum(close > close[1],Length) / Length * 100


Actually the indicator is so simple, but really great for trend determination, so if someone could help out would be awesome (I don't expect JCL to do so, since I assume he has his hands full with things to do).

But thank you a lot.

Re: Indicator coding [Re: danatrader] #479327
03/18/20 08:58
03/18/20 08:58
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I am not 100% sure but believe the pinescript is not the same as the sierra code. The sierra code sums up by differences to the current close but the pinescript sums up by differences of subsequent closes.

In Zorro: SumUp(series(priceClose()),Length) / Length * 100;


Re: Indicator coding [Re: danatrader] #479329
03/18/20 12:42
03/18/20 12:42
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
The SC code is from a really great futures / SC devleoper from Czech.
Sadly he won't share all, (which I understand fully).

So, the code from Sierra I assume is better (since I veryfied it graphically in the past).

In Zorro: SumUp(series(priceClose()),Length) / Length * 100; -> is the pince script version?
I will giv it a try, actually I was already working with SumUp, but didn't get it fully.

Thank you Petra.


BTW, this indicator allows to do really nice things, since most indicators may be piped through.
And it is almost realtime and really "cheap" in calculation costs.

Last edited by danatrader; 03/18/20 12:46.
Re: Indicator coding [Re: danatrader] #480303
05/30/20 21:41
05/30/20 21:41
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
Psychological Line is an indicator developed by Ken Muranaka

The indicator’svalues may range from 0 to 100. It is a simple indicator which shows the numberof increasing/decreasing prices over a specified period; thereby is a means for deter-mining the overbought/oversold price level.
The standard calculation of theindicator is as follows:

PSL = n / 12 * 100

where n is the number of days 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.

https://www.questia.com/magazine/1G1-63024940/opinion-oscillator

Last edited by danatrader; 05/30/20 22:20.
Re: Indicator coding [Re: danatrader] #480412
06/05/20 09:29
06/05/20 09:29
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
not nice, but working

Code
#define _SUM_PLUS  0         // register for AssetInt
#define _SUM_MINUS 1         // register for AssetInt

//---------------- indicator -----------------------------

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;
		
}


function run()
{

	set(PLOTNOW+LOGFILE);
    //set(STEPWISE);
	StartDate=2020;
	BarPeriod = 60;
	LookBack = 1;
	
	PlotScale = 8;
	PlotWidth = 1600;
	PlotHeight1 = 600;
	PlotHeight2 = 120;
    assetList("Assets");
    if (is(INITRUN)){
        assetHistory(Asset,1);
    }

	vars aPL = series(idxPL());
	plot("PLine",aPL,NEW,BLUE);
		 		  
}

Last edited by Grat; 06/05/20 09:30.
Re: Indicator coding [Re: danatrader] #480423
06/06/20 05:50
06/06/20 05:50
Joined: Mar 2019
Posts: 357
D
danatrader Offline OP
Senior Member
danatrader  Offline OP
Senior Member
D

Joined: Mar 2019
Posts: 357
It goes into the direction, thank you, I will continue working on it.
Thats a good start I have right here.

Thank you both Grat and Petra.

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

Joined: Mar 2019
Posts: 357
Did receive another snippet of code from the original developer... the thing is, of course it should be smoothed, but somehow calculations don't fit, it should move btween 0 and 100.
i will work on it, and crack it, I now have some approaches availabel, thanks to all again (sadly I am still fighting myself into it).

Seems like having winning ideas is so easy, coding so difficult laugh

// definition
Length1.Name = "Psychological area period";
Length1.SetInt(30);
Length1.SetIntLimits(1, MAX_STUDY_LENGTH);


//body
int &perioda = sc.GetPersistentInt(1);
perioda = Length1.GetInt();






//example output
//2: ATR Simple
if (CalculationMethod.GetIndex() == 2) {
sc.ATR(sc.BaseDataIn, outputID, Lengthfirst.GetInt(), MOVAVGTYPE_SIMPLE);
}




//PSL
for (int ictr = 1; ictr <= (perioda); ictr++)
{
if (outputID[sc.Index] > outputID[sc.Index - ictr])
{
Count = Count + 1.0f;
}
}

PSL[sc.Index] = (Count / (perioda)) *100.0f;

Last edited by danatrader; 06/06/20 07:10.
Re: Indicator coding [Re: danatrader] #480426
06/06/20 11:21
06/06/20 11:21
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
This indicator / original is not good for FX. Becouse calculate only the LONG. If is a downtrend, show zero. ( from head ). For this I have a modification (-100;100)

Page 1 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