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