Anyone of you guys has an idea how to solve the problem? I found the code in the spanish forum. the backtest is unreal I think.
// Definición de los parámetros del código
DEFPARAM CumulateOrders = false
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 220000
// Impide al sistema operar en días precisos de la semana
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
x = 4
IF BarIndex - TradeIndex = x Then
Sell at Market
endif
IF BarIndex - TradeIndex = x Then
exitshort at Market
endif
// Condiciones para entrada de posiciones largas
indicator1 = CCI[30]//30
c1 = (indicator1 > 0)
indicator2 = DPO[15](close)//15
c2 = (indicator2 < 0)
IF (c1 AND c2) AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Condiciones de salida de posiciones largas
indicator3 = CCI[30]//30
c3 = (indicator3 CROSSES OVER 100)//100
IF c3 THEN
SELL AT MARKET
ENDIF
// Condiciones de entrada de posiciones cortas
indicator4 = CCI[30]//30
c4 = (indicator4 < 0)
indicator5 = DPO[15](close)//15
c5 = (indicator5 > 0)
IF (c4 AND c5) AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Condiciones de salida de posiciones cortas
indicator6 = CCI[30]//30
c6 = (indicator6 CROSSES UNDER 150)//180
IF c6 THEN
EXITSHORT AT MARKET
ENDIF
// Stops y objetivos
SET STOP %LOSS 0.2
SET TARGET %PROFIT 0.2
DPO use future datas, which is of course impossible in real time, but possible in history. That’s why this indicator is not available in automatic trading and why you get amazin results in backtests.
There are many topics around that deal with DPO of future and past datas (which is a code that use the same calculation but with current available data, not the future ones, and just like any other indicators!).