Stochastic K and D lines
Forums › ProRealTime English forum › ProOrder support › Stochastic K and D lines
- This topic has 20 replies, 5 voices, and was last updated 5 years ago by
s00071609.
-
-
05/05/2018 at 11:17 AM #69818
Hi all,
I have some problem coding the stochastic. I have set the Stochastic to (79,3,4) in the indicators section, but when it come to coding only shows two parameters: Stochastic [79,3]. I would like to create a condition when %K crosses over %D or viceversa, but I don’t see it.
I have reviewed the library in search of similar strategies with stochastic but nothing so far.
Any suggestions?
Thanks so much in advance.
Juan
05/05/2018 at 12:35 PM #69827I think i got it. I found an old result from Nicolas in the Forums.
1234K = stochastic[14,3]D = average[4](K)RETURN K, DThanks anyway,
Juan
02/24/2019 at 11:34 PM #92211Did you manage to write the correct screener code for the stochastic crossover?
If you did would you be able share it please?
Thank you
02/25/2019 at 1:27 AM #92218Did you manage to write the correct screener code for the stochastic crossover?
If you did would you be able share it please?
Thank youJuan Salas‘s code is correct, to code a crossing just write:
Croosover/under12CrossOver = K crosses over DCrossUnder = K crosses under DIf you search in the library for a Stochastic screener you’ll find some.
02/25/2019 at 10:54 AM #92235Did you manage to write the correct screener code for the stochastic crossover?
If you did would you be able share it please?
Thank you
Hi, disciplinet,
Roberto is right. I am sending you a piece of code similar to what Roberto sent:
123456789101112131415161718// Indicators ///////////////////////stoch76K= Stochastic[76,3]long50=stoch76K crosses over 50 // Entrada en largo normal al cruzar al alza 50long80=stoch76K crosses over 80 // Reentrada en largo en >80short50=stoch76K crosses under 50 // Entrada en corto normal al cruzar a la baja 50short20=stoch76K crosses under 20 // Reentrada en corto en <20// Estocastico lentoD76 = average[4](stoch76K) // Dstoch76K= Stochastic[76,3] // Kcrucelentoalza=stoch76K crosses over D76crucelentobaja=stoch76K crosses under D76// Estocastico rapidoD8 = average[3](stoch8K) // Dstoch8K= Stochastic[8,3] // Kcrucerapidoalza=stoch8K crosses over D8crucerapidobaja=stoch8K crosses under D8I hope it can help you
1 user thanked author for this post.
09/24/2019 at 5:57 PM #108375I am have this code for stochastic in hourly TF. Pro Order should be placing order when, %K is above the %D (ie. %K>%D) and value of %D should be 32 and 75 before an order is placed. This is a bullish condition
But I have multiple orders being placed even when stochastic is bearish. All conditions should be true to open a buy position ie c2 and c3 and c4 should all be true..
Why is this dependency occurring with Pro Order Tests?
I have attached an image that clearly shows the stochastic does not meet the conditions.
12345678timeframe(1 Hour, updateonclose)indicator3 = Stochastic[5,3](close)indicator4 = Average[3](indicator3)c2 = (indicator3[3] > indicator4)indicator5 = Average[3](Stochastic[5,3](close))c3 = (indicator5 > 32)indicator6 = Average[3](Stochastic[5,3](close))c4 = (indicator5 < 75)09/24/2019 at 6:22 PM #108377Why line 4 refers to the 3rd previous candle?
This could be the logical error.
09/24/2019 at 6:41 PM #108380Ok thanks for pointing that out – that was an error. I corrected it, it improved by removing some of these orders, but there are still some that should not be there.
If you see the screenshot below, 2 orders are placed in same area, the first one is placed when the stochastic is clearly bearish.
How can i fix this? I want it to place orders when stochastic is bullish only.
12345678timeframe(1 Hour, updateonclose)indicator3 = Stochastic[5,3](close)indicator4 = Average[3](indicator3)c2 = (indicator3 > indicator4)indicator5 = Average[3](Stochastic[5,3](close))c3 = (indicator5 > 25)indicator6 = Average[3](Stochastic[5,3](close))c4 = (indicator6 < 35)09/24/2019 at 7:04 PM #108382Without the complete code it is impossible to tell, it is likely conditions are not linked with AND.
Or if you use a smaller default TF a trade could be entered while conditions have changed because variables are updated only when the 1-hour bar closes.
If you need further help you should post your code to enable readers to replicate your trades, also specifying instrument and default TF used.
09/24/2019 at 8:12 PM #108386Here is the code, its daily and hourly TF being used,
1234567891011121314151617181920212223242526272829303132333435363738394041// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionstimeframe(Daily)indicator1 = Stochastic[5,3]indicator2 = Average[3](indicator1)indicator0 = Average[3](Stochastic[5,3])c1 = (indicator1 > indicator2)c0 = (indicator0 < 70)timeframe(1 Hour, updateonclose)indicator3 = Stochastic[5,3](close)indicator4 = Average[3](indicator3)c2 = (indicator3 > indicator4)indicator5 = Average[3](Stochastic[5,3](close))c3 = (indicator5 > 10)indicator6 = Average[3](Stochastic[5,3](close))c4 = (indicator6 < 40)LL = lowest[6](low) - 2*pointsizeSL = close [0] - LL//BARHIGH = HighREM Money ManagementCapital = 5000Risk = 0.01//Stoploss = 5//StopLoss = abs((BARHIGH - SL)/pointvalue) // Could be our variable XREM Calculate contractsequity = Capital + StrategyProfitmaxrisk = round(equity*Risk)PositionSize = abs(((maxrisk/SL)/PointValue)*pipsize)IF c0 AND c1 AND c2 AND c3 AND c4 THENBuy Positionsize CONTRACT AT MARKETset stop Loss SLSet target profit SL*6ENDIF09/24/2019 at 9:04 PM #108390What TF did you take that pic from?
When you look at the daily chart keep in mind that previous daily bars only show the pic at closing time, while you did not use updateonclose thus at runtime values can be differrnt from hour to hour.
09/24/2019 at 9:09 PM #10839109/24/2019 at 9:23 PM #108392What time and instrument were those wrong trades?
09/24/2019 at 9:28 PM #10839309/24/2019 at 11:29 PM #108402For Spot GOLD I have no trades opened from Aug.20th through Aug 31st.
-
AuthorPosts
Find exclusive trading pro-tools on