Dax Trend following, h2 Time zone:uk

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #88471 quote
    Francesco78
    Participant
    Master
    defparam cumulateorders = false
    n=2
    soglia = 0.02
    timestart = 90000
    timeend = 180000
    profitti = 275
    perdite = 350
    timeok = time>=timestart and time<=timeend
    
    c = (sin(atan((close-open[n])/open[n]*100/n)))
    if c crosses over soglia and timeok  then
    buy 1 contract at market
    endif
    
    if c crosses under -soglia and timeok  then
    sellshort 1 contract at market
    endif
    
    set target pprofit profitti
    set stop ploss perdite
    daxh-154739452948lpc.png daxh-154739452948lpc.png
    #88567 quote
    Nicolas
    Keymaster
    Legend

    Thanks again Francesco, any WFA to share for this one?

    #88571 quote
    Francesco78
    Participant
    Master
    #88650 quote
    Nicolas
    Keymaster
    Legend

    Ok but the optimized variables in your first post are the ones found for a 100% IS optimization? Better to know and explain in the post because people will ask a lot of questions 🙂

    Wilko thanked this post
    #88756 quote
    O-jay8
    Participant
    Veteran

    Hello Francesco,
    Thank you again for another contribution. It is really appreciated.
    I have a question, do you optimise all of the data or do you use in-sample and out-of-sample?

    Best regards

    #88757 quote
    Francesco78
    Participant
    Master

    The first

    is optimized over the whole set of data.

    the second post shows walk forward 75/25

    Hope this answer your question

    Regards

    #88923 quote
    Nicolas
    Keymaster
    Legend

    Strategy added into the library: DAX Trend following: 2-hours timeframe

    Francesco78 thanked this post
    #88926 quote
    Francesco78
    Participant
    Master

    Thank you!

    #89167 quote
    Gianluca
    Participant
    Master

    Ciao, i had very different result with 200k bars, but anyway i changed something in the code.

    i have 2 questions
    in this function

    c = (sin(atan((close–open[n])/open[n]*100/n)))

    i never seen the command SIN AND ATAN what are they? and how you found them? i the function search of PRT they aren’t presents. Thank you.

    This is my version of your code, hoping could help.

    defparam cumulateorders = false
    //1/TRAILING STOP//////////////////////////////////////////////////////
    once trailinstop= 1   //1 on - 0 off
    trailingstart = 100 //trailing will start @trailinstart points profit
    trailingstep = 60 //trailing step to move the "stoploss"
    ///2 BREAKEAVEN///////////
    once breakeaven = 1    //1 on - 0 off
    startBreakeven = 50 //how much pips/points in gain to activate the breakeven function?
    PointsToKeep = 30 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
    
    n=2
    soglia = 0.01
    sogliashort=-0.06
    timestart = 90000
    timeend = 180000
    profitti = 165
    entratalong=0
    entratashort=0
    timeok = time>=timestart and time<=timeend
    
    c = ((sin(atan((close-open[n])/open[n]*100/n)))*100)+close
    c2 = (sin(atan((close-open[n])/open[n]*100/n)))
    graphonprice c
    
    if c>close and c2 > soglia and timeok  then
    entratalong=high+1*pipsize
    sl = (entratalong - low) / pipsize
    buy 1 contract at entratalong stop//market
    entratalong=0
    set target pprofit profitti
    set stop ploss sl+10
    endif
    
    if c<close and c2<sogliashort and timeok then
    entratashort=low-1*pipsize
    sl = (high - entratashort) * pipsize
    sellshort 1 contract at entratashort stop
    entratashort=0
    set target pprofit profitti
    set stop ploss sl+10
    endif
    
    
    ///1///////////////////////////////////////////////
    //reset the breakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    //2////////////////////////////
    //test if the price have moved favourably of "startBreakeven" points already
    if breakeaven>0 then
    IF onmarket AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
     
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    endif
    
    //************************************************************************
    //trailing stop function
    if trailinstop>0 then
    //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
    endif
    

    [attachment file=”89168″]

    [attachment file=”89169″]

    2h-trend-foll-francesco.jpg 2h-trend-foll-francesco.jpg francesco-2h.jpg francesco-2h.jpg
    #89171 quote
    Vonasi
    Moderator
    Master
    #89251 quote
    Gianluca
    Participant
    Master

    thank you!

    #115397 quote
    nonetheless
    Participant
    Master

    Ciao Francesco, I have added a trailing stop to your code which seems to help but I’m unclear about the WFE. See the screen shots below, does this look over-optimized?

    This is my version:

    defparam cumulateorders = false
    n=2
    soglia = 0.02
    timestart = 90000
    timeend = 180000
    profitti = 280
    perdite = 340
    timeok = time>=timestart and time<=timeend
    
    c = (sin(atan((close-open[n])/open[n]*100/n)))
    if c crosses over soglia and timeok  then
    buy 1 contract at market
    endif
    
    if c crosses under -soglia and timeok  then
    sellshort 1 contract at market
    endif
    
    set target pprofit profitti
    set stop ploss perdite
    
    //trailing stop function
    trailingstart = 57 //trailing will start @trailinstart points profit
    trailingstep = 1 //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
    DAX-5m.jpg DAX-5m.jpg DAX-5m-WFE.jpg DAX-5m-WFE.jpg
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Dax Trend following, h2 Time zone:uk


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 11 replies,
has 6 voices, and was last updated by nonetheless
6 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/14/2019
Status: Active
Attachments: 7 files
Logo Logo
Loading...