This post belongs to this system: http://www.prorealcode.com/prorealtime-trading-strategies/dax-trading-strategy-breakoutfakeout/
A few changes were made after start the strategy in real time with some troubles. Some adjuntments and improvements
Major change
Code problems mades system don’t put stop and limit orders after entering a position. Now the system runs with fixed orders “PLOSS” and “PPROFIT” to avoid this. Tested in real time and working OK.
Minor changes
- It will run from Monday to Thursday, not even Friday, Saturday or Sunday. As I suppose Fridays are more often sideways and prefered to avoid this day.
- Min distance for stoploss is now 6 pips, as far as IG broker don’t let it start with less.
- Max range was 200 points, now is 150. Max risk for this system is 0,5% of actual equity, so stoploss shouldn’t exceed 15 pips.
FULL CODE
//-------------------------------------------------------------------------
// Main code : Binomio AutoTrading Bot v.2 DAX
//-------------------------------------------------------------------------
REM #########################################
REM ## Binomio AutoTrading Bot 2016 DAX 1m ##
REM #########################################
REM Not cumulate orders
defparam cumulateorders = false
REM No positions open before this time
defparam flatbefore = 080000
REM All positions will be closed after this time
defparam flatafter = 213000
REM MAX and MIN we want to operate
REM No orders will be set if range is greater than
maxrange = 150
REM No orders will be set if range is shorter than
minrange = 20
REM Parameters
profitvalue = 1.5 // % Range (1.5 = 150%)
rangepercent = 0.1 // %Range (0.1 = 10%)
REM ######################
REM ## MONEY MANAGEMENT ##
REM ######################
Capital = 3000 // Initial capital
Risk = 0.5 // %Risk max
REM RESET MAIN VARIABLES EACH NEW DAY
if Dayofweek = 5 then
trading = 0
else
If intradaybarindex = 0 then
trading = 1
bullish = 0
bearish = 0
inrange = 0
rangepips = 0
enter1 = 0
enter2 = 0
enter3 = 0
enter4 = 0
abovemax = 0
abovemin = 0
belowmax = 0
belowmin = 0
//profittrend = 0
profitrange = 0
endif
endif
REM CHECK CONTROL TIME
starttime = 075500
endtime = 075900
REM RANGE ESTABLISHMENT
IF time >= starttime and time <= endtime then
REM NIGHT MAX
maximo = dhigh(0)
REM NIGHT MIN
minimo = dlow(0)
REM RANGE IN PIPS BETWEEN NIGHT MAX AND MIN
rangepips = round(maximo-minimo)
REM PROFIT IN PIPS EX
takeprofit = rangepips*profitvalue// i.e we could add here "*0.9" to reduce the profit objective
REM DISTANCE FROM LINES TO SET ORDERS
margin = rangepips*rangepercent
REM SET MAX ORDER PLACES
abovemax = maximo+margin
belowmax = maximo-margin
REM SET MIN ORDER PLACES
abovemin = minimo+margin
belowmin = minimo-margin
REM SET NUMBER OF PIPS TO RISK EACH TRADE
StopLoss = round(margin*2)
if StopLoss<6 then
StopLoss = 6
endif
endif
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
REM SPREAD CHECK
IF Time>=090000 and time<173000 then
spread = 0 // Backtest spread is set to 1
else
spread = 1 // Backtest spread 1 + 1 = Real spread
endif
REM CONDICION DEL MERCADO
inrange = Close<maximo-margin and close>minimo+margin
bullish = Close>(maximo+margin)
bearish = Close<(minimo-margin)
semibull = Close>maximo-margin and close<maximo+margin
semibear = close<minimo+margin and close>minimo-margin
REM START SETTING ORDERS
REM FIRST TRADES
if not onmarket and trading = 1 and rangepips<=maxrange and rangepips>=minrange then
REM RESET VARIABLES EACH TIME WE ARE OUT OF THE MARKET
if bearish then
if enter4=0 then
sellshort PositionSize contract at market//belowmin limit
endif
if enter1=0 then
buy PositionSize contract at abovemin+spread stop
endif
endif
if bullish then
if enter3=0 then
buy PositionSize contract at market//abovemax limit
endif
if enter2=0 then
sellshort PositionSize contract at belowmax-spread stop
endif
endif
if inrange then
if enter1=0 then
buy PositionSize contract at abovemin limit
endif
if enter2=0 then
sellshort PositionSize contract at belowmax limit
endif
if enter3=0 then
buy PositionSize contract at abovemax+spread stop
endif
if enter4=0 then
sellshort PositionSize contract at belowmin-spread stop
endif
endif
if semibull then
if enter3=0 then
buy PositionSize contract at abovemax+spread stop
endif
if enter2=0 then
sellshort PositionSize contract at belowmax-spread stop
endif
endif
if semibear then
if enter1=0 then
buy PositionSize contract at abovemin+spread stop
endif
if enter4=0 then
sellshort PositionSize contract at belowmin-spread stop
endif
endif
endif
buytrend = tradeprice(1)>maximo
buyrange = tradeprice(1)<maximo
selltrend = tradeprice(1)<minimo
sellrange = tradeprice(1)>minimo
REM SI ESTAMOS LARGOS
if longonmarket then
REM IF TRADE PRICE IS ABOVE MAX
if buytrend then
enter3 = 1
if enter2=0 then
sellshort PositionSize contract at belowmax-spread stop
endif
endif
REM IF TRADE PRICE IS INTO DE RANGE
if buyrange then
enter1 = 1
if enter4=0 then
sellshort PositionSize contract at belowmin-spread stop
endif
endif
endif
REM SI ESTAMOS CORTOS
if shortonmarket then
REM SI HEMOS VENDIDO POR DEBAJO DEL MINIMO
if selltrend then
enter4 = 1
if enter1=0 then
buy PositionSize contract at abovemin+spread stop
endif
endif
REM SI HEMOS VENDIDO DENTRO DEL RANGO
if sellrange then
enter2 = 1
if enter3=0 then
buy PositionSize contract at abovemax+spread stop
endif
endif
endif
set stop ploss stoploss
set target pprofit takeprofit
Thanks Adolfo, I’ll change your library post accordingly to this new version.
You’re wellcome Nicolas.
I saw a few good changes in website recently, each day looks better! Thanks a lot for giving us a space like this.
Have a nice day and better trading!!
Hey everyone! I did a Monte Carlo test with attached results.
Do you have any experience with this monte carlo one?
What do you think about results?
Cheers!
Hi Adolfo, I am working with montecarlo during these days… If you send me your data I run it whit my system (very similar with nicolas system) and we can open a new thread where to disucuss how to read the montecarlo.
what do you think?
Hi David, I <3 it.
Do you need something else than results? There are 418 trades, how do I send it to you?
Is posible for you to share monte carlo test also?
Cheers!
please drag the last page of the result of the backtest into excel and share it here.
remember to put the spread in it
GM!!! I attached an image in first post, did you see that?
Where is spread’s place?
sorry, maybe I explained wrong.
I have done it for you. this is the montecarlo test for your system on dax 1 minute with spread equal to 1. Dax 1 euro per point.
The result that you have posted where without the spreads in it. they were fake results. If you add the spread the TS does not perform good.
Comments? Am I doing something wrong?
Hey David, just realized that your backtest were only 100.000 units rather than 200.000 is I did, see attached results for full period. It does 403 trades with 1 point spread.
Shall I send to you a text plain file with trades?
yes.. with IG I can do only 100.000 bars. Send me the list of closed position in excel.
Ok David, sorry for inconvenience and thanks for your efforts. Here are results in excel.
I need it full like this. just drag and drop the matrix in excel.
Nothing more…
Aha! get it… I saw a forbbiden an icon, sry!