hi all
i have this code that works very well but i don’t like the system of accumulation
//-------------------------------------------------------------------------
// Code principal : MonSystème(196)
//-------------------------------------------------------------------------
// Definición de los parámetros del código
DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
DEFPARAM FlatAfter =173000
capital=strategyprofit+10000
n=capital/1000
if n>100 then
n=100
endif
if n<10 then
n=10
endif
HoraEntradaLimite = 090600
HoraInicio = 090500
HoraEntradaLimite1 = 091600
HoraInicio1 = 091500
HoraEntradaLimite2 = 093100
HoraInicio2 = 093000
if dayofweek=1 then //Monday
daytrading=1
endif
if dayofweek=2 then // Tuesday
daytrading=1
endif
if dayofweek=3 then // Wednesday
daytrading=1
endif
if dayofweek=4 then //Thursday
daytrading=1
endif
if dayofweek=5 then // Frifay
daytrading=1
endif
if Time >= HoraInicio and time <= HoraEntradaLimite and daytrading= 1 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and daytrading= 1 or Time >= HoraInicio2 and time <= HoraEntradaLimite2 and daytrading= 1 then
c1 = open < close-2
if not onmarket then
IF c1 THEN
buy n contract AT close+2 stop
endif
c2= open > close-1
IF c2 THEN
sellshort n contract AT close-1 stop
endif
endif
endif
SET STOP ptrailing 5
i would like to put in the accumulation of this system , i ve tried to code it but it seems to not work…. it give no results
//-------------------------------------------------------------------------
// Code principal : MonSystème(197)
//-------------------------------------------------------------------------
// Definición de los parámetros del código
DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
// La posición se cierra a las 17:29 p.m. si no toca ni stop ni take.
DEFPARAM FlatAfter =173000
once ordersize=1
// No se abren nuevas posiciones después de la vela que se cierra a las 09:06
HoraEntradaLimite = 090600
// El análisis de mercado empieza en la vela de 5 minutos que cierra a las 09:05
HoraInicio = 090500
// Órdenes máximas
if Ordersize>18 then
Ordersize=18
endif
// Riesgo, multiplicador de contratos.
n=6
// Condiciones para el analisis.
if Time >= HoraInicio and time <= HoraEntradaLimite then
// Condiciones de entrada de posiciones largas.
c1 = open < close-1
IF c1 THEN
IF PositionPerf(1) < 0 THEN
OrderSize = OrderSize/2//+1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
endif
// Si la primera barra del día de 5 min es positiva, compramos.
buy ordersize*n shares at market
endif
// Condiciones de entrada de posiciones cortas.
c2= open > close-1
IF c2 THEN
iF PositionPerf(1) < 0 THEN
OrderSize = OrderSize/2//+1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
ENDIF
// Si la primera barra del día de 5 min es negativa, vendemos.
sellshort ordersize*n shares at market
endif
endif
SET STOP ploss 5
SET TARGET pPROFIT 10
results for the first system very nice
Hello Paris,
maybe like this?
DEFPARAM CumulateOrders = true
DEFPARAM FlatAfter =173000
once ordersize=1
// Órdenes máximas
if Ordersize>18 then
Ordersize=18
endif
// Riesgo, multiplicador de contratos.
n=6
HoraEntradaLimite = 090600
HoraInicio = 090500
HoraEntradaLimite1 = 091600
HoraInicio1 = 091500
HoraEntradaLimite2 = 093100
HoraInicio2 = 093000
if dayofweek=1 then //Monday
daytrading=1
endif
if dayofweek=2 then // Tuesday
daytrading=1
endif
if dayofweek=3 then // Wednesday
daytrading=1
endif
if dayofweek=4 then //Thursday
daytrading=1
endif
if dayofweek=5 then // Frifay
daytrading=1
endif
if Time >= HoraInicio and time <= HoraEntradaLimite and daytrading= 1 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and daytrading= 1 or Time >= HoraInicio2 and time <= HoraEntradaLimite2 and daytrading= 1 then
c1 = open < close-2
if not onmarket then
IF c1 THEN
IF PositionPerf(1) < 0 THEN
OrderSize = OrderSize/2//+1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
endif
buy ordersize*n contract AT close+2 stop
endif
c2= open > close-1
IF c2 THEN
iF PositionPerf(1) < 0 THEN
OrderSize = OrderSize/2//+1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
ENDIF
sellshort ordersize*n contract AT close-1 stop
endif
endif
endif
SET STOP ptrailing 5
just before to go beyond of course these two codes are from raul .
ok thanks derek thanks for your code , it works perfectly , i put it on my collection .
but it is not exctly what i wanted to do .
The basis of the new strategy is the first code , so it only go long no shorts , and i want to replace in it , the accumulation , wich is in the second code
once ordersize=1
// No se abren nuevas posiciones después de la vela que se cierra a las 09:06
HoraEntradaLimite = 090600
// El análisis de mercado empieza en la vela de 5 minutos que cierra a las 09:05
HoraInicio = 090500
// Órdenes máximas
if Ordersize>18 then
Ordersize=18
endif
// Riesgo, multiplicador de contratos.
n=6
// Condiciones para el analisis.
in the first code i want to ” gear ” the orders , by now it always send 10 contracts and i dont like that .
@Paris Your first code states below so it will trade 10. But I’m sure you can see that so I must be confused what you are saying?
if n<10 then
n=10
endif<br><br>
buy n contract AT close+2 stop
endif
Hello Paris,
this was just a copy & paste of the position sizing from system 2 into system 1 and, I admit, I did not run the code myself.
yes i understand why it only trade 10 , but i want that trades like the second ….
for example :
c1 = open < close-2
if not onmarket then
IF c1 THEN
buy n*ordersize contract AT close+2 stop
endif
c2= open > close-1
IF c2 THEN
sellshort n*ordersize contract AT close-1 stop
endif
endif
endif
By the way: Both systems you posted go short.
@ grahal , no …. more like the way that raul do it , in second code
@ derek , you are right ,my mistake sorry …. ” sellshort ” is a short order , i was thnking of just ” sell “