Adolfo

BreakOut - SAR - Index - 15m - (DJIA-DAX-PXI)

Category: Strategies By: Adolfo Created: April 25, 2016, 10:10 PM
April 25, 2016, 10:10 PM
Strategies
15 Comments
BreakOut - SAR - Index - 15m - (DJIA-DAX-PXI)

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

Download
Filename: BREAKOUT-SAR-INDEX.itf
Downloads: 277
Download
Filename: Informe-detallado-1-Breakout-djia-15m.png
Downloads: 112
Adolfo
Adolfo Senior
A ProRealTrader. I'm here to learn as much as I can, and improve my skills every single day!
Author’s Profile

Comments

Meta Signals Pro
3 years ago
#

Hi, For me there is a mistake here L32 maxriesgo = round(equity*riesgo) => round(equity*(riesgo/100)

GraHal
10 years ago
#

Hi Adolfo, big thank you for your code, but I am a bit confused.

Spread is the difference between Buy Price and Sell Price and is what the Market-Maker (for example IG)  makes on the round trip of selling me an instrument and then buying it back again.

You say above that Variable 'S' / Spread is the distance you want to wide orders ... please could you explain / expand on what you mean?

Or anybody else who might understand this ... please could you enlighten me?

Many Thanks

GraHal   

Adolfo Onrubia
10 years ago
#

Ups! Sorry. Variable "S" is to set an specific Spread if needed. Could be "0", or the distance you want to wide orders.

Adolfo Onrubia
10 years ago
#

Hi, fisrtly thanks for your interest on it. :)

Variable "c" is to set your initial capital (i.e. 1000€)
"r" is to set the maximum risk percentage we want (i.e 0,03)

and "s" is the maximum stop loss distance in pips.

Hope it helps you!

Adolfo

ALEALE
10 years ago
#

Hello

could you help to set variables c,s,r, 
thanks

Adolfo Onrubia
10 years ago
#

Ups, how can edit posted code? Can I?

This strategy at 08:00h GMT+1 sets a max/min range at highs and lows (dhigh,dlow). At 09:00h set stop orders at dhigh/dlow stop +/- Spread ( variable to set how many points away the limit we set the orders), if price is still into the range. At this step orders are placed and waiting to be executed. 
If price already breaks those limits, the inmediatly join the market with "AT MARKET" orders. After that, a cross over or under "SAR" (parabolic SAR indicator price) will stop positions.

PIPSTOP = distance between recent highs and lows (last hour), in order to set an emergency STOP pLOSS.

Also included money management, you can set your initial capital and your desired % of risk in variables "capital" and "riesgo".

Already now i'm very excited while working with the next version of this system, with a "JACKPOT" profit objective! I want to ear your questions, thanks!

Adolfo

Adolfo Onrubia
10 years ago
#

Yes! I will, after dinner :) 

Nicolas
10 years ago
#

Maybe you could explain parameters to everyone Adolfo? I know there are the spread one which is important i believe? thanks :)

Adolfo Onrubia
10 years ago
#

Hi gutta11!

Should be more because our timezones are different? System is tested at GMT+1. 

I don't know why you get this results, maybe we will find some help from our bests pro's!

Adolfo.

gutta11
10 years ago
#

This seems nice!
But in the back test, I just got like 30 trades the last year! And -80%
Do you have an idea what´s wrong here?
Thank you very much!

 

Andres
10 years ago
#

Thank you very much for the code, Adolfo.

Andrés.

 

Adolfo Onrubia
10 years ago
#

Hi Doctrading!

Then you would like to see this:

REM INDICATOR
mySAR = SAR[0.02,0.02,0.2]

REM CONDITIONS
c1 = mySAR >= High
c2 = mySAR <= Low

IF Not OnMarket THEN
IF c1 THEN
BUY 1 CONTRACT AT mySAR STOP
ENDIF
IF c2 THEN
SELLSHORT 1 CONTRACT AT mySAR STOP
ENDIF
ENDIF

IF LongOnMarket THEN
mySTOP = mySAR
IF Close >= TradePrice(1) THEN
mySTOP = mySAR
SELLSHORT AT mySTOP STOP
ELSE
SELLSHORT AT mySTOP STOP
ENDIF
ENDIF

IF ShortOnMarket THEN
mySTOP = mySAR
IF Close <= TradePrice(1) THEN
mySTOP = mySAR
EXITSHORT AT mySTOP STOP
ELSE
EXITSHORT AT mySTOP STOP
ENDIF
ENDIF

Very funny results on DAX last year :)

Doctrading
10 years ago
#

Hello,

Nice code, I was just looking to make a similar code on Parabolic SAR !

Adolfo Onrubia
10 years ago
#

Hello, I'm glad to see it published! 

505 Trades, also added a screenshoot with detailed report

http://www.prorealcode.com/wp-content/uploads/2015/07/Informe-detallado-1-Breakout-djia-15m.png

Nicolas
10 years ago
#

Hello, and thank you Adolfo for your library contribution.

How much trades do the strategy have done since January this year?

ProRealCode ProRealCode
Loading...