intraday DAX strategy 5min mini1€ spread 1
Forums › ProRealTime English forum › ProOrder support › intraday DAX strategy 5min mini1€ spread 1
- This topic has 502 replies, 34 voices, and was last updated 4 years ago by Asteriks.
-
-
02/01/2017 at 9:34 PM #23489
@all
hi, yesterday I replaced the trailing with nicolas function and back test matches in demo system results. I fear that the problem is the trailing owns in PRT function. The problem of Nicolas function that is activated only if the market goes in the direction of the trade so we must enter a stop loss otherwise we risk substantial losses. I attach my own version of the strategy with the nicolas script.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144// Definición de los parámetros del códigoDEFPARAM CumulateOrders = false // Acumulación de posiciones desactivadaDEFPARAM FlatAfter =173000Margin = 60Lottfree = 0orderSize = max(1,1+ROUND((strategyprofit-lottfree)/Margin))ordersize=min(50,ordersize)HoraEntradaLimite = 090100HoraInicio = 090000HoraEntradaLimite1 = 090600HoraInicio1 = 090500HoraEntradaLimite2 = 091100HoraInicio2 = 091000HoraEntradaLimite3 = 091600HoraInicio3 = 091500//Mondayif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=1 thenn=1endifif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=1 thenn=1endifif Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=1 thenn=1endifif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=1 thenn=1endif//Tuesdayif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=2 thenn=1endifif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=2 thenn=1endifif Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=2 thenn=1endifif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=2 thenn=1endif//Wednesdayif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=3 thenn=1endifif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=3 thenn=1endif////Thrusdayif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=4 thenn=1endifif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=4 thenn=1endif////Fridayif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=5 thenn=1endifif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=1 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=1 or Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=1 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=1 or Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=2 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=2 or Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=2 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=2 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=3 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=3 or Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=4 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=4 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=5 thenc1 = open < close-2if not onmarket thenIF c1 THENbuy n*ordersize contract AT close+2 stopendifc2= open > close-1IF c2 THENsellshort n*ordersize contract AT close-1 stopendifendifendif//trailing stoptrailingstop = 5//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endif//case SHORT orderif shortonmarket thenMINPRICE = MIN(MINPRICE,close) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price levelendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif//SET STOP PLOSS 51 user thanked author for this post.
02/01/2017 at 9:41 PM #23490This version is the MFE one you can also try the other one :
https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
02/01/2017 at 9:51 PM #23493@nicolas @all
Yes, I have test also your version and backtest equal to the result in demo account. Is tt correct to add also a stop loss because if the market goes in the opposite direction of the trade we must have high lossess ? Thanks
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151// Definición de los parámetros del códigoDEFPARAM CumulateOrders = false // Acumulación de posiciones desactivadaDEFPARAM FlatAfter =173000Margin = 60Lottfree = 0orderSize = max(1,1+ROUND((strategyprofit-lottfree)/Margin))ordersize=min(50,ordersize)HoraEntradaLimite = 090100HoraInicio = 090000HoraEntradaLimite1 = 090600HoraInicio1 = 090500HoraEntradaLimite2 = 091100HoraInicio2 = 091000HoraEntradaLimite3 = 091600HoraInicio3 = 091500//Mondayif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=1 thenn=1endifif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=1 thenn=1endifif Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=1 thenn=1endifif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=1 thenn=1endif//Tuesdayif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=2 thenn=1endifif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=2 thenn=1endifif Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=2 thenn=1endifif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=2 thenn=1endif//Wednesdayif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=3 thenn=1endifif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=3 thenn=1endif////Thrusdayif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=4 thenn=1endifif Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=4 thenn=1endif////Fridayif Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=5 thenn=1endifif Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=1 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=1 or Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=1 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=1 or Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=2 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=2 or Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=2 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=2 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=3 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=3 or Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=4 or Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=4 or Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=5 thenc1 = open < close-2if not onmarket thenIF c1 THENbuy n*ordersize contract AT close+2 stopendifc2= open > close-1IF c2 THENsellshort n*ordersize contract AT close-1 stopendifendifendif//trailing stop functiontrailingstart = 5 //trailing will start @trailinstart points profittrailingstep = 5 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFSET STOP PLOSS 502/01/2017 at 10:08 PM #2349402/01/2017 at 10:23 PM #23495Hi,
attached back with these parameters of trailing Nicolas. I think that that the strategy not perform very well and I stop trading in real with this strategy. Thanks
12345678910111213141516171819202122232425262728293031323334353637383940//trailing stop functiontrailingstart = 5 //trailing will start @trailinstart points profittrailingstep = 5 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFSET STOP PLOSS 51 user thanked author for this post.
02/02/2017 at 5:54 AM #23505The fact of using a trailing is for those days of great price movements. But what about the other days? The other days represent 95% of the days, imagine, with a trailing if the price moves in our favor 5 points and then turns around, we would stay at 0, if you move 10 points in our favor and then give The return, we would earn 5 points, we would need the price to rise, without going back, 15 points to ensure we earn 10 points.
Except that 5% of days that the price moves without going back, it is rare that the price moves more than 15 points without going back 5. With the trailing, for example, if the price goes up 14 points and turns around, we will win 5 Points, if you raise 11 and turn around, we would earn 5 points.
We would be letting out many points most days. Would not it be better not to be looking for those big price moves always and reap profits every day? I explain, if we place a take profit at a distance of 10 points and a normal stop of 5 or even a trailing of 5, someday we will stop making some money but in the long run I think it would be more convenient when it comes to scalping.
On the other hand, I understand that the trailing stop added to the code is only updated every 5 minutes, that’s a short time strategy I think it will never work. That is, when placing the order at 9, also places the trailing, the price can raise the first minute 50 points that the trailing is not going to move until 9.05 to recalculate it.
Imagine that the first 3 minutes goes up 20 points and the minute 4 falls 30 points, the operation would be losing when touching the stop even if we had won. This is how I understand the trailing code works.
02/02/2017 at 5:59 AM #2350602/02/2017 at 9:45 AM #2351602/02/2017 at 9:45 AM #23517Hey guys!
I totally agree with the trailingstop discussion you have here. I´m running the latest V3 system live and it definitely dosen´t match the backtest. Look at the picture. Real trades on the left and backtest at the right.
02/02/2017 at 9:50 AM #23520Since this is a scalping strategy, with no indicator needed, I still wonder why no one has launched it on a 1 second timeframe already? Ok.. you need first to calculate the 5 minutes Open/Close bar if I’m correct?
Trailing stop will be updated every 1 second, what else is needed? Tick trading, ok that’s no possible, but 1sec would be fair enough I believe!
02/02/2017 at 9:51 AM #2352102/02/2017 at 10:08 AM #23527Hello! Yesterday I tried it in 1 minute with the trailing of PRT, today I will try in 1 second with the trailing of Nicolas. I suppose it will be necessary that the opening of the 9 is less closing at 9.05, ie, 5×60 = 300 seconds. Close [300] <open-2 for purchase and close [300]> open-1 for sale.
02/02/2017 at 10:25 AM #23538I suppose it will be necessary that the opening of the 9 is less closing at 9.05, ie, 5×60 = 300 seconds. Close [300] open-1 for sale.
For this specific purpose, I think that we can’t do it like this, because with a 1 second timeframe, some candlesticks may not exist because of no new quotation. I think that a better option would be to have an indicator that calculate them like this instead:
123456789if time=090000 thenval0900=closeendifif time=090500 thenval0905=closeendifreturn val0900, val090502/02/2017 at 4:01 PM #23630Hi Nicolas, I’m trying out what he told me right now in demo live in 1 second timeframe. What happens is that you place the order and the next second you remove it, how can I do to place the order in that first second and keep it until it touches the price?
02/02/2017 at 4:29 PM #23633 -
AuthorPosts
Find exclusive trading pro-tools on