Peaks and Troughs of Stochastic
Author: 07nioe
Creation Date: 9/5/2014 8:43 AM
profile picture

07nioe

#1
Hi,

I use a simple stochastic trading strategic which has room for improvement. One idea is to use a filter for the stochastic.

Go long, if the the peaks of the stochastic becoming higher
Go short, if the he peaks of the stochastic becoming lower

On a chart you can see it quite clear. But I don't know how to code this.

Does anyone has an idea? Is a sma of the stochastics the right way? Or do I have to take another indikator which bases on the stochastic values?

Anyway, here is the code which needs improvement:

CODE:
Please log in to see this code.


Thank you very much!

Best
Niels
profile picture

Eugene

#2
QUOTE:
On a chart you can see it quite clear. But I don't know how to code this.

Before you or anyone else can program it, your idea needs to be expressed as a clear set of rules ready to be coded. Could you be more precise about what "the peaks of the stochastic" are? How do you define them from a technical analysis standpoint?

For example, there are numerous examples (as downloadable strategies and in the Wiki) using Peak.Series to define divergences and various zigzag techniques.
profile picture

07nioe

#3
Hi Eugene,

I'll try to clearly define the rules:

1. System goes Long, if the StochasticK is in the oversold area ( for example <20) AND stochasticK HIGHER than the last low(peak) of the stochasticK value (for example: now the value 14, last time it was 12)

2. System goes Short, if the StochasticK is in the overbought area (for example >75) AND stochasticK is LOWER than the last high(peak) of the stochasticK value. (for example: now the value 80, last time it was 82)

3. The reversal level is 20% or 30 as absolute value.

I hope the rule is more precise now. Otherwise I 'll try to specify further.

Thank you very much

Best Wishes
Niels


profile picture

Eugene

#4
Niels,

Here's how your rules could be implemented, for example, using the ZigZag Class:

CODE:
Please log in to see this code.


profile picture

07nioe

#5
Hi Eugene,

Thank you again for your fast help. I think we'll come closer to the right solution. I have the impression that the system ist quite slow. After the higher trough / lower peak is reached the system needs time to enter a position and often the market has reversed.

Maybe there is a solution: One possible way is not wait unit the lower peak / higher trough is formed but rather the value of the stochasticK comes close to the level of the last peak / trough.

The image shows where the position should be entered. I hope that helps.

Thank you for your ideas.

Best
Niels
profile picture

Eugene

#6
Peak/trough detection works this way. It's not possible to catch exact tops and bottoms. Tweak the ZigZag's reversalAmount parameter for faster detection.

P.S. An image can be only a PNG (preferrred!), JPG or GIF (inferior) under 2 Megabytes in size.
profile picture

07nioe

#7
Doesn't work with the upload. Okay, I don't know if Zigzag is the right approch than.

May it is enough to identify the last Peak / trough and use the following rule:

if stochasticK value is above / below a certain value (overbought / oversold) and is still below / above the last Peak / Trough value, than go Long or short. Is that possible to code?

Thank you

Best
Niels
profile picture

Eugene

#8
Niels,

The proposed "solution", as I see it, will trigger many false/premature signals. ZigZag is a convenient overlay on top of the Peak/Trough. I suggest you reduce the reversalAmount parameter until a sufficient result is obtained.
profile picture

WEALTHPRO25

#9
dear sir,
i am trying to see the stochastic peak and trough on one chart,
i have a small error in the below code can you please help, it does not compile, thanks
CODE:
Please log in to see this code.
profile picture

Eugene

#10
Kindly reconsider throwing different independent strategies together via copy/paste. You've been already told that this "approach" does not work in programming at all and in Wealth-Lab in particular. Regardless of how it's called this time, "small error" or "composed":

Trading between Support & Resistance

You've exceeded the capability of Rule-based strategies but constant tweaks to custom code or teaching you how to program is not part of the support plan. Show us that you learn C# 101 and not just keep doing the same thing (mistake) over and over. There are a large number of free web resources, books, tutorials (even on our Wiki FAQ) to help out in your C# study.

Good luck in your venture!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).