Good afternoon,
This robot simply tries to buy or sell in the direction of the first 5 minutes of the market, ie if the first bar 5 minutes from the opening at 9am is positive, we buy, otherwise we sell.
With a spread of 1 point in the DAX mini 1 € and a time frame of 5 min.
In addition, it has an accumulator, in case the operation wins, the next day we will add 2 contracts, in case of losing the operation, we will divide between two contracts that we put the next day. Example:
Day 1: 1 contract -> We win; Day 2: 3 contracts-> We win; Day 3: 5 contracts-> We lost; Day 4: 3 (2.5) contracts-> We win; Day 5 = 5 contracts …
In addition, it has a manual multiplier to assume greater or lesser risk with the number of contracts.
There are also a maximum number of contracts.
IMPORTANT: For a faithful backtest, you must use PRT v10.3, in v.10.2 the results are NOT real.
A discussion thread is ongoing on the forum about the settings and feedback about the strategy, you can read, ask your questions and participate here: https://www.prorealcode.com/topic/5-min-mini1e-dax-spread-1/
//—————–
Buenas tardes,
Este robot trata simplemente de comprar o vender en la dirección de los primeros 5 minutos del mercado, es decir, que si la primera barra de 5 minutos desde la apertura a las 9h es positiva, compramos, en caso contrario, vendemos.
Con un spread de 1 punto en el DAX mini 1€ y un time frame de 5 min.
Además, tiene un acumulador, en el caso de que la operación resulte ganadora, al día siguiente sumaremos 2 contratos, en el caso de perder la operación, dividiremos entre dos los contratos que metemos al día siguiente. Ejemplo:
Día 1: 1 contrato -> Ganamos; Día 2: 3 contratos-> Ganamos; Día 3: 5 contratos-> Perdemos; Día 4: 3 (2,5) contratos-> Ganamos; Día 5= 5 contratos…
Además, tiene un multiplicador manual para asumir mayor o menor riesgo con la cantidad de contratos.
También hay puesto un máximo de contratos.
IMPORTANTE: Para un backtest fiel, hay que usar PRT v10.3, en la v.10.2 los resultados NO son reales.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
// 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 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hi Raul, thanks a lot for your post. I tested the strategy myself with prorealtime 10.3 and the tick backtest engine, results are the same as yours, with spread. For an unknown reason, results were not so great before 2015 though.. it may needs some investigation to find the reason why maybe.
About your ‘accumulator’ code, this is a nice and great idea, well done! 🙂 I’m sure it would be some kind of useful for other coders around here.
Hello pascual, thanks for your comment. Could you show me how the robot works before 2015? Yes, the accumulator is an idea of martingala adapted so that it is not so risky. Works very well for strategies where the take profit is more or less twice the stop loss. I personally have tested the accumulator in some robots of this same page with good results.
hola raul…
es normal que tengo un oversize mas de 18 contractos (42 o 54 por ejemplo) ?
lo he probado con v10.3
Hola larouedegann,
Si es normal, me explico, ordersize depende exclusivamente del acumulador, ademas, esta el parametro «n», q es el multiplicador, en este caso esta en 6. Quiere decir que todo se multiplica por 6 hasta un maximo de ordersize=18, que habria q multiplicarlo por 6. Es decir, un maximo de 108 contratos, prueba a cambiar «n=1» y veras q suma d 1 en 1 en vez d 6 en 6.
yo no habia visto el n
lo siento
Hola!
Thanks for the code, just put it to live and we’ll see the outcome. I really like the simplicity of the code.
Just a question, the time frame. Is it German time or Spanish? Do I need to change anything as I am living in Sweden?
Hi!
The time is set to the opening in Spain that is at 9 am, I do not know in Sweden at what time corresponds to the opening
Great, what part of Spain? Gmt? Gmt+1?
I used this on a demo IG account today and used the following values:
DEFPARAM FlatAfter =163000
HoraEntradaLimite = 080600
HoraInicio = 080500
And made 10 pts profit this morning. Demo only, but seems promising.
Just a question about the position size. I did backtest the code on v10.3 and results are good during the last year.But i do not understand how the position size can be sometime so important.I have QTY = 90 sometime… i though this piece of code would make impossible positions more than 18 : if Ordersize>18 thenOrdersize=18
Am I wrong ?
buy ordersize*n shares at market
where n is set to 6 and ordersize can be 18, 18*6=108 is the maximum it can be!
Hi!
Indeed, that is by the multiplier, try to change n = 1 and add from 1 to 1 to a maximum of 18, if n = 2, there will be up to 36 …
An example:
1- You earn 10 points with 6 contracts = 60 €
2- You earn 10 points with 18 contracts = 180 €
3- You earn 10 points with 30 contracts =
€ 300
4- You earn 10 points with 42 contracts = 420 €
5 – You earn 10 points with 54 contracts = 540
6 – You earn 10 points with 66 contracts = 660 €
7 – You earn 10 points with 78 contracts = 780 €
Cumulative total = € 2940
8 – You lose 5 points with 90 contracts = -450 €
9 – You lose 5 points with 45 contracts = -225 €
10 – You lose 5 points with 23 contracts = -115 €
11 – You lose 5 points with 12 contracts = -60 €
12 – You lose 5 points with 6 contracts = -30 €
Total lost = € 880
Total = 2940-880 = € 2060
This means that in the event that so many contracts are introduced at the same time, they are safe benefits no matter what happens. It would be very good news to see that so many contracts are used because it assures us gains in that accumulator cycle.
ok ! Thanks akira220984
When i see so many contracts i think about the capital required and the margin call.
But the accumulator seems to be a pretty good idea. I need to check some position to make my opinion about it.
It is true, I had forgotten, for the current configuration is necessary a capital of 3000 € to 5000 € to assume the margins, as you are entering contracts, it means that you have been winning. In my broker 108 contracts have a required margin of about 6000 €, if I reach that number of contracts I would have to say that I have already won 6 + 18 + 30 + 42 + 54 + 66 + 78 + 90 + 102 = 486 * 10 = 4860 € therefore will have enough money to take the margin.
When activating the robot you can limit the maximum number of contracts that will be opened in order to limit the risk, adjusting it to the volume of your account.
I think that even if the calculation of positions of the robot is higher than the limit you have set, only run the maximum number of contracts with which you have limited the execution of the robot.
Used it live today, opened a pos 9.05 as it should and closed it quick with a profit of 10pts (Too bad it wasen’t 40, dax went down like a rock today).
Will keep you updated on progressBig thanks too Raul.
Yes, it is a method of scalping, going in and out fast, assuming low risk. Although you could put a trailing stop to see how it works for days like today. Yes, I am also proving, Pascual has told me that before 2015 does not give good results, I am looking for someone with 200,000 bars to see what happens before 2015.
Hey Raul, Any possibility for helping me out with a trailing stop code and where to put it?
Hey Raul, you keep calling me pascual, don’t know why 🙂
Haha I noticed in the first answer and I do not know why I’ll call you back. I’m sorry Nicolas, by the way, can you show me what the backtest looks like with 200000 bars? I have a similar robot only with another type of accumulator, I would like to know how it is with 200000 bars, could you please show me how they are?
Delete the take profit and stop losing and put this:
SET STOP ptrailing 5
Thanks for the trailing, but does this mean that it does not take profit after 10pts? As there is no take profit code.. how far does it go?
On V10.3, the trailing stop gives good results too. If you opt for a trailing instead of a take profit you can maybe improve the % of winning trades. Tested it on V10.3, tick by tick mode.
SET STOP ptrailing 5
Yes, I have also tried it. But I would like someone who had 200,000 bars to show us how he behaves before
I used this on a demo IG account today and used the following values:
DEFPARAM FlatAfter =163000
HoraEntradaLimite = 080600
HoraInicio = 080500
And made 10 pts profit this morning. Demo only, but seems promising.
Yes, I have also tried it. But I would like someone who had 200,000 bars to show us how he behaves before
Buen trabajo Raul, muy interesante la estrategia económica y muy buenos resultados en los backtest del robot con PRT 10.3. Ahora toca probarlo en demo a ver que tal se comporta.
Enhorabuena,
Jesús
Muchas gracias Jesus, a seguir trabajando siempre!
Le han puesto en real esta mañana, con n = 1,veremos los resultados. hay una differencia de 2000.00 euros entre v 10.3 et v 10.2 sobre 150000 unitades (con n=1 15000 euros en v10.3 y 17000 euros en v10.2).
De lo que te diga v 10.2 olvidate porque no es real, ten en cuenta que esta estrategia igual te tiras 2 meses casi plano como se ve en la imagen, hay que tener paciencia, tienes 150.000 barras? lo tienes de manera gratuita? mi broker solo me da 100.000 de manera gratuita
claro que si.tenemos 150000 barras (2 anos en 5mn) con prorealtime cfd.pacienca
A mi me dan solo 100.000, puedo ver año y medio
the same robot with trailing stop and other type of accumulator (you can keep the previous accumulator, it works too)
// Definición de los parámetros del código
DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
DEFPARAM FlatAfter =172900
once ordersize=1
HoraEntradaLimite = 090600
HoraInicio = 090500
if Ordersize>50 then
Ordersize=10
endif
if Time >= HoraInicio and time <= HoraEntradaLimite then
// Condiciones de entrada de posiciones cortas
c1 = open < close-2
if not onmarket then
IF c1 THEN
IF PositionPerf(1) < 0 THEN
OrderSize = OrderSize-1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
if ordersize<1 then
ordersize=1
ENDIF
endif
buy ordersize shares at market
endif
c2= open > close-1
IF c2 THEN
iF PositionPerf(1) < 0 THEN
OrderSize = OrderSize-1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
if ordersize<1 then
ordersize=1
endif
ENDIF
sellshort ordersize shares at market
endif
endif
endif
SET STOP ptrailing 5
Buenos días,
de cara a probar esta estrategia, donde explicáis que ha de hacerse sobre la versión 10.3, yo quería señalaros algo y saber vuestra opinión al respecto.
Tengo desarrollado otro robot basado en ichimoku que no me gusta cómo lograr manejar los momentos de cierre de la posición, pero me encanta cómo logra señalar los puntos de entrada en base a una suma de filtros, entonces el robot yo lo dejo en tiempo real funcionando a través de backtesting, pero no operando en real. El resultado es que me marca las entradas y cierres que él haría, y eso me ayuda para combinar mi trabajo diario con la identificación de momentos en los que entrar a mercado.
¿Tal vez se podría poner a funcionar esta estrategia de igual modo? ¿o sigue siendo un problema si no usamos la versión 10.3?
What happends when you change the ordersize?
Insted of 10 it becomes 20. The charts is better for, better gains, lesser losses of worst gains and just a bit more in total loss.
if Ordersize>50 then
Ordersize=10
endif
if Time >= HoraInicio and time <= HoraEntradaLimite then
Yes, you have to go testing to see which configuration is better.
Any recommendations seeing how I’m a fan of trailing stops when scalping like this?
Raul: Please add a spreadsheet of the accumulator used in the code with the trailing-stop please.I can’t understand this one, the fist one I understood.
Hi Raul
This is very cool & I’m paper trading it from today. I’m just trying to get my head around the rationale for the accumulator. If I can’t verbally describe a strategy then I’m always more cautious. It assumes that the market move tomorrow is related to today right? i.e. it is not an independent event? Or more precisely, that the success of the strategy (i.e that the market continues to move in the same direction as the first 5 minute bar) is related between consecutive days? Or at least it is saying that there are times (not necessarily all of the time) when the two events are related and the accumulator makes the most of these related periods? I can sort of believe it although I’m trying to get completely comfortable with it in my head. The results go a long way to showing that there is a degree of relatedness.
I’m not meaning to be pedantic!
Thanks
One day with the next has absolutely nothing to do. Simply that if one day you win 10, the next day you can “afford” the luxury of risking 3×5 = 15 (earned the previous day plus 5 points of the same day, if you win again, you will have won 10 + 30 = 40, If on the third day you lose, you only lose 25 and you drop contracts again, as you can see in the picture, the money evolution is slow until you hit a series of days gained, which is when the profits are triggered. Time gains slowly or loses very little, it is not about finding meaning to why strategy, but looking for mathematical sense.
let us know if you get any slippage with real money
Thanks for your share, really amazing result, will try it immediately. But how come the result from 2016 DEC to now is not good as before.
Thanks Raul. I get it mathematically now. Just slow getting my head around it after too much screen time. A big thing I wasn’t factoring in (even though it was in plain sight) is the difference in the target (10) and stop (5).
As I said, I wasn’t trying to be pedantic or difficult.
Thanks again. Great strategy.
Hi jon. Yes, but look at the backtest as there are whole months going flat as of January and February 2016. Or in September, there isn´t strategy (at least that I know) that of a perfect money evolution, but at least in this when you lose, you lose little and when you win, the profits soar. I’m looking for someone with 200,000 bars to see how it behaves earlier and see if it’s a solid strategy.
jon no, bin, sorry
I’ve backtestest from 2 Jan 2013 until 20 Dec 2016 (just for making forward testing nice and neat 4 1-year periods). It’s almost 200,000 bars. I can’t attach files when I take a screen shot and I have even downloaded SnapMyScreen.
I’ve made a few changes to your first code (where the order size is reduced by /2). I’ve limited ordersize to 11 to be conservative. Also focused on minimising max drawdown.
n=1, Ordersize = 11, Stop = 3, Target = 12 (I know, the stop may be too close and I could miss profitable moves). I’ll see how it goes and may go back to a stop of 5. Spread 1. I’m also including an Order Fee of EUR1 / contract.
Results seem promising: Gain 787.09%, % winning trades 26.54%, Gain/Loss 1.75, Max Drawdown 3,886. As to be expected a brilliant performance in Q4 2016 with nearly EUR30k profits (all building up to this). So far this year just seems to be “ticking over” with small losses.
I’ll attach files when I can. It always says “HTTP error”.
Hope this helps.
You can see clearly from the equity curve what you mean by whole months of nothing going on…just ticking along with small losses, then on a number occasions there is a run of 6+ winners in a row and then there is a nice spike up in profits. Almost like steps is you see what I mean. I would say approximately 20 of these “steps”, followed by a “quiet period” of small losses, then another “step”
Just copy-paste the code, you cant add a file to the comments.
Yes, basically it is that, when there is no series of winning days, stay stable or with few losses, but the moment you chain a few days winners, they increase profits a lot.
The code is no different to Raul’s above. Here it is again (with a few bits translated into English by Google). I thought it would be useful to attach the screenshot of the equity curve or the Backtest Report for everyone however I didn’t know it wasn’t allowed in the comments.
// Definition of parameters
DEFPARAM CumulateOrders = false // No accumulation of orders
// The position is closed at 4:30 p.m., local market time (London).
DEFPARAM FlatAfter =162900
once ordersize=1
// No new positions after the candle closes at 08:06
EndTime = 080600
// Market analysis starts in the candle 5 minutes closes at 08:05
StartTime = 080500
// Max orders
if Ordersize>11 then
Ordersize=11
endif
// Risk & multiplier contracts
n=1
// Conditions for analysis
if Time >= StartTime and time <= EndTime then
// Conditions to enter long positions
c1 = open < closeO-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
// If the first day of 5 bar min is positive, we buy
buy ordersize*n shares at market
endif
// Conditions to enter short positions
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
// If the first day of 5 bar min is positive, we sell.
sellshort ordersize*n shares at market
endif
endif
SET STOP ploss 3 //5
SET TARGET pPROFIT 12 //10
Would you try using a 5-point trailing? If I tell you my email, could you send me screenshots?
The smallest stop loss allowed by my broker in the DAX is 4 points
Hi Raul
I would be happy to email you the screenshots (it’s the least I could do for you sharing the strategy).
Noted re: minimum stop size of 4 for you. I wouldn’t be surprised if I had the same. We’ll see.
I’ll run the backtest again with a stop of 5 and will post below.
Hi, I made the small changes in programming. Now, instead of launching the purchase or sale just after finishing the first 5 minutes, what it does is to launch a purchase order 2 points above the closing if it is positive, a sales order of the points below the closing Yes Is negative.
// Definición de los parámetros del código
DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
DEFPARAM FlatAfter =173000
once ordersize=1
HoraEntradaLimite = 090600
HoraInicio = 090500
if Ordersize>15 then
Ordersize=15
endif
if Time >= HoraInicio and time <= HoraEntradaLimite 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
if ordersize<1 then
ordersize=1
ENDIF
endif
buy ordersize*6 contract AT close[1]+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
if ordersize<1 then
ordersize=1
endif
ENDIF
sellshort ordersize*6 contract AT close[1]+2 stop
endif
endif
endif
SET STOP ptrailing 5
with other accumulator:
// Definición de los parámetros del código
DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
DEFPARAM FlatAfter =172900
once ordersize=1
HoraEntradaLimite = 090600
HoraInicio = 090500
if Ordersize>50 then
Ordersize=10
endif
if Time >= HoraInicio and time <= HoraEntradaLimite then
// Condiciones de entrada de posiciones cortas
c1 = open < close-2
if not onmarket then
IF c1 THEN
IF PositionPerf(1) < 0 THEN
OrderSize = OrderSize-1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
if ordersize<1 then
ordersize=1
ENDIF
endif
buy ordersize shares AT close[1]+2 stop
endif
c2= open > close-1
IF c2 THEN
iF PositionPerf(1) < 0 THEN
OrderSize = OrderSize-1
if ordersize<1 then
ordersize=1
ENDIF
ELSIF PositionPerf(1) > 0 THEN
OrderSize =OrderSize+2
if ordersize<1 then
ordersize=1
endif
ENDIF
sellshort ordersize shares AT close[1]-2 stop
endif
endif
endif
SET STOP ptrailing 5
Hi Raul! Thanks for your strategy. Looks very promising! Maybe you could make a topic for this strategy so we can post and share results easily.
Like today, I used the code you posted yesterday on a demo account. I have a €5 loss. But in the v10.3 backtest it shows a win of 14 pips.
Yes, I have noticed, has been because in backtest the openings and closures are perfect and live if there are fast movements are delayed, if you look at the price of entry in the backtest is different from the live entry. Plus today has been a day that has just gone up 5 points, this is scalping 🙁 To solve this problem, I have modified the code. You have it in these last comments, instead of opening directly, it creates opening orders. I will create in the forum a topic.
All. These are the results with the version of the code I posted above. I know the code has changed but I have been asked for the results with a stop of 5.
Stop 5, Target 10: initial equity of EUR10k is too small. You have a max drawdown of EUR9063 and the strategy stops in Feb 2014. If you increase starting equity to EUR20k, strategy moves into profit from approx Q2 2014. It does really well but you have to be comfortable with the drawdown. Obviously returns aren’t as high as you have doubled starting equity.
Stop 5, Target 12: Starting equity of 10k. Works OK. Drawdown of 6,014 (so more than when stop is 3). Makes more overall (+968% over the 4 years). Winning trades 35.62%, G/L 1.5, Loss of worst trade 1,651.
Overall, if you are just concerned with the total gain over the 4 years, stop 5 & target 12 is better. However I wasn’t happy with the drawdown. The strategy “ticks along” through 2013 no matter what the settings (either small gain or, in most cases, loss). I optimised and walked forward from 2013 and I decided on Stop 3, Target 12. I was tempted with Stop 4, Target 10 (Gain 976%, % winning 36%, G/L 1.75) however had drawdown 5,834 and in particular had a worse year in 2013.
Hope this is of use.
I have created a post in the English forum to share the images. Can you try the backtest 4 years with the code forum? Has a trailing and how input is different.
Better to give the URL of your post: https://www.prorealcode.com/topic/5-min-mini1e-dax-spread-1/
Hello Raul vg the minimum stop on the Dax and mini 1 and not to 18 points how do you insert
SET STOP ptrailing 5
Orders will be refused all I deleted
Hi alemaliz,
In the IG broker, the minimum trailing stop is 5 with the open market.
For everyone information, a discussion thread is ongoing here: https://www.prorealcode.com/topic/5-min-mini1e-dax-spread-1/
This is where you’ll find last versions and debate about this intraday trading strategy.
Bonjour Nicolas,
comment se fait-il qu’avec cette stratégie stop loss à 5 pips, PRT mettant le stop à 17 pips ???????
sur 42 contrats,ça fait mal.y a t-il une explication ?les ordres étant passés en même temps(achat-vente stop limite)
Personnellement je ne comprends pas
Buenos días Raul, tengo puesto este sistema desde hace unos días en una cuenta demo en la versión 10.3 de proreal y no coincide el Backtest con las operaciones que lleva hechas ¿Sabes a que se debe? Se supone que con la versión 10.3 los backtest son fiables.
Muchas gracias.
Hola Raul … it looks wonderful 🙂
Why does it not work if I use less than 100,000 € capital?
For example 10,000 €
Hola y gracias por compartir!
Descubrí que en 5 minutos teníamos algo muy bueno! Pero no en el buen sentido del mercado … ¿es posible devolver las compras / ventas para hacer pedidos positivos?
Gracias de antemano