hydroflask
New member
There is a useful column study shared on here: https://usethinkscript.com/threads/...ossover-watchlist-column-for-thinkorswim.191/
I wanted to use this for Stochastic instead because I only want to look for long trades in my list of stocks when K crosses over D to the upside. K is the thinner line, D is the thicker line. I need the look back period to be zero (which doesn't seem to work), as I want to know if the stochastic is -currently- red and angling down, or -currently- green and angling up.
Summarily, long when D is green, short when D is red.
I am hoping that one of the experts in here could adjust the code in a way that makes it work. I know this is asking a lot as a stranger, but I have made several attempts at getting the result myself and only fall short each time.
FWIW here is my most recent attempt. It's embarrassing, I know:
I wanted to use this for Stochastic instead because I only want to look for long trades in my list of stocks when K crosses over D to the upside. K is the thinner line, D is the thicker line. I need the look back period to be zero (which doesn't seem to work), as I want to know if the stochastic is -currently- red and angling down, or -currently- green and angling up.
Summarily, long when D is green, short when D is red.
I am hoping that one of the experts in here could adjust the code in a way that makes it work. I know this is asking a lot as a stranger, but I have made several attempts at getting the result myself and only fall short each time.
FWIW here is my most recent attempt. It's embarrassing, I know:
Code:
declare lower;
input lookback= 1;
input over_bought = 80;
input over_sold = 20;
input KPeriod = 5;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 2;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(averageType, FastK, slowing_period);
def FullD = MovingAverage(averageType, FullK, DPeriod);
def bull_cross = FullK crosses above FullD;
def bear_cross = FullK crosses below FullD;
def bull_lookback = highest(bull_cross, lookback);
def bear_lookback = highest(bear_cross, lookback);
plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;
signal.AssignValueColor(if signal == 2 then Color.Dark_Green
else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);
AssignBackgroundCOlor(if signal == 2 then Color.Dark_Green
else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);
Last edited: