intraday DAX strategy 5min mini1€ spread 1

Viewing 15 posts - 376 through 390 (of 503 total)
  • Author
    Posts
  • #23489 quote
    volpiemanuele
    Participant
    Veteran

    @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.

    // Definición de los parámetros del código
    DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
    
    DEFPARAM FlatAfter =173000
    
    Margin = 60
    Lottfree = 0
    orderSize = max(1,1+ROUND((strategyprofit-lottfree)/Margin))
    ordersize=min(50,ordersize)
    
    
    HoraEntradaLimite = 090100
    HoraInicio = 090000
    
    HoraEntradaLimite1 = 090600
    HoraInicio1 = 090500
    
    HoraEntradaLimite2 = 091100
    HoraInicio2 = 091000
    
    HoraEntradaLimite3 = 091600
    HoraInicio3 = 091500
    
    
    
    
    //Monday
    
    if Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=1   then
    n=1
    endif
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=1   then
    n=1
    endif
    
    if Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=1   then
    n=1
    endif
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=1   then
    n=1
    endif
    
    
    //Tuesday
    
    if Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=2   then
    n=1
    endif
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=2   then
    n=1
    endif
    if Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=2   then
    n=1
    endif
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=2   then
    n=1
    endif
    
    //Wednesday
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=3   then
    n=1
    endif
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=3   then
    n=1
    endif
    
    ////Thrusday
    
    if Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=4   then
    n=1
    endif
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=4   then
    n=1
    endif
    
    ////Friday
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=5   then
    n=1
    endif
    
    
    
    if 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 then
    
    
    c1 = open < close-2
    if not onmarket then
    IF c1 THEN
    
    buy n*ordersize contract AT close+2 stop
    endif
    
    c2= open > close-1
    
    IF c2 THEN
    
    sellshort n*ordersize contract AT close-1 stop
    endif
    endif
    endif
    
    
    
    //trailing stop
    trailingstop = 5
    
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
    
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    
    //SET STOP PLOSS 5
    
    manel thanked this post
    #23490 quote
    Nicolas
    Keymaster
    Master

    This version is the MFE one you can also try the other one :

    https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/

    #23493 quote
    volpiemanuele
    Participant
    Veteran

    @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

    // Definición de los parámetros del código
    DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
    
    DEFPARAM FlatAfter =173000
    
    Margin = 60
    Lottfree = 0
    orderSize = max(1,1+ROUND((strategyprofit-lottfree)/Margin))
    ordersize=min(50,ordersize)
    
    
    HoraEntradaLimite = 090100
    HoraInicio = 090000
    
    HoraEntradaLimite1 = 090600
    HoraInicio1 = 090500
    
    HoraEntradaLimite2 = 091100
    HoraInicio2 = 091000
    
    HoraEntradaLimite3 = 091600
    HoraInicio3 = 091500
    
    
    
    
    //Monday
    
    if Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=1   then
    n=1
    endif
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=1   then
    n=1
    endif
    
    if Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=1   then
    n=1
    endif
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=1   then
    n=1
    endif
    
    
    //Tuesday
    
    if Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=2   then
    n=1
    endif
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=2   then
    n=1
    endif
    if Time >= HoraInicio2 and time <= HoraEntradaLimite2 and dayofweek=2   then
    n=1
    endif
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=2   then
    n=1
    endif
    
    //Wednesday
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=3   then
    n=1
    endif
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=3   then
    n=1
    endif
    
    ////Thrusday
    
    if Time >= HoraInicio and time <= HoraEntradaLimite and dayofweek=4   then
    n=1
    endif
    
    if Time >= HoraInicio1 and time <= HoraEntradaLimite1 and dayofweek=4   then
    n=1
    endif
    
    ////Friday
    
    if Time >= HoraInicio3 and time <= HoraEntradaLimite3 and dayofweek=5   then
    n=1
    endif
    
    
    
    if 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 then
    
    
    c1 = open < close-2
    if not onmarket then
    IF c1 THEN
    
    buy n*ordersize contract AT close+2 stop
    endif
    
    c2= open > close-1
    
    IF c2 THEN
    
    sellshort n*ordersize contract AT close-1 stop
    endif
    endif
    endif
    
    
    
    //trailing stop function
    trailingstart = 5 //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
    
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    
    SET STOP PLOSS 5
    #23494 quote
    mamio
    Participant
    Veteran

    @emanuele, can you post your equity curve of the last 20000 bars please?

    #23495 quote
    volpiemanuele
    Participant
    Veteran

    Hi,

    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

    //trailing stop function
    trailingstart = 5 //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
    
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    
    SET STOP PLOSS 5
    mamio thanked this post
    back.docx
    #23505 quote
    Raul Vg
    Participant
    Senior

    The 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.

    #23506 quote
    CN
    Participant
    Senior

    I agree, how can we make the 10pts sl insted of trailing?

    #23516 quote
    CN
    Participant
    Senior

    Antoher day with loss, 1 win 1 big loss.

    How come the backtest shows win on v3 if you look yday and today?

    #23517 quote
    Joachim Nilsson
    Participant
    Average

    Hey 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.

    Skärmbild-52.png Skärmbild-52.png
    #23520 quote
    Nicolas
    Keymaster
    Master

    Since 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!

    #23521 quote
    CN
    Participant
    Senior

    I agree with @Nicolas.

    What does @raul and @emauele say?

    #23527 quote
    Raul Vg
    Participant
    Senior

    Hello! 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.

    #23538 quote
    Nicolas
    Keymaster
    Master

    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-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:

    if time=090000 then 
     val0900=close
    endif
    
    if time=090500 then 
     val0905=close
    endif 
    
    return val0900, val0905
    dax-open-close.png dax-open-close.png
    #23630 quote
    Raul Vg
    Participant
    Senior

    Hi 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?

    #23633 quote
    Nicolas
    Keymaster
    Master

    Depends of much time you want the order to remain on market? In fact you only need your trading conditions to remain true and the pending order will be set at each new candlestick, until the condition is set to false.

Viewing 15 posts - 376 through 390 (of 503 total)
  • You must be logged in to reply to this topic.

intraday DAX strategy 5min mini1€ spread 1


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Raul Vg @raul_v Participant
Summary

This topic contains 502 replies,
has 34 voices, and was last updated by Asteriks
5 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/19/2017
Status: Active
Attachments: 189 files
Logo Logo
Loading...