AEParticipant
Senior
Hi all,
I check this strategy very interesting but I found some errors when I tried it in REAL with IG. For that, I modify it but I would like to check with 200k bars. Could you please help me?
//-------------------------------------------------------------------------
// Main code : Binomio AutoTrading Bot v.3 DAX
//-------------------------------------------------------------------------
REM ###############################################
REM ## Binomio AutoTrading Bot Julio 2019 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 #########
profittrendvalue = 1.8
profitrangevalue = profittrendvalue
//5 //1.7
rangepercent = 0.1//0.1
REM ######################
REM ## MONEY MANAGEMENT ##
REM ######################
Capital = 6000
Risk = 0.5
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
profitrange = rangepips*profitrangevalue// i.e we could add here "*0.9" to reduce the profit objective
//profittrend = rangepips*profittrendvalue //1.5
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 abs(close - abovemax)<= 10 then
igabovemax = abs(close - abovemax)+1
else
igabovemax = 0
endif
if abs(close - abovemin)<= 10 then
igabovemin = abs(close - abovemin)+1
else
igabovemin = 0
endif
if abs(close - belowmax)<= 10 then
igbelowmax = abs(close - belowmax)+1
else
igbelowmax = 0
endif
if abs(close - belowmin)<= 10 then
igbelowmin = abs(close - belowmin)+1
else
igbelowmin = 0
endif
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+igabovemin 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-igbelowmax 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+igabovemax stop
endif
if enter4=0 then
sellshort PositionSize contract at belowmin-spread-igbelowmin stop
endif
endif
if semibull then
if enter3=0 then
buy PositionSize contract at abovemax+spread+igbelowmin stop
endif
if enter2=0 then
sellshort PositionSize contract at belowmax-spread-igbelowmax stop
endif
endif
if semibear then
if enter1=0 then
buy PositionSize contract at abovemin+spread+igabovemin stop
endif
if enter4=0 then
sellshort PositionSize contract at belowmin-spread-igbelowmin 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-igbelowmax 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-igbelowmin 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+igabovemin 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+igabovemax stop
endif
endif
endif
set stop ploss stoploss
set target pprofit profitrange
Paul and the others, some ideas for improvement? The ratio is not very high but with the frequency of trades, it can make the gain volume ….