Parabolic SAR Alerts in ThinkorSwim

Is it possible to create an alert when Parabolic SAR reverses in Thinkorswim? Ideally, I would like to get an alert on desktop and mobile with sound and a push notification through the app or email. I tried using the Study Alert feature under the MarketWatch -> Alerts tab, but Parabolic SAR isn't a Study that appears to be supported. Is there a custom way to do this with Thinkscript?
 
Solution
Here is the scan for a PSAR for EITHER a transition from bullish to bearish OR from bearish to bullish. I have listed two plot statements. Please comment out the one you don't want as the scanner only accepts a single plot statement

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' ("...

tomsk

Well-known member
VIP
Here is the scan for a PSAR for EITHER a transition from bullish to bearish OR from bearish to bullish. I have listed two plot statements. Please comment out the one you don't want as the scanner only accepts a single plot statement

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;
 
Solution

ssara

New member
VIP
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
 
Last edited:

laketrader

New member
2019 Donor
VIP
I tried to make a label for PSR study. But I found on some symbols that the value was incorrect. e.g WKHS - The correct label should be 5 but the label displayed 15. I am not sure why. Any help is always appreciated.

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);
 

dixit78

New member
Hello All,

I am looking for a code to help indicate the reversal using Parabolic Sar. Could someone help me with this or does someone have a code? Thank You Very Much
 

rad14733

Well-known member
VIP
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...???
 

dixit78

New member
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...???
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?
 

rad14733

Well-known member
VIP
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?
Ahh... The rest of the story... You left that out of your original request... Let me check to see if I have that here...
 

Similar threads

Top