Hi, I tried to use an old adx indicator and system in order to create the system below.
It is based in the stochastic K and D indicator. The intention is that when stochastic stay in the overbought level at least 18 bars, once that it goes to the oversold level, a buy order is generated. The opposite happens if it stays 18 bars in the oversold territory.
As I do not know how to program, I also tried to created the strategy from rules to combine both.
There are some errors in line 30 and 53, someone could help?
CODE:
Please log in to see this code.
Size:
Color:
Hi Antonio,
QUOTE:
"when stochastic stay in the overbought level at least 18 bars"
Firstly, this code won't help you program the desired condition(s). Before attempting to code my version, I need to find out something. Let's imagine the Stoch managed to stay in the overbought zone for at least 18 bars, and then dropped, say, 5 points - i.e. not enough to go oversold, but then again went overbought. Does that invalidate the whole sequence or you don't care about the stochastic dipping a little and still would wait for it to go oversold eventually?
Size:
Color:
Thanks for the reply Eugene. In this case the system should not care, in this case it is called a false movement and would not trigger the buy sign. ( I do not know if is possible, but in this case the system should still consider overbought level ). It will only trigger the but sign when it goes to the oversold level (20 level or sometimes the power of buyers is so strong that it does not go to the level, stays around 30 or 35, in this case the system should miss the trigger). The exit position should appear when the stochastic returns to the oversold level.
Size:
Color:
QUOTE:
The exit position should appear when the stochastic returns to the oversold level.
Does this imply an extra condition? Please clarify: should the trailing stop be triggered by itself or it depends on stochastic reaching certain level?
Size:
Color:
No it is not an extra condition. There is only one condition to get out of the position. Is when the stochastic reaches the opposite level (where it was originally with the 18 bars side).
Size:
Color:
Here's the code of your system as I understood it.
Note: after staying ob/os for 18 bars, a successive signal while waiting for an entry [e.g. crossing back to overbought for a buy signal] cancels the whole sequence, and the system moves on.
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
There is only one condition to get out of the position.
In your code, the only one exit condition is a Donchian-type channel breakout/breakdown trailing stop. This is the exit I've coded in above.
Size:
Color: