Good Morning,
I share my first code based on a well-known strategy.
I tried to make it as simple as possible and not fill with indicators and triggers. A simple strategy following a reversion pattern of bars and a mean exp of 40 periods.
I would like to improve it and are welcome any of your contributions and opinions of money management, stop loss optimization, etc.
I’ve placed it in ProOrder Autotrading in Demo to see how it behaves.
Regards,
Gbp usd in 4 hour timeframe
Buenos días,
Comparto mi primer código basado en una estrategia por demás conocida.
Traté de hacerlo lo más sencillo posible y no llenar de indicadores y triggers. Una estrategia sencilla siguiendo un patrón de reversion de barras y una media exp de 40 períodos.
Me gustaría mejorarlo y son bienvenidos cualquiera de sus aportes y opiniones de money management, optimización de stop loss, etc.
Lo he colocado en el ProOrder Autotrading en Demo a ver como se comporta.
Saludos,
gbp usd en timeframe de 4 horas
// Condiciones para entrada de posiciones largas
EMA40 = ExponentialAverage[40](close)
nbar = 4
//Filtro://
//FDI (fractal dimension index) de 30 //
N = 30
once fdi=undefined
if barindex >= n-1 then
diff=0
length = 0
pdiff = 0
hh=0
ll=0
FDI=0
HH = highest[N](close)
LL = lowest[N](close)
for Period = 1 to N-1 do
if (HH - LL) > 0 then
diff = (customclose[Period] - LL) / (HH - LL)
if Period > 1 then
length = length + SQRT(SQUARE(diff - pdiff) + (1 / SQUARE(N)))
endif
pdiff = diff
endif
next
if length > 0 then
FDI = 1 + (LOG(length) + LOG(2)) / LOG(2 * (N))
else
FDI = 0
endif
endif
//profit step of the strategy to increase lot
positionsize = 1
C4 = EMA40 CROSSES OVER CLOSE
C3 = BARINDEX - TRADEINDEX = NBAR
C5 = CLOSE CROSSES UNDER EMA40
IF not longonmarket and open > close[1] and C4 and FDI<1.5 THEN
BUY positionsize LOT AT MARKET nextbaropen
ENDIF
//Condiciones de salida de posiciones largas
If LongOnMarket AND C3 THEN
SELL AT MARKET
endif
//Condiciones de entrada de posiciones cortas
IF NOT ShortOnMarket AND open < close[1] and C5 and FDI<1.5 THEN
SELLSHORT positionsize LOT AT MARKET nextbaropen
ENDIF
// Condiciones de salida de posiciones cortas
IF ShortOnMarket AND C3 THEN
EXITSHORT AT MARKET
endif
//Stops y objetivos: introduzca aquí sus stops de protección y objetivos de beneficios
set stop ploss 60