Hello

The pSAR indicator in AB has two parameters - acceleration and max. acceleration. Where does min. acceleration come into play? I want to match what I'm using in AB to what I have in a different platform. Thanks for the help.

Hello

The pSAR indicator in AB has two parameters - acceleration and max. acceleration. Where does min. acceleration come into play? I want to match what I'm using in AB to what I have in a different platform. Thanks for the help.

In other words, what is the AB equivalent of SAR( min, step, max) ?

cheers

First of all SAR is one to one implementation of Wilder SAR.

And first argument is minimum acceleration factor already. It increases from minimum to maximum. Watch the table.

http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:parabolic_sar

https://help.stockdoctor.com.au/hc/en-us/articles/360000100475-Parabolic-SAR

3 Likes

Thanks trash.

The SAR I use on the other platform looks quite different to AB for the same parameters. I guess that must mean it's not Wilder's.

Strangely, when I alter the step argument in the other indicator, it doesn't change anything visually. I feel like it should. The platform is PRT.

@Tomasz, is it possible to see the pSAR code you used for AB please? I can't seem to reproduce it elsewhere. Is it as per Stockcharts.com below?

Prior SAR: The SAR value for the previous period.

Extreme Point (EP): The lowest low of the current downtrend.

Acceleration Factor (AF): Starting at .02, AF increases by .02 each time the extreme point makes a new low. AF can reach a maximum of .20, no matter how long the downtrend extends.

Current SAR = Prior SAR - Prior AF(Prior SAR - Prior EP)

9-Feb-10 SAR = 43.56 = 43.84 - .16(43.84 - 42.07)

The Acceleration Factor is multiplied by the difference between the Prior period's SAR and the Extreme Point. This is then subtracted from the prior period's SAR. Note however that SAR can never be below the prior two periods' highs. Should SAR be below one of those highs, use the highest of the two for SAR.

Prior SAR: The SAR value for the previous period.

Extreme Point (EP): The highest high of the current uptrend.

Acceleration Factor (AF): Starting at .02, AF increases by .02 each time the extreme point makes a new high. AF can reach a maximum of .20, no matter how long the uptrend extends.

Current SAR = Prior SAR + Prior AF(Prior EP - Prior SAR)

13-Apr-10 SAR = 48.28 = 48.13 + .14(49.20 - 48.13)

The Acceleration Factor is multiplied by the difference between the Extreme Point and the prior period's SAR. This is then added to the prior period's SAR. Note however that SAR can never be above the prior two periods' lows. Should SAR be above one of those lows, use the lowest of the two for SAR.

@C_M there is an old example in the User's Library. It is worth noting that the user variable in this afl "reverse" needs to be called something else since more recent versions of AmiBroker have a built in function called "Reverse".

http://www.amibroker.com/members/library/formula.php?id=268

If ** SAR** is of interest to you then you may also like to look over a nice modification made by another user, Thomas Ludwig, based upon an April 1995 article in Technical Analysis of Stocks and Commodities by Dennis Meyers.

http://www.amibroker.com/members/library/detail.php?id=448

2 Likes

AmiBroker **always** uses correct implementation of **every** indicator in line with original authors defininition http://technical.traders.com/tradersonline/display.asp?art=294

and output is always identical with industry standard (like Metastock/Tradestation) (of course within IEEE precision limits)

2 Likes

@Tomasz, I don't disagree with you much. However the industry standard is Amibroker not metastock & tradestation.

1 Like

"of course within IEEE precision limits" - I think that might be the issue.

Thank you, and thanks @portfoliobuilder

Tomasz, would it be ok if I asked someone from PRT to convert your code to another language please? I checked about PRT and they do actually have high precision formatting. I feel like I might be able to get it to working.

Give away my high performance optimized C++ code to convert my work to other platform? The answer is no.

4 Likes

I don't understand how max acceleration can be less than acceleration without it giving an error. I'm assuming the step is 0.02 and not alterable?

@C_M you can alter the code as you see fit. If you Right Click on your chart and see "Edit formula" you call up the afl file and make changes, give it a new name if you prefer, and save your new afl file.

```
_SECTION_BEGIN("SAR");
acc = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
_SECTION_END();
```

Thanks, I understand that, but it's not what I asked.

What is the value of 'step' in the hard coded SAR? And why does AB allow 'max accel' to be less than 'initial accel'? Just trying to work out this indicator.

The step is 0.001 and you can make it anything you like.

As for the second question, I can't speak for @Tomasz but I assume it is coded to give the user the flexibility to choose different ranges of "acceleration" and "maximum".

But you do appear to be correct that the indicator in it's current state is not "idiot-proof" and can be misused if not properly understood. And no, I am not implying that you are an idiot. It is a common North American expression. @Tomasz often uses the phrase "user's shooting themselves in the foot" if they are improperly using functions due to lack of understanding.

I'm not referring to the parameter step, but the hard-coded SAR step.

SAR requires 3 inputs - initial accel, step and max accel.

Back in 1995 when I started to write AmIBroker I wrote it for **MYSELF** and it was written for Amiga which had 7MHz (yes megahertz, not Gigahertz) CPU and 1MB (megabyte) of RAM. So the computer was 1000x slower than today's CPUs and had 16000 times less memory. Every CPU cycle and every byte counted. Still AmiBroker on Amiga was faster than many todays softwares on current top-of-the-line PCs.

To achieve that I had to make sure NOT to bloat the code with nonsense and sometimes assumed that **user** (i.e. me, at that time) knows what he is doing. Parabolic SAR function was there almost since very beginning (version 1.x I don't remember).

ParabolicSAR is **working fine**. If you feed it with nonsense (step > maximum) it STILL behaves correctly, i.e. resulting SAR is equal to MAXIMUM as there is a code

```
af = min( af + AFStep, AFMaximum);
```

So the result is that maximum specified is used if af + step is greater than max.

I don't have zillions of junior programmers to add silly code like this in every possible place:

```
if( non_sense_parameters) Error("The parameters you entered are nonsense");
```

Still the function **IS** fool proof and behaves **correctly** (and it was so since 1995). It just does not scream to the user yet another error message.

Over the course of years more and more error messages were added (check the README for last 10 years) because users pretty often don't precisely know what they are doing and nowadays I don't need to think **thrice** about every byte and every CPU cycle as in the Amiga days. I just think once now

There is also other reason: since parameters in AmIBroker can be adjusted by sliders it is **way more user-friendly** to handle wrong combinations of parameters in sensible way without error message (as Parabolic SAR does already) than to shout error messages each time you move the slider "too far".

For this reason adding the error message in this case would be simply ANTI-user friendly.

Each solution in AmiBroker is for a very good reason.

10 Likes

I got more than I bargained for there. No one is doubting your ability.