Stochastic %K Oversold

Hi,

I've created a script to scan where Stochastic %K is in the over-sold zone i.e., %K < 20 and has recently started to turn-up in last 1 day as per the below script.

//Stochastic is in the over-sold zone %K < 20 and has now started to turn-up in last 1 day
//And price is > MA150
//Create variables for the MA values
MA1 = MA(BARS=150, CALC=Close);
STO = STOCH()

// Create logic formula
STO.%K < 20 and STO.%KTurnsUp
and CLOSE() > MA1

However I've noticed there is another function STOCHSCAN() similar to STOCH() though I'm unable to get the desired results when I use STOCH() or STOCHSCAN(). When I use a normal MA50 > MA150 scan and add a stochastic indicator on chart I'm able to identify the correct desired pattern. Appreciate if someone can let me know if I'm missing anything here in the above script.

Thanks.

Hi Raviraj,

I can see a small error in the script. You need a space before the “TurnsUp”

eg you have “STO.%KTurnsUp”

and it should be “STO.%K TurnsUp”

Hope that helps

Mathew

 

Hi Raviraj,

A couple of other things also:

  1. there needs to be a semi-colon at the end of variables ie STO=STOCH();
  2. The indicator on the chart and the script aren't matching. By default, the STOCH() function uses the Fast plot set to 10, 3, 3, and the indicator in your chart is using the slow stochastic 14/3/3. Click on the 'stoch' text in the script editor window to change the Type to Slow and Base Stochastic to 14:
Capture

Then apply to a Show Bar and the results should match the indicator (tip: change the Show Bar from arrow to a line, and Show over All Views).

Capture

Thanks Mathew and Darren for your help. I've corrected the script and after applying on Show Bar I'm able to get the desired results.

//Create variables for the MA values
MA1 = MA(BARS=150, CALC=Close);
STO = STOCH(TYPE=Slow, BAR1=14);

// Create logic formula
STO.%K < 21 and STO.%K TurnsUp