I posted “Bullish and Bearish Forex Screeners (based on 3 indicators)” about 4 months ago and had a lot of suggestions and support from @Nicolas, @Sofitech and @Doctrading to develop an automatic trading system.
Well, after a lot of testing, I have come up with the attached system. It seems to be happier in the longer time frames viz. H4 up. I have posted it with two variables, a and b, which are the parameters for the SuperTrend indicator. Since this is the exit signal, it is important to optimise these variables for the instrument you plan to trade. Then enter the results of the optimisation into the code and prepare it for automatic trading. I suggest you test it forward first before committing real money.
I found a wonderful site for the procedures involved in creating and testing a strategy at https://trading.prorealtime.com/en/create-a-trading-system, for those of you who haven’t found it already.
I have also attached the results from 4 tests, of which the DAX was the most spectacular, with 2000% gain in about 15 weeks. However it had the largest drawdown.
So have fun playing with this. I look forward to your suggestions for improvements.
DEFPARAM CumulateOrders = true // Cumulating positions activated
// Indicators
COI = WEIGHTEDAVERAGE[10](ROC[14] +ROC[11])
MAC = MACDline[12,26,9](close)
STO = Stochastic[14,3](close)
ST = Supertrend[a,b]
// Conditions to enter long positions
c1 = COI > COI[1] AND COI < 0
c2 = MAC > MAC[1] AND MAC < 0
c3 = STO > 20 AND STO < 40
IF Not ShortOnMarket AND c1 AND c2 AND c3 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
c5 = close crosses over ST
IF c5 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
c11 = COI < COI[1] AND COI > 0
c12 = MAC < MAC[1] AND MAC > 0
c13 = STO < 80 AND STO > 60
IF Not LongOnMarket AND c11 AND c12 AND c13 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
c15 = close crosses under ST
IF c15 THEN
EXITSHORT AT MARKET
ENDIF