Trend surfer DAX modified

Viewing 15 posts - 16 through 30 (of 46 total)
  • Author
    Posts
  • #66011 quote
    irioton
    Participant
    Average

    I tried this :

    if close[val]>0 and close[val]<close[val[1]] and close[val[1]]>0 and close[val[1]]>close[val[2]] then
    IF LONGONMARKET THEN
    SELL 1 SHARES AT MARKET
    SELLSHORT 1 SHARES AT MARKET
    ELSE
    SELLSHORT 1 SHARES AT MARKET
    ENDIF
    ENDIF
    
    
    if close[val]<0 and close[val]>close[val[1]] and close[val[1]]<0 and close[val[1]]<close[val[2]]then
    IF SHORTONMARKET THEN
    EXITSHORT 1 SHARES AT MARKET
    BUY 1 SHARES AT MARKET
    ELSE
    BUY 1 SHARES AT MARKET
    
    ENDIF
    ENDIF

    but still doesn’t work…

    #66012 quote
    GraHal
    Participant
    Master

    How about below, also try including volume also?

    if Close > average[200](close) AND close[val]<0 and close[val]>close[val[1]] and close[val[1]]<0 and close[val[1
    #66016 quote
    irioton
    Participant
    Average

    Ok, I finally made it work my way, then I added your code (+5% win ratio), then I added volume, it didn’t change much, same thing for volatility.

    I’ve got good %win ratio but awful win/loss ratio, any idea how to improve this ?

    ratios.png ratios.png
    #66022 quote
    GraHal
    Participant
    Master

    What about adding a momentum indicator, e.g. Chande Momentum Index or similar; RSI maybe??

    #66039 quote
    irioton
    Participant
    Average

    OK, eventually I filtered it with supertrend extended (see attached), looks better now, I’ll try to push it.

    Here’s the code :

    a = 89 (sl)

    b = 28 (tp)

    c = 20

    d = 1

    // Trend Surfer DAX Modified
    DEFPARAM CumulateOrders = False
    
    // code-Parameter
    DEFPARAM FlatBefore = 080500
    DEFPARAM FlatAfter = 180000
    
     
    // DAX trading window
    ONCE BuyTimeMorning = 080500
    //ONCE SellTimeMorning = 110000
    //ONCE BuyTimeAfternoon = 130000
    ONCE SellTimeAfternoon = 173000
    
    // trading parameter
    ONCE sl = a
    ONCE tp = b
    ONCE lengthKC=20
    
    // position management during trading window
    IF (Time >= BuyTimeMorning AND Time <= SellTimeAfternoon) THEN
    
    value = (Highest[lengthKC](high)+Lowest[lengthKC](low)+average[lengthKC](close))/3
    val = linearregression[lengthKC](close-value)
    indicator1, ignored = CALL "PRC_SuperTrend Extended"[2.236, 66, 1, 10]
    ignored, indicator2 = CALL "PRC_SuperTrend Extended"[2.236, 66, 1, 10]
    c1 = (indicator1 < indicator2)
    c2 = (indicator1 > indicator2)
    
    if val>0 and val[1]>0 and val[2]>0 and val<val[1] and val[1]>val[2] and c2 then
    IF LONGONMARKET THEN
    SELL 1 SHARES AT MARKET
    SELLSHORT 1 SHARES AT MARKET
    ELSE
    SELLSHORT 1 SHARES AT MARKET
    ENDIF
    ENDIF
     
    if val<0 and val[1]<0 and val[2]<0 and val>val[1] and val[1]<val[2] and c1 then
    
    IF SHORTONMARKET THEN
    EXITSHORT 1 SHARES AT MARKET
    BUY 1 SHARES AT MARKET
    ELSE
    BUY 1 SHARES AT MARKET
    ENDIF
    ENDIF
    
    StopdistanceBreakeven = c
    NormalStop = sl
    
    nb = barindex - tradeindex
    minprice = lowest[nb + 1](Low)
    maxprice = highest[nb + 1](High)
    
    If longonmarket then
    If maxprice >= positionprice + StopdistanceBreakeven then
    sell at (positionprice + 1 ) stop
    else
    sell at positionprice - NormalStop stop
    endif
    endif
    
    If shortonmarket then
    If minprice <= positionprice - StopdistanceBreakeven then
    exitshort at (positionprice - 1) stop
    else
    exitshort at positionprice + NormalStop stop
    endif
    endif
    // stop and profit
    //SET STOP pLOSS sl
    SET TARGET pPROFIT tp
     
    ENDIF
    

     

    chears !

    Sans-titre.png Sans-titre.png
    #66041 quote
    irioton
    Participant
    Average

    i just saw that i tested it on 10 000 bars, its still good thow, but not so good…

    #66042 quote
    irioton
    Participant
    Average

    Again, it doesn’t do what I want, which also means it can be even more profitable.

    See picture attached, any suggestions are welcome.

    Sans-titre-1.png Sans-titre-1.png
    #66078 quote
    irioton
    Participant
    Average

    I cooked another one that seems to work : ut 2min, trades on TDI overbought/oversold.

    Neutral trades are in fact winners of 1 pip (spread + 1)

    GraHal thanked this post
    Sans-titre-2.png Sans-titre-2.png TDI-SURACHAT-SURVENTEok.itf
    #66190 quote
    irioton
    Participant
    Average

    Here is an other one, much more profitable, based on moving avegerage 50 and 500 (optimized) crossing.

    Sometimes, the simpler, the better. I can’t go back further 3 months thow…

    Nicolas and GraHal thanked this post
    moyenne-mobille.itf Sans-titre-3.png Sans-titre-3.png
    #66209 quote
    irioton
    Participant
    Average

    Even better if we make it swinng trading.

    GraHal thanked this post
    Sans-titre-4.png Sans-titre-4.png moyenne-mobille1.itf
    #66942 quote
    irioton
    Participant
    Average

    Hi again !

    I’m trying to make some tweaks on the last code I posted, but I need help…

    I took nicolas’ trailing code here https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/

    I’m keeping the break even part, but I want the trailing step to be the last high or low (if we go short or long) of “n” or “m” periods (n and m being different for long or short and to be optimized).

    here’s what I changed, but it doesn’t seem to work :

    trailingstart = 39
    clow = tradeprice - (lowest[m](low))
    chigh= (highest[n](high))-tradeprice
     
    //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)+clow*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=clow*pipsize THEN
    newSL = newSL+clow*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)-chigh*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=chigh*pipsize THEN
    newSL = newSL-chigh*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************
     
    GRAPH newSL as "trailing"
    #66946 quote
    irioton
    Participant
    Average

    It is defined to 39, I missed it when I copied/pasted the code, I edited the post to correct that, sorry

    #66948 quote
    GraHal
    Participant
    Master

    Aha I thought my eyes were deceiving me so I nipped in and deleted my comment re the Trailingstart! 🙂 🙂

    Have you use GRAPH to see what the value of tradeprice (lowest[m](low)) is?  Because if it is > Trailing start then it wouldn’t work anyway??

    #66950 quote
    irioton
    Participant
    Average

    ok I am going to look closer, I ‘ll report back when I shall find the error.

    Meanwhile, I added pyramiding code I founded in nicolas’ advanced training videos,

    I tweaked it so that position size increases also after a win (and not just deacreases after a loss).

    Win/loss ratio jumped from 4,73 to 5,71.

    here’s the code to put at the begining :

    taille=1
    for i = 1 to 2 do
    if positionperf(i)<0 then
    taille=taille-1
    else
    if taille<5 then
    taille=taille+1
    endif
    endif
    next
    #66951 quote
    GraHal
    Participant
    Master

    Please could you put your latest full code on here and then I can see if I can offer any improvements, but doubt I will as you are doing great on your own … your code has done me well today!

    Thank You
    GraHal

    irioton.jpg irioton.jpg
Viewing 15 posts - 16 through 30 (of 46 total)
  • You must be logged in to reply to this topic.

Trend surfer DAX modified


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
irioton @irioton Participant
Summary

This topic contains 45 replies,
has 6 voices, and was last updated by irioton
7 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/19/2018
Status: Active
Attachments: 27 files
Logo Logo
Loading...