Dear all,
This is my first strategy posted, I have coded this strategy based on my empirical experience, the idea is that Italy 40 index tends to invert directionality in the morning at 09:00 CET. 09:00 is the time when the future starts trading and is also the time when the index bid offer spread shrinks from around 25ticks to 6/7 ticks.
The fliter I used are:
The code force open and close at 30 minutes distance, open at 09:00 and closes at 09:30
In the code I also added an accumulator of positions, ading up positions as long as the strategy is profitable.
You find the results in the picture named btVP.png.
I also tried to do a walk forward analysis, with constant positions, and the results are in backtestwg.png
There is one thing to note before trying to run the code.
In the example I used a 30 minutes time frame in order to capture the longest possible timeseries, but pls be warned that in real you should open a position slightly later than 09:00:00 because the bid offer tightnes only after few seconds after. Ideally 09:01:00 should be fine.
As far as I know Nicolas has done a 200, 000 backtest and it looks that the strategy has worked consistently well up to 2013.
Any comment, improvement will be greatly appreciated.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
timeenter = time = 090000
timeexit = time = 093000
indicator1 = AverageTrueRange[50](close)
volfilter= indicator1>20
b = 120
size = 5
increasestep = 2000
// Conditions to enter long positions
c1 = (DClose(1) <= DOpen(1)-b) and abs(dclose(1)-dopen(1))<900
NotAugust = CurrentMonth < 8 OR CurrentMonth > 8
if strategyprofit >=0 then
IF c1 AND timeenter and NotAugust and volfilter THEN
BUY size+round(strategyprofit/increasestep) PERPOINT AT MARKET
ENDIF
endif
if strategyprofit < 0 then
IF c1 AND timeenter and NotAugust and volfilter THEN
BUY size/2 PERPOINT AT MARKET
ENDIF
endif
if longonmarket AND timeexit and volfilter THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
c2 = (DClose(1) >= DOpen(1)+b)and abs(dclose(1)-dopen(1))<900
if strategyprofit >=0 then
IF c2 AND timeenter and NotAugust and volfilter THEN
SELLSHORT size+round(strategyprofit/increasestep) PERPOINT AT MARKET
ENDIF
endif
if strategyprofit < 0 then
IF c2 AND timeenter and NotAugust and volfilter THEN
SELLSHORT size/2 PERPOINT AT MARKET
ENDIF
endif
if shortonmarket AND timeexit THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP ploss 300
set target pprofit 400
You must be logged in to post a comment.
Ciao Nacho, grazie per il commento, onestamente a me non e' mai capitato, ma ho fatto solo in reale...
Spero che qualcun altro possa aiutarti.
Saluti!
Molto bene, ho voluto parlare di una cosa che sto trovando con questa strategia, ho girato su un conto demo per vedere come funziona e non soddisfa gli orari, le posizioni sono aperte alle 9 del mattino e devono chiudere a 9 30 e molti giorni non chiudere quella posizione, dando poi un errore e fermare la strategia si fa a sapere che è?
Grazie mille.
Ciao e grazie per il codice.
Avevo osservato la stessa cosa circa sette o otto anni fa, sempre con IG ma facendo trading manuale. Per un po' è andata bene ma poi ho cominciato a mangiare il gruzzoletto guadagnato, ed ho lasciato perdere. In effetti lo spread alto fa la differenza.
Purtroppo!
Perché è un pattern su cui si può fare affidamento.
Grazie a te per il commento, per quanto riguarda lo spread basta impostare l'entrata alle subito dopo le nove del mattino ora italiana. Mi fa piacere sapere che funzionava anche setto otto anni fa..:)
HI Iramirez,
my personal view is that as is not easy at all to find patterns, even pay a bit of slippage is not a disaster on the long term.
It become insignificant on the long term if the backtest is solid.
I appreciate your comment anyway.
Ciao
Hi, I do not understand why to do strategies for indexes with a slipage so high. I do not like to give my money to the brokers. In Spain IG gives us a slip for Italy of 15. We have the DAX with 1 point !!!.
Thank you anyway
ciao francesco grazie mille. pietro ranzato non riesco a contattarti sono interessato al tuo lavoro se mi puoi contattare su fb grazie.