Hi everyone!
This strategy buy or sell if price breaks max or min night range with an “spread” difference (optimized by variable “s”), and then is stopped at SAR crosses.
It has money-management included, system will calculate risk before setting up orders and join with the contracts updated with “STRATEGYPROFIT” var.
I’m thinking to trade it real mode and maybe you could help me to improve it, is my really first one you know…
Best wishes!
REM Cumulate orders
DEFPARAM CumulateOrders=true
REM Operative time
DEFPARAM FlatBefore = 090000
DEFPARAM FlatAfter = 212900
REM Indicadores
parabolic = SAR[0.02,0.02,0.2]
REM Variables
maximo = Highest[4](high)
minimo = Lowest[4](low)
ultimotrade = BARINDEX-TRADEINDEX
REM Condiciones
C1 = PARABOLIC>HIGH
C2 = PARABOLIC<LOW
C3 = uLtimotrade>1
if time=080000 then
maximoN=dhigh(0)
minimoN=dlow(0)
endif
REM CONFIGURACION DE ESTRATEGIA
REM GESTION MONETARIA
REM Cálculo de contratos a operar
capitalinicial = c //Capital
riesgo = r // riesgo por operación
spread = s
equity = capitalinicial+strategyprofit
maxriesgo = round(equity*riesgo)
pipstop = abs(round(maximo-minimo))
myLOT = abs(round(((maxriesgo/pipstop)/PointValue)*pipsize))
if mylot<1 then
mylot=1
else
myLOT = abs(round(((maxriesgo/pipstop)/PointValue)*pipsize))
endif
REM PRIMERA COMPRA
IF TIME>=090000 AND TIME<=094500 AND NOT ONMARKET AND C3 THEN
REM ENTRAR AL MERCADO DENTRO DEL RANGO
IF CLOSE<maximoN and CLOSE>minimoN and c1 then
sellshort myLOT contract at minimoN-spread*pipsize stop
buy myLOT contract at parabolic+spread*pipsize limit
ENDIF
IF CLOSE<maximoN and CLOSE>minimoN and c2 AND C3 then
sellshort myLOT contract at parabolic-spread*pipsize stop
buy myLOT contract at maximoN+spread*pipsize limit
ENDIF
REM ENTRAR AL MERCADO POR ENCIMA DEL RANGO
IF CLOSE>maximoN and c2 AND C3 then
buy myLOT contract at market
endif
REM ENTRAR AL MERCADO POR DEBAJO DEL RANGO
IF CLOSE<minimoN and c1 AND C3 then
sellshort myLOT contract at MARKET
endif
ENDIF
rem si estoy largo
if longonmarket and c1 AND C3 then
breakeven = minimo
SELLSHORT AT minimo STOP
endif
if longonmarket and c2 AND C3 then
breakeven = parabolic
sellSHORT at breakeven-spread*pipsize stop
endif
rem si estoy corto
if shortonmarket and c1 AND C3 then
breakeven = parabolic
BUY at breakeven+spread*pipsize stop
endif
if shortonmarket and c2 AND C3 then
breakeven = maximo
BUY at breakeven+spread*pipsize stop
endif
No confusing closes at bar 0. +info