anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.15k stars 558 forks source link

Psar not matching up with Tradingview psar #69

Open streetgainer opened 7 years ago

streetgainer commented 7 years ago

The psar doesn't match the psar on Tradingview. Could the calculation be missing something?

anandanand84 commented 7 years ago

@streetgainer can you send the values comparing the two?

streetgainer commented 7 years ago

Yes.. below are the last 30 daily bars (H/L) for NFLX and the Tradingview's psar results for each day. What I noticed is that Tradingview charts has an additional setting on their psar indicator called Start which is also set to .02 at default, and it's defined here as "The starting value for the Acceleration Factor ". Not sure if that's an issue. The psar results below are rounded to 2 digits after the decimal but actually have as many as 4 or 5 digits after the decimal...

`let high=[ 190.25, 188.66, 189.7, 190, 185.03, 184.97, 184.62, 182.57, 181.22, 181, 182.27, 181.91, 175.96, 174.45, 172.58, 172.45, 171.88, 170.5, 170.58, 169.97, 168.99, 169.93, 169.64, 171.24, 168.75, 168.67, 169.68, 174.85, 176.24, 176.48 ]

let low=[ 187.01, 185.81, 187.51, 179.38, 181.18, 180.65, 181.43, 177.81, 178.02, 178.5, 179.1, 177.45, 170.01, 167.6, 169, 168.8, 168.25, 166.25, 165.72, 165.8, 164.23, 167.04, 166.7, 166.15, 165.5, 165.6, 164.73, 169.37, 173.86, 173.92 ]

let tradingview_results=[ 167.61, 170.96, 173.83, 176.31, 178.43, 180.26, 181.43, 191.50, 191.23, 190.96, 190.69, 190.16, 188.96, 187.25, 185.68, 184.23, 182.90, 181.23, 179.37, 177.73, 175.84, 174.22, 172.82, 171.62, 170.58, 169.69, 169.68, 164.23, 164.71, 165.42]

let technicalindicators_results=[ 187.01, 190.25, 190.25, 190.1612, 190, 190, 189.5752, 189.167392, 188.48594848000002, 187.84539157120003, 187.24326807692802, 186.67727199231234, 185.93909023292736, 184.3461812096346, 182.33663946447845, 180.56824272874104, 179.0120536012921, 177.64260716913705, 176.04764216545786, 174.3952194189846, 173.00718431194707, 171.4272911357966, 170.1317787313532, 164.23, 164.37019999999998, 164.50759599999998, 164.64224407999998, 164.73, 164.73, 165.42059999999998 ]`