You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter GetRichOrDieTrying
- Start date

Solution

Code:

```
# PSAR Scan
# tomsk
# 11.20.2019
# Scans for a PSAR state transition from bullish to bearish or from bearish to bullish
#
# TD Ameritrade IP Company, Inc. (c) 2008-2019
#
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' ("...
```

Code:

```
# PSAR Scan
# tomsk
# 11.20.2019
# Scans for a PSAR state transition from bullish to bearish or from bearish to bullish
#
# TD Ameritrade IP Company, Inc. (c) 2008-2019
#
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");
def state = {default init, long, short};
def extreme;
def SAR;
def acc;
switch (state[1]) {
case init:
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = low;
case short:
if (SAR[1] < high)
then {
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = extreme[1];
} else {
state = state.short;
if (low < extreme[1])
then {
acc = min(acc[1] + accelerationFactor, accelerationLimit);
extreme = low;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
}
case long:
if (SAR[1] > low)
then {
state = state.short;
acc = accelerationFactor;
extreme = low;
SAR = extreme[1];
} else {
state = state.long;
if (high > extreme[1])
then {
acc = min(acc[1] + accelerationFactor, accelerationLimit);
extreme = high;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
}
}
def transitionBull = state[1] == state.short and state == state.long;
def transitionBear = state[1] == state.long and state == state.short;
# Comment out (#) the ONE not needed
plot scan = transitionBull;
#plot scan = transitionBear;
```

Hello Experts - You guys are genius. I wanted to take your help with one item. It's simple but I am no coder.

-> Parabolic SAR FLIPS -- Using the SAR value I want to post the LINES on top and bottom of where the flips took place.

-> Maybe just look at last N flips only to avoid lots of Lines.

-> There is study parabolicSarCrossover which puts the UP and DOWN Arrows - Need to have Horizontal lines instead

-> Parabolic SAR FLIPS -- Using the SAR value I want to post the LINES on top and bottom of where the flips took place.

-> Maybe just look at last N flips only to avoid lots of Lines.

-> There is study parabolicSarCrossover which puts the UP and DOWN Arrows - Need to have Horizontal lines instead

Last edited:

Code:

```
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");
def state = {default init, long, short};
def extreme;
def SAR;
def acc;
switch (state[1]) {
case init:
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = low;
case short:
if (SAR[1] < high)
then {
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = extreme[1];
} else {
state = state.short;
if (low < extreme[1])
then {
acc = min(acc[1] + accelerationFactor, accelerationLimit);
extreme = low;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = max(max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
}
case long:
if (SAR[1] > low)
then {
state = state.short;
acc = accelerationFactor;
extreme = low;
SAR = extreme[1];
} else {
state = state.long;
if (high > extreme[1])
then {
acc = min(acc[1] + accelerationFactor, accelerationLimit);
extreme = high;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = min(min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
}
}
def transitionBull = state[1] == state.short and state == state.long;
def transitionBear = state[1] == state.long and state == state.short;
def count1 = if transitionBull then 1 else count1[1]+1;
def count2 = if transitionBear then 1 else count2[1]+1;
input label_text = "PSAR";
AddLabel(1, label_text + " - " + if transitionBull then count1 else count2,
if transitionBull then color.green
else color.red);
```

I want it to add it to my watchlist column so that it tells me every time there is a reversal instead of changing thru different charts, does it make sense?Isn't the Parabolic Sar a reversal indicator in and of itself...??? The dots are either above or below the prices, indicating trend... Or do you want something else...???

Ahh... The rest of the story... You left that out of your original request... Let me check to see if I have that here...I want it to add it to my watchlist column so that it tells me every time there is a reversal instead of changing thru different charts, does it make sense?

Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|

T | Multi-Time Frame Parabolic SAR for ThinkorSwim | Indicators | 38 | |

F | Looking for Parabolic SAR MTF (Multi Time Frame) | Questions | 10 | |

F | How do you handle parabolic rises? | Questions | 4 | |

S | SAR dots Color Change | Questions | 5 | |

R | Alerts for Stock share for up or down price | Questions | 3 |