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.
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).
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;
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.
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.
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
// definition Length1.Name = "Psychological area period"; Length1.SetInt(30); Length1.SetIntLimits(1, MAX_STUDY_LENGTH);
//body int &perioda = sc.GetPersistentInt(1); perioda = Length1.GetInt();
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)
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.
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.
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....
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; }
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.
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?