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