If you have followed the thread found here: https://www.prorealcode.com/topic/profitable-strategy-that-work-on-any-market/
You will be aware that I have placed a challenge to the forum to create a universal market neutral strategy. In other words a strategy that can be adapted to any market without ANY optimization. Below is my attempt at exactly this. I have opted to add a trading time filter as all markets have their sweet spot.
No variables have to be optimized for this strategy to work other than the trading time and spread. Attached is 2 screenshots of the same code executed on 2 different markets (same 1Hr timeframe but different spreads) where in both instances the code has significantly outperformed Buy and Hold. Spread on CAC40 set to 3 and spread on ZAF40 set to 20.
Note that this strategy was not meant to be a jaw dropper in terms of performance but rather a proof of concept that a single strategy can be applied to different markets with positive results. Obviously optimizing this strategy to individual markets will yield better results but that was never the idea. Hopefully the whole ProRealCode community can benefit from this (and even improve on it).
//Stategy: Universal Bollinger Breakout/Reversal
//Author: Juan Jacobs
//Market: Neutral
//Timeframe: 1Hr but not timeframe dependant
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
If hour > 0 and hour < 18 then //(CAC: 0-18, ZA: 0-18, DAX: 9-13,OMX: 8-11, US: 8-16, FTSE: 15-22, DOW: 8-22, EUR/USD: 9-23, AUD/USD: 3-17, GBP/USD: 10-23, EUR/GBP: 0-13, USCrude: 17-21, BrentCrude: 16-22, Gold: <2 or >22)
possize = 2
Else
possize = 0
EndIf
If dayofweek >= 5 and hour > 22 Then
If longonmarket Then
Sell at market
ElsIf shortonmarket Then
Exitshort at market
EndIf
EndIf
// Conditions to enter long positions
Periods = 42
Deviations = 1.618
PRICE = LOG(customclose)
alpha = 2/(PERIODS+1)
if barindex < PERIODS then
EWMA = AVERAGE[3](PRICE)
else
EWMA = alpha * PRICE + (1-alpha)*EWMA
endif
error = PRICE - EWMA
dev = SQUARE(error)
if barindex < PERIODS+1 then
var = dev
else
var = alpha * dev + (1-alpha) * var
endif
ESD = SQRT(var)
BollU = EXP(EWMA + (DEVIATIONS*ESD))
BollL = EXP(EWMA - (DEVIATIONS*ESD))
LongMA = Average[100](close)
RS2 = RSI[2](close)
ATR = AverageTrueRange[2](close)
If close > LongMA and RS2 > 70 and close[1] > BollU and close > BollU and open > open[2] Then
Buy possize contract at market
ElsIf close > LongMA and RS2 < 50 and close[1] > BollU and close < BollU Then
Sellshort possize contract at market
EndIf
If close < LongMA and RS2 < 40 and close[1] < BollL and close < BollL and open < open[2] Then
Sellshort possize contract at market
ElsIf close < LongMA and RS2 > 50 and close[1] < BollL and close > BollL Then
Buy possize contract at market
EndIf
If longonmarket and ((close < close[1] - ATR and RS2 < 5)) Then
Sell at market
ElsIf shortonmarket and ((close > close[1] + ATR and RS2 > 95)) Then
Exitshort at market
EndIf
You must be logged in to post a comment.
If longonmarket and ((close[2] > BollU and close[1] > BollU and close BollU and high[1] > BollU and high < BollU)) Then LE = 1 ElsIf shortonmarket and ((close[2] < BollL and close[1] BollL) or (low[2] < BollL and low[1] BollL)) Then SE = 1 EndIf If ((close 95 Then Sell at market ElsIf ((close > close[1] + ATR) or (SE = 1)) and RS2 < 5 Then Exitshort at market EndIf
@nicolas it would be interesting to see the 200k bar backtests of the CAC40 and SAF40, if you can post them? Would also be interesting to see if another trading time-frame is maybe better suited back then? I also think that maybe we can look into adding a different stop mechanism, maybe something like your trailing stop? The idea is for the PRC COMMUNITY to build onto this to get it to perform even better and more consistently on all markets.
I just want to expand a bit on the mechanics of how this strategy should theoretically perform in both ranging and trending markets. The idea is that in a ranging market you would likely see Bollinger reversals between the bands whereas in a trending market you would see a successful Bollinger breakout. This strategy aims to take advantage of both. Then also just to be fair (in answering Nicolas's question above) although I mentioned the strategy to be timeframe independent, it would more accurate to just call it market neutral. The above set of 'static' variables is more suited to a specific timeframe. For lower timeframes such as the 5min chart, a smaller MA such as 50 would likely be 'more' suited along with an ATR[1] period. However once configured for an timeframe, it should be compatible between different markets on that timeframe.
Thanks for this interesting concept. I successfully test the strategy on DAX and Bund (same kind of results as your other tests on SAF40 and CAC40), but I'm not able to get relevant backtests on other timeframes than 1 hour, and because you stated that this trading strategy is "non timeframe dependent", that's why I'm talking about it. Good job!
@juanj wondering if you may help me please. I am looking for a simply strategy to use on the South African Alsi through IG markets, would you be able to discuss this with me? Thanks