Hello everybody,
I would like to run a simulation of parabolic SAR but when I try to code the indicator in eg python I don´t really get the same results as in PRT,
How can I get to know the details of how SAR is defined / specified?
As I said, I´ve looked at a number of places but the code I come up with casts different results as PRT
Many many thanks in advance,
JSParticipant
Senior
Hi @jmcenterio
Here is the code of the parabolic SAR.
This code gives the same results as the “internal PRT” indicator…
increment = 0.02
initial = 0.02
limite = 0.2
IF BARINDEX < 2 THEN
Lparabolic = LOW
islong = 1
af = limite
hp = HIGH
lp = LOW
ELSE
IF islong THEN
Lparabolic = Lparabolic + af * (hp - Lparabolic)
Lparabolic = MIN(Lparabolic, LOW[1])
Lparabolic = MIN(Lparabolic, LOW[2])
ELSE
Sparabolic=Sparabolic + af * (lp - Sparabolic)
Sparabolic=MAX(Sparabolic, HIGH[1])
Sparabolic=MAX(Sparabolic, HIGH[2])
ENDIF
reverse = 0
IF islong THEN
IF LOW < Lparabolic THEN
islong = 0
reverse = 1
Sparabolic = hp
lp = LOW
af = initial
ENDIF
ELSE
IF HIGH > Sparabolic THEN
islong = 1
reverse =1
Lparabolic = lp
hp = HIGH
af = initial
ENDIF
ENDIF
IF NOT reverse THEN
IF islong THEN
IF HIGH > hp THEN
hp = HIGH
af = af + increment
af = MIN (af,limite)
ENDIF
ELSE
IF LOW < lp THEN
lp = LOW
af = af + increment
af = MIN (af,limite)
ENDIF
ENDIF
ENDIF
ENDIF
If isLong then
DRAWPOINT(barindex, Lparabolic, 2) Coloured(0,255,0)
EndIf
If NOT isLong then
DRAWPOINT(barindex,Sparabolic,2) Coloured(255,0,0)
EndIf
Return