Trading system with EMA, SAR and Stochastic
Forums › ProRealTime English forum › ProOrder support › Trading system with EMA, SAR and Stochastic
- This topic has 14 replies, 5 voices, and was last updated 7 years ago by
Leo.
-
-
10/04/2017 at 3:01 PM #48200
A request that was addressed to ProRealTime:
Dear Sir or Madame,
I opened the account via the prorealtime homepage with IG Markets and would kindly like to ask for writing a code for trading system as follows:
Parameter
– Currency pair: AUD/USD (or other major pairs)
– 3 Min Candle Chart
– EMA 200
– Parabolic SAR (using the standard setting)
– Stochastic Indicator (13 ; 8 ; 3) / horizontal lines in the indicator are located at 25 (instead of 20) on the bottom and 75 (instead of 80) on the top
– Trading Hours 08:05 o’clock German time until 15:25 o’clock German time and 15:35 o’clock until 21:45 o’clockLong Order
• The current candle stick is trading above the EMA 200.
• Parabolic SAR is plotting below the current candle (green for uptrend).
• Stochastic is confirming the above with crossing upward (preferably the lines have crossed below the 25 horizontal line already)If the above conditions are all fulfilled, then:
• Buy 0,1 Lot (mini-Lot) with the open of the next candlestick.
• Stop-Loss is placed 2 pips below the Parabolic SAR.
• Target is 10 pips (might be changed, just do not know which is the best target at the moment but I assume that amending the target should be possible without difficulties).
• The Stop-Loss is a trailing stop which should be plotted always two pips below the Parabolic SAR.
• Position is closed when the price reaches the target or the stop loss.Short Order
• The current candle stick is trading below the EMA 200.
• Parabolic SAR is plotting above the current candle (red for downtrend).
• Stochastic is confirming the above with crossing downward (preferably the lines have crossed above the 75 horizontal line already)If the above conditions are all fulfilled, then:
• Sell 0,1 Lot (mini-Lot) with the open of the next candlestick.
• Stop-Loss is placed 2 pips above the Parabolic SAR.
• Target is 10 pips (might be changed, just do not know which is the best target at the moment but I assume that amending the target should be possible without difficulties).The Stop-Loss is a trailing stop which should be plotted always two pips above the Parabolic SAR.
• Position is closed when the price reaches the target or the stop loss.Trust the above is understandable. If you have any questions please contact me.
Thank you very much in advance and look forward to hearing from you.
Suggestion for an anwser:
1234567891011121314151617181920212223242526272829303132333435363738ParabolicSAR=SAR[0.02,0.02,0.2]EMA200=ExponentialAverage[200](close)mystoch=Stochastic[13,8](close)tradingtime=(time >= 080500 and time <152500) or (time >=153500 and time < 214500)c1=close > EMA200c2=close > ParabolicSARc3=mystoch crosses over 75if not longonmarket and tradingtime and c1 and c2 and c3 thenbuy 0.1 share at marketsell at ParabolicSAR-2*pointsize stopset target pprofit 10endifif longonmarket thensell at ParabolicSAR-2*pointsize stopendifc4=close < EMA200c5=close < ParabolicSARc6=mystoch crosses under 75if not shortonmarket and tradingtime and c4 and c5 and c6 thensellshort 0.1 share at marketexitshort at ParabolicSAR+2*pointsize stopset target pprofit 10endifif shortonmarket thenexitshort at ParabolicSAR+2*pointsize stopendifif not tradingtime thensell at marketexitshort at marketendif02/21/2018 at 1:08 AM #63335Bonjour,
Ce système ne semble pas marcher chez moi sur les actions :
> que faudrait-il changer (désolé mes connaissances de programmation sont réduites) !
Merci d’avance !!
Chris
02/21/2018 at 5:56 AM #6333602/21/2018 at 10:29 AM #63360I think is missing the stochastic lines crossing. Cross over in the last 5 bars:
123StochD=Average[Pd](myStoch)Cx= myStoch crosses over StochDCx1= highest[5](Cx)=1Line 3 should read
1Cx1= summation[5](Cx)02/22/2018 at 3:03 PM #63526Hi Roberto,
Thanks for your answer ; so what would be the full code to deal with stocks ?
BTW, do you know how to set a timeframe for backtest ?
Best,
Chris
02/22/2018 at 3:56 PM #63539Here is the full code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344ParabolicSAR=SAR[0.02,0.02,0.2]EMA200=ExponentialAverage[200](close)mystoch=Stochastic[13,8](close)tradingtime=(time >= 080500 and time <152500) or (time >=153500 and time < 214500)c1=close > EMA200c2=close > ParabolicSARc3=mystoch crosses over 75StochD=Average[Pd](myStoch)Cx = myStoch crosses over StochDCx1= summation[5](Cx)Cy = myStoch crosses under StochDCy1= summation[5](Cy)if not longonmarket and tradingtime and c1 and c2 and c3 and Cx1 thenbuy 0.1 share at marketsell at ParabolicSAR-2*pointsize stopset target pprofit 10endifif longonmarket thensell at ParabolicSAR-2*pointsize stopendifc4=close < EMA200c5=close < ParabolicSARc6=mystoch crosses under 75if not shortonmarket and tradingtime and c4 and c5 and c6 and Cy1 thensellshort 0.1 share at marketexitshort at ParabolicSAR+2*pointsize stopset target pprofit 10endifif shortonmarket thenexitshort at ParabolicSAR+2*pointsize stopendifif not tradingtime thensell at marketexitshort at marketendifWhen a backtest is launched it uses the current TF on the chart, just change it.
1 user thanked author for this post.
02/22/2018 at 4:36 PM #63550Thanks Roberto for the code and your answer 😉 (I don’t get it; apprently the Trading Systems I tried keep taking M5 for the backtest even if I am on the daily time frame ..;
I would be interested in your advice for the best automatic trading system you have used on stocks !!
I am struggling to find one profitable ;
Are you using this ATS ?
Best,
Chris
02/22/2018 at 4:42 PM #63555Sorry, I don’t trade stocks!
I use ATS only on demo accounts and just a few FX pairs + DAX.
1 user thanked author for this post.
02/22/2018 at 4:44 PM #63556Roberto,
Here is what it returns ; what do I need to do ? Thanks !
02/22/2018 at 5:13 PM #63558Leo wrote that line of code assuming you know what to write within brackets, i.e. the number of periods for the Average to be used with Stochastic. Just replace PD with your desidered value. This line of code is with number 3:
1StochD=Average[3](myStoch)02/22/2018 at 5:37 PM #63560Hi Roberto,
Still not working sorry; would you mind checking is in PRT yourself when you have 5 mn?
Thanks ;
Chris
02/22/2018 at 5:44 PM #63562On which instrument and TF are you testing it?
02/23/2018 at 12:30 AM #6360102/23/2018 at 1:30 PM #6366702/23/2018 at 10:50 PM #63759Hi GraHal,
Thanks to your comment, it sparks an idea to me ,I posted in a new forum
https://www.prorealcode.com/topic/pseudostochastic-trade/
-
AuthorPosts
Find exclusive trading pro-tools on