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!
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
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
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
Hello, and thank you Adolfo for your library contribution.
How much trades do the strategy have done since January this year?
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
Hello,
Nice code, I was just looking to make a similar code on Parabolic SAR !
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 🙂
Thank you very much for the code, Adolfo.
Andrés.
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!
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.
Maybe you could explain parameters to everyone Adolfo? I know there are the spread one which is important i believe? thanks 🙂
Yes! I will, after dinner 🙂
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
Hello
could you help to set variables c,s,r, thanks
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
Ups! Sorry. Variable “S” is to set an specific Spread if needed. Could be “0”, or the distance you want to wide orders.
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
Hi,
For me there is a mistake here L32
maxriesgo = round(equity*riesgo) => round(equity*(riesgo/100)