The MA-RSI Winner
Forums › ProRealTime English forum › ProOrder support › The MA-RSI Winner
- This topic has 3 replies, 2 voices, and was last updated 4 years ago by
Nicolas.
-
-
05/24/2020 at 4:44 PM #133058
Hi All,
This is my first strategy. Works really well on the 1HR timeframe on most Forex Pairs and most notibly on GBP/AUD.
It uses the RSI indicator of 8 periods to identify volume at both 40 and 60 respectively to either go long or short. This is then paired with a Moving Average of 22 (Optimised) to look at crossovers for entering and exiting the trades.
It uses a 4 Point/Pip Trailling Stop.
What would I like to add?
I would like to use an ATR at 20 periods to automatically calculate the Trailling Stop but I dont have the coding skills to add this.
Short position example
Current Timeframe Candle High price + (2*ATR) = Stop Loss
Long Position Example
Current Timeframe Candle Low Price – 2*ATR = Trailling Stop Value
In the example above i’ve used 2 ATR. Ideally i would want this to be configurable or at least easy to change the number in the code as an integer.
Appreciate any improvements, comments etc…
1234567891011121314151617181920212223242526272829303132333435363738394041// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = RSI[8](close)c1 = (indicator1 >= 60)indicator2 = ExponentialAverage[22](close)c2 = (close[1] > indicator2[1])IF c1 AND c2 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator3 = ExponentialAverage[22](close)c3 = (close < indicator3)IF c3 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator4 = RSI[8](close)c4 = (indicator4 <= 40)indicator5 = ExponentialAverage[22](close)c5 = (close[1] < indicator5[1])IF c4 AND c5 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator6 = ExponentialAverage[22](close)c6 = (close > indicator6)IF c6 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP pTRAILING 41 user thanked author for this post.
05/24/2020 at 4:48 PM #13308305/25/2020 at 7:55 PM #133232Hi @Nicolas
Hmmm, that may have stumped me…. I thought the backtest automated the spread cost within the backtest automatically based against the Forex pair brokerage fee. Clearly this isnt the case? I am using CFD’s to demo trade this. Also the Tick by Tick shows an error so unable to verify unfortunately.
When I do add a an average 1.57 pip spread it does decline considerably although still well profitable against a £500 start it finishes at £5K over 4 years backtesting alyjough the tick by tick may change that
is there an area within the forum to request assistance with coding the above Trailling Stop?
Best wishes,
Plaedies05/26/2020 at 10:58 AM #133294Tick by tick mode is mandatory when you want to test the stoploss to be triggered inside a candlestick, otherwise the results could be VERY different in live trading.
That’s why I always suggest to use a soft coded trailing stop in strategies AND to backtest with tick-by-tick mode enable (always!). There are many examples of trailing stop codes in forums and in the strategies posted in the library.
-
AuthorPosts