Australian (ASX) Stock Market Forum

Amibroker question: Does Stochastic no longer work?

Joined
19 May 2016
Posts
5
Reactions
0
.
I repost my question from Yahoo Amibroker Groups title "Why crazy Stochastics results"? Mr Tomasz Janeczko said Stochastics died last century. Mr Janeczko is genius but when he give negative answer it stops other people from posting good help and discussion.

My code is below. I grateful if someone here gives technical explanation of crazy results. Even a link to a site would be fine.

Scenario: I use similar to Buy = StochD < OversoldLimit
Purpose: Optimize OversoldLimit
Expected result: Best results with plateau between 20 and 40. (See fourth screenshot below)
Actual results: Best result is 94 !!! See first screenshot. Second screenshot is slightly rotated. This is very smooth line. No spikes. But I think is impossible. Normal values are 30 for oversold, and 80 for overbought.

Another example. To avoid using my code in case of my errors, I used code from Dr Howard Bandy's book "Quantitative Trading Systems". Figure 10.3. Stochastic of the RSI.

I made one difference. Dr Bandy used crossover of fast/slow. I changed to Buy < oversoldLimit. Optimized. Of course I cannot show this copyright code.

Third screenshot shows 3D chart for Nett Profit v oversoldLimit. Now everything is spikes. Spikes means that indicator or system is not robust. I expect to see similar to fourth screenshot.

I grateful for explanation of these strange results. Is possible that Stochastic crossover still works, but upper and lower limits no longer work?

Thanks

-----------------------------------------

SetOption( "InitialEquity", 999999 ) ; // out of the way
SetOption( "MaxOpenPositions", 9999 ) ; // out of the way
SetPositionSize( 1000, 1 ) ;
SetTradeDelays( 0, 0, 0, 0 );

Buy = Sell = 0 ;
BuyPrice = Open ;
SellPrice = Close ;

Ema100 = EMA( C, 100 ) ;
trendEma100 = ( Ema100 - Ref(Ema100, -5 ) ) ;
trendEma100OK = trendEma100 > 0 ; // 5-day trend rising

// stochastic
lowerLimit = Optimize( "lowerLimit", 20, 0, 100, 2 );
stochSlow = StochD( 14, 3, 3 ) ;
stochSlowOK = stochSlow < lowerLimit ;

BuySignal = trendEma100OK AND stochSlowOK ;
Buy = Ref( BuySignal, -1) ;

buyStop = Ref (H, -1 ) * 1.01 ;

Buy = Buy AND H > buyStop ;
BuyPrice = Max( buyStop, Low );

//n-bar stop for testing
Sell = 0 ;
holdDays = 4 ;
ApplyStop( stopTypeNBar, stopModeBars, holdDays, 1 );
//
.
 

Attachments

  • Expected.png
    Expected.png
    5.6 KB · Views: 53
  • AbForum_05_01.png
    AbForum_05_01.png
    33.2 KB · Views: 5
  • AbForum_05_02.png
    AbForum_05_02.png
    27.5 KB · Views: 4
  • DrBandy_01.png
    DrBandy_01.png
    32.2 KB · Views: 5
Sometimes it does, sometimes it doesn't. The strength, rate of change, velocity, periods of consolidation etcetera of a price move is why oscillators are not consistently rhythmic. 50/50 probability indicator.
 
Look at your trading logic.

Ema100 = EMA( C, 100 ) ;
trendEma100 = ( Ema100 - Ref(Ema100, -5 ) ) ;
trendEma100OK = trendEma100 > 0 ; // 5-day trend rising[/COLOR][/I]


You are looking for a short and long term uptrend in the above lines (a rising long term moving average),

And then you ask for a stochastic to show when to buy. What if the stochastic result is just showing you that your stock is continuing its uptrend? Thus a high stochastic level is the time to buy.

Try changing your trading system logic, "overbought" and "oversold" may work better for you if you are not also demanding a strongly trending stock.
 
.
Thank you Portfoliobuilder for good analysis and comments.

>> Look at your trading logic.

I think trading logic for mean reversion system is look for temporary oversold when general trend is up. Like stretch a spring. This explained by Dr Elder "When the weekly trend is up, look for Stochastic to fall to its lower reference line, giving a buy signal."

>> You are looking for a short and long term uptrend in the above lines

With great respect, here is my think. Person look at chart with 30 day EMA. He say "I see downtrend from A to B. I see flat from B to C. I see uptrend from C to EOD today." But AB cannot see chart. So I say to AB "please calculate 100 day EMA then tell me if last 5 days is up". ROC easier to write than Ref but I forget and I too lazy to change.

I think AB do similar thing with inWeekly for daily charts. But I think maybe inWeekly only correct at EOD on Friday and hold same value till EOD next Thurday. Like calendar watch that jumps 7 days at EOD every Friday.

Maybe I wrong but I think 5 day ROC always acurate at EOD today. Same for 10 day or 25 day or any ROC.

>> ...a high stochastic level is the time to buy.

I agree that is what my code says. Like testing simple EMA crossover and find that writing Cross wrong way give more profit. But I think theory say high level is overbought so time to sell.

Thanks.




Look at your trading logic.

Ema100 = EMA( C, 100 ) ;
trendEma100 = ( Ema100 - Ref(Ema100, -5 ) ) ;
trendEma100OK = trendEma100 > 0 ; // 5-day trend rising[/COLOR][/I]


You are looking for a short and long term uptrend in the above lines (a rising long term moving average),

And then you ask for a stochastic to show when to buy. What if the stochastic result is just showing you that your stock is continuing its uptrend? Thus a high stochastic level is the time to buy.

Try changing your trading system logic, "overbought" and "oversold" may work better for you if you are not also demanding a strongly trending stock.
 
Top