Stochastic Vs Price Divergence indicator help
Forums › ProRealTime English forum › ProBuilder support › Stochastic Vs Price Divergence indicator help
- This topic has 16 replies, 4 voices, and was last updated 5 years ago by GraHal.
-
-
03/28/2018 at 8:27 AM #66603
Hi
I was hoping someone with better coding knowledge could help to create an indicator that looked for the following two triggers. I tried to a adapt some of the indicators found on this site but my attempts have failed miserably. I have found this to be an extremely reliable indicator for near term direction change regardless of chart time frame ie. 1, 5, 60 min, daily timeframe. Infact confirmation on multiple timeframes is even a stronger indication.
Should be coupled with manual assessment of oversold/overbought nature and infliction of longer duration Stochastic 40,4,4 and 60,10.6 i.e lower probability when longer time frames are embedded in overbought or oversold territory.
Buy divergence
- Price formed a Lower Low (confirmed by a higher close price on the following bar) and the corresponding 14,3,3 Stochastic %K has formed a Higher Low
Sell divergence
- Price formed a Higher High (confirmed by a lower close price on the following bar) and the corresponding 14,3,3 Stochastic %K has formed a Lower High
03/28/2018 at 12:43 PM #66625For an additional example in the attached the indicator would not trigger until the later Higher High in price even though there are lower minor highs that happen between the two obvious peaks.
Ideally the code would look for the peaks to occur with in a modifiable number of periods .
Thanks
Kevin
03/28/2018 at 1:06 PM #66627Trading with short term divergence coupled with a secondary confirmation like a MACD cross can be very powerful and high probability. The attached is an example of 4 short term trades on the DAX.
The chart is 28/3/2018 from 6-11pm Australian time to 2min timeframe present 4 trade opportunities results were.
18:56 buy 25points
19:32 Sell 40 points
19:52 Buy 20 points
22:28 buy Stopped 0 points
03/28/2018 at 2:27 PM #66629Some links where you can find pretty good solutions that you can tailor to your needs:
https://www.prorealcode.com/reply/18544/
https://www.prorealcode.com/topic/divergences-tti-stoch-extreme/
https://www.prorealcode.com/topic/request-to-code-opposite-divergences/
04/30/2018 at 2:35 PM #6947504/30/2018 at 2:48 PM #69479Indicators/Oscillators should only use RETURN as the last line, not SCREENER which is a keyword reserved to ProScreener only, so you should remove (or simply comment out) that line.
05/02/2018 at 9:40 AM #69617Hi Robert
I have been able to get two to work but they don’t seem to identify the situations I am looking for. I can not get the “https://www.prorealcode.com/topic/divergences-tti-stoch-extreme/” to work. In it presented state it errors, but in noticed there seems to be a lot of lines that are commented out. I have tired to play around with reinserting them but it only produces further errors. Can you please advise?
Thanks
Kevin
05/02/2018 at 1:40 PM #69647Commented lines were added by the author for debugging purposes, you should either ignore or remove them.
I am using it and it works (see my screenshot). Of course it most often detects divergences which are slightly divergent! But this is an issue code cannot solve, while your eyes can!
Automated strategies are a quite different from manual trading; if a price HIGHEST is 12600 and the CLOSING price reached 12599 then pulled back, you can see it as double top while a stgrategy would not!
05/03/2018 at 9:06 AM #69695Thanks Robert
I tried it again against a different index chart and now it works. It looks like this would form a really good basis for what I am trying to achieve. Please understand I am not good at programing, generally I use the standard offering that can be selected. So I am sorry if these questions are basic but as I cant “read” and understand all the programing I am not clear on what is actually being compared.
The program compares the price higher high or lower low to the divergence of a Stochastic line. What is the setting of the line for example: is it K on a Stochastic of 11,3,3 or something else?
Which line in the program set the Stoch to be used…line number?
The code asks for a variable to be defined “ma”, what is this variable and what do you set it to?
Thanks
Kevin
- It is comparing twweeeerrf
05/03/2018 at 10:04 AM #69701This is the one I use (you can import attached .ITF file from within ProBuilder), I can’t fine where I found it, but for sure it is somewhere in this forum
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// DIVERGENCES STO adapted from HK-LISSE code// p = 14 //Stochastic periods// k = 3 //K line value// d = 6 //D line value (used by Average)x = stochastic[p,k] //X is this is the K liney = average[d](x) //Y is the D line (an SMA of K line)if x>overboughtzone thenhi=max(hi,x)hico=max(hico,max(high,high[1]))endifif x crosses under y thensto2b=sto1bsto1b=hihi=0p3b=p1bp2b=max(p1b,hico1)p1b=max(highest[3](high),hico)if p2b=p1b thenp2b=max(p3b,p4b)endifhico=0hico1=0endifif x<y thenp4b=hico1hico1=max(hico1,high)endifif p1b>p2b and sto1b<sto2b and x crosses under y and x<x[1] thensignB= -2elsesignB= 0endifif x<oversoldzone thenlo=min(lo,x)lowco=min(lowco,min(low,low[1]))endifif x CROSSES OVER y thensto2h=sto1hsto1h=lolo=100p3h=p1hp2h=min(p1h,lowco1)p1h=min(lowest[3](low),lowco)if p2h=p1h thenp2h=min(p3h,p4h)endiflowco=100000lowco1=100000endifif x>y thenp4h=lowco1lowco1=min(lowco1,low)endifif p1h<p2h and sto1h > sto2h and x crosses over y and x>x[1] thensignH= 2elsesignH= 0endif////////////////////////////////////////////////return signH as " div STO bull ", signB as " div STO bear " , 0 as " zero "05/03/2018 at 10:08 AM #69702As for STOCHASTIC, in your code you define it as:
Stochastic 14,3,312Kline = Stochastic[14,3](close) //14,3Dline = Average[3](Kline) //3then you can reference a BULLISH crossing over the OS zone:
1IF Kline CROSSES OVER 20 AND Kline > Dline THEN....05/03/2018 at 12:18 PM #69716Hi Robert
Each of the examples you have provided I believe contains parts of what I am looking to achieve, but I am not experienced enough to strip the required parts out it and compile.
I only use Price and Stochastic K (regardless of overbought or oversold levels)
I wish to compare:
-When price makes a Higher close (HC) than a previous High and compare that to the corresponding two values of Stochastic K , if HC2 >HC1 and Sto2 < Sto1 than they re divergent (price is going higher but Sto is going lower) so “return an indication”
-When price makes a Lower close (LC) than a previous Low and compare that to the corresponding two values of Stochastic K , if LC2 < LC1 and Sto2 > Sto1 than they re divergent (price is going lower but Sto is going Higher) so Return an indication”
Often the situation looks very much like the image you attached, but sometime the divergences happens within two consecutive bars. From there it takes the human to analyse
Are you able to program this or should I use the custom coding request form to get a quote? I am grateful for your free help that you have given so far but I realise this is taking up your time.
Thanks
Kevin
05/03/2018 at 3:03 PM #69734I’ll have a try. I’ll let you know when I have a (hopefully) working code ready.
05/04/2018 at 5:48 PM #69794Sorry Fea, I tried to code something the way you need, but did not succeed easily. I think it could take too much time for me.
I suggest that you use the custom code form.
08/21/2019 at 9:48 AM #105161hi Roberto, I see that on this indicator we can put an alarm! I’m afraid I do not really understand … can we say to him, for example on bearish divergence, as soon as a higher vertex diverges with a lower vertex in formation thus in real, (not yet closed!) so I get an alert? I am looking for this kind of indicator that scan the differences in training … if yes pourrioez you communicate me the procedure to follow, because I could see alert settings in the indicator but I do not understand their interpretations well ..a big thank-you Excellent day
-
AuthorPosts
Find exclusive trading pro-tools on