Strategy TrendImpulse v1

Viewing 15 posts - 16 through 30 (of 75 total)
  • Author
    Posts
  • #129028 quote
    fredb
    Participant
    Junior

    hello i am fred and i am a beginner in ready programming. I am trying to use your XXXDJI-M1 program, but I have a message that says: edit the code. could you help me please ?

    #129035 quote
    Lucho0712
    Participant
    New

    I am not an expert, but I can try. Is this a message you get when you try to backtest the code? could you send a screenshot?

    #129068 quote
    fredb
    Participant
    Junior

    hello Lucho0712 do you speak french ?

    #129075 quote
    Vonasi
    Moderator
    Master

    do you speak french ?

    Even if you do then please do not do so in the English speaking forums. Start a fresh topic in the French forum if you wish to discuss things in French.

    #129083 quote
    fredb
    Participant
    Junior

    hello i am calling fred i am french and i am a beginner in ready programming. I am trying to use your XXXDJI-M1 program, but I have a message that says: edit the code. could you help me please

    #129107 quote
    Maik2404
    Participant
    Veteran

    Wahrscheinlich meinte er diese Meldung siehe Anhang. Ich kann den Code auch nicht starte. Ich soll die Variablen einfügen. Aber weiß nicht wie.

    He probably meant this message see attachment. I can’t start the code either. I should insert the variables. But don’t know how.

    #129109 quote
    Vonasi
    Moderator
    Master

    Maik2404 – You failed to attach any image plus….

    There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.

    The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:

    Post your topic in the correct forum.

    ProRealTime Platform Support          only platform related issues.
    ProOrder                                                only strategy topics.
    ProBuilder                                              only indicator topics.
    ProScreener                                           only screener topics
    General Discussion                               any other topics.
    Welcome New Members                      for new forum members to introduce themselves.

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
    Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
    Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
    Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
    Always be polite and courteous to others.
    Have fun.

    I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂

    #129110 quote
    Lucho0712
    Participant
    New

    Maik Fred, as Yahootew mentions in the original post, try downloading XXXDJI-M1-TrendImpulsev1-1.itf

    That version contains the variables. Maybe it solves your problem

    #129111 quote
    Maik2404
    Participant
    Veteran

    Coding help required. I got the message that I should use variables, but I don’t know how to edit the code. Can someone help me?

    #129140 quote
    Maik2404
    Participant
    Veteran

    Lucho0712: I can do the backtest but if I want to start the system then I should replace the variables with specific values. The variables are predefined but always from to. Do I have to assign fixed values? How can I do that?

    #129143 quote
    Maik2404
    Participant
    Veteran

    worked … thanks

    #129327 quote
    patapouf
    Participant
    Average

    Thanks a lot yahootex3000.

    I was looking at the DLS conditions.

    Things become a bit more complicated if we live in Europe, since we too have a DLS period… but not exactly on the same period as USA !

    In Europe, DLS time begins on the last Sunday of March, and ends on the last Sunday of October.

    As a consequence, during 2 short periods, in March (from the 2nd Sunday to the last Sunday) and in October/November (from the las Sunday of October to the 1st Sunday of November), the time difference is only 5 hrs, while it is 6 hrs during the other part of the year. I  am trying to solve the equation !

    #129712 quote
    Dow Jones
    Participant
    Veteran

    In Europe, DLS time begins on the last Sunday of March, and ends on the last Sunday of October.

    Indeed, I have a code for DLS conversion of ASIA->UK, but no UK (or EUR) -> USA. Anyway, I share also the UK version here, hope it can help a bit…

    // ---------   UK DAY LIGHT SAVINGS MONTHS      ---------------- //
    mar = month = 3 // MONTH START
    oct = month = 10 // MONTH END
    
    IF ( dayofweek >= 0 and mar AND 31-day<7 ) OR ( month > 3 AND month < 10 ) OR ( oct AND 31-day > 6 )  OR  (dayofweek = 4 AND oct AND day<31) OR (dayofweek = 3 AND oct AND day+1<31) OR  (dayofweek = 2 AND oct AND day+2<31) OR (dayofweek = 1 AND oct AND day+3<31) OR (dayofweek = 0 AND oct AND day+4<31)  OR (dayofweek = 5 AND oct AND 31-day<7) THEN
    UKDLS=1
    ELSE
    UKDLS=0
    ENDIF
    #129779 quote
    Dow Jones
    Participant
    Veteran

    Hi All,

    I integrated the ML + Trailing Stop and replace the trendimpulse with bollinger, result seems better. Also added ATR to filter out the huge volatility and cause big losses or big winners (especially March) to be more practical for live.

    Take note I’m taking 90-10 WFA 5 iterations to optimize the startingvalue and startingvalue2.

    Please see attached.

    DEFPARAM CumulateOrders = false
    DEFPARAM PRELOADBARS = 1000
    
    // ---------   US DAY LIGHT SAVINGS MONTHS      ---------------- //
    mar = month = 3 // MONTH START
    nov = month = 11 // MONTH END
    IF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THEN
    USDLS=010000
    ELSE
    USDLS=0
    ENDIF
    
    timeok = NOT(time >051500- USDLS AND time <053000 - USDLS) AND NOT(time >060000 - USDLS AND time <070000 - USDLS)
    
    //startingvalue   = 15 //5, 100, 10 boxsize
    increment       = 5 //5, 20, 10
    maxincrement    = 7 //5, 10 limit of no of increments either up or down
    reps            = 3  //1 number of trades to use for analysis //2
    maxvalue        = 70 //20, 300, 150 //maximum allowed value
    minvalue        = 50 //5, minimum allowed value
    
    //startingvalue2  = 55 //5, 100, 50 stop loss
    increment2      = 3 //5, 10
    maxincrement2   = 7 //1, 30 limit of no of increments either up/down //4
    reps2           = 3  //1, 2 nos of trades to use for analysis //3
    maxvalue2       = 25 //20, 300, 200 maximum allowed value
    minvalue2       = 5 //5, minimum allowed value
    
    heuristicscyclelimit = 2
    
    once heuristicscycle = 0
    once heuristicsalgo1 = 1
    once heuristicsalgo2 = 0
    
    if heuristicscycle >= heuristicscyclelimit then
    if heuristicsalgo1 = 1 then
    heuristicsalgo2 = 1
    heuristicsalgo1 = 0
    elsif heuristicsalgo2 = 1 then
    heuristicsalgo1 = 1
    heuristicsalgo2 = 0
    endif
    heuristicscycle = 0
    else
    once valuex = startingvalue
    once valuey = startingvalue2
    endif
    
    if heuristicsalgo1 = 1 then
    
    //heuristics algorithm 1 start
     
    if (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) then
    optimise = optimise + 1
    endif
    
    once valuex  = startingvalue
    once pincpos = 1 //positive increment position
    once nincpos = 1 //negative increment position
    once optimise = 0 //initialize heuristicks engine counter (must be incremented at position start or exit)
    once mode1 = 1 //switches between negative and positive increments
    //once wincountb = 3 //initialize best win count
    //graph wincountb coloured (0,0,0) as "wincountb"
    //once stratavgb = 4353 //initialize best avg strategy profit
    //graph stratavgb coloured (0,0,0) as "stratavgb"
     
    if optimise = reps then
    wincounta = 0 //initialize current win count
    stratavga = 0 //initialize current avg strategy profit
    heuristicscycle = heuristicscycle + 1
     
    for i = 1 to reps do
    if positionperf(i) > 0 then
    wincounta = wincounta + 1 //increment current wincount
    endif
    stratavga = stratavga + (((positionperf(i)*countofposition[i]*close)*-1)*-1)
    next
    stratavga = stratavga/reps //calculate current avg strategy profit
    //graph (positionperf(1)*countofposition[1]*100000)*-1 as "posperf1"
    //graph (positionperf(2)*countofposition[2]*100000)*-1 as "posperf2"
    //graph stratavga*-1 as "stratavga"
    //once besta = 300
    //graph besta coloured (0,0,0) as "besta"
    if stratavga >= stratavgb then
    stratavgb = stratavga //update best strategy profit
    besta = valuex
    endif
    //once bestb = 300
    //graph bestb coloured (0,0,0) as "bestb"
    if wincounta >= wincountb then
    wincountb = wincounta //update best win count
    bestb = valuex
    endif
     
    if wincounta > wincountb and stratavga > stratavgb then
    mode1 = 0
    elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 1 then
    valuex = valuex - (increment*nincpos)
    nincpos = nincpos + 1
    mode1 = 2
    elsif wincounta >= wincountb or stratavga >= stratavgb and mode1 = 1 then
    valuex = valuex + (increment*pincpos)
    pincpos = pincpos + 1
    mode1 = 1
    elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 2 then
    valuex = valuex + (increment*pincpos)
    pincpos = pincpos + 1
    mode1 = 1
    elsif wincounta >= wincountb or stratavga >= stratavgb and mode1 = 2 then
    valuex = valuex - (increment*nincpos)
    nincpos = nincpos + 1
    mode1 = 2
    endif
     
    if nincpos > maxincrement or pincpos > maxincrement then
    if besta = bestb then
    valuex = besta
    else
    if reps >= 10 then
    weightedscore = 10
    else
    weightedscore = round((reps/100)*100)
    endif
    valuex = round(((besta*(20-weightedscore)) + (bestb*weightedscore))/20) //lower reps = less weight assigned to win%
    endif
    nincpos = 1
    pincpos = 1
    elsif valuex > maxvalue then
    valuex = maxvalue
    elsif valuex < minvalue then
    valuex = minvalue
    endif
     
    optimise = 0
    endif
     
    // heuristics algorithm 1 end
    
    elsif heuristicsalgo2 = 1 then
    
    // heuristics algorithm 2 start
     
    if (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) then
    optimise2 = optimise2 + 1
    endif
     
    once valuey = startingvalue2
    once pincpos2 = 1 //positive increment position
    once nincpos2 = 1 //negative increment position
    once optimise2 = 0 //initialize heuristicks engine counter (must be incremented at position start or exit)
    once mode2 = 1 //switches between negative and positive increments
    //once wincountb2 = 3 //initialize best win count
    //graph wincountb2 coloured (0,0,0) as "wincountb2"
    //once stratavgb2 = 4353 //initialize best avg strategy profit
    //graph stratavgb2 coloured (0,0,0) as "stratavgb2"
     
    if optimise2 = reps2 then
    wincounta2 = 0 //initialize current win count
    stratavga2 = 0 //initialize current avg strategy profit
    heuristicscycle = heuristicscycle + 1
     
    for i2 = 1 to reps2 do
    if positionperf(i2) > 0 then
    wincounta2 = wincounta2 + 1 //increment current wincount
    endif
    stratavga2 = stratavga2 + (((positionperf(i2)*countofposition[i2]*close)*-1)*-1)
    next
    stratavga2 = stratavga2/reps2 //calculate current avg strategy profit
    //graph (positionperf(1)*countofposition[1]*100000)*-1 as "posperf1-2"
    //graph (positionperf(2)*countofposition[2]*100000)*-1 as "posperf2-2"
    //graph stratavga2*-1 as "stratavga2"
    //once besta2 = 300
    //graph besta2 coloured (0,0,0) as "besta2"
    if stratavga2 >= stratavgb2 then
    stratavgb2 = stratavga2 //update best strategy profit
    besta2 = valuey
    endif
    //once bestb2 = 300
    //graph bestb2 coloured (0,0,0) as "bestb2"
    if wincounta2 >= wincountb2 then
    wincountb2 = wincounta2 //update best win count
    bestb2 = valuey
    endif
     
    if wincounta2 > wincountb2 and stratavga2 > stratavgb2 then
    mode2 = 0
    elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 1 then
    valuey = valuey - (increment2*nincpos2)
    nincpos2 = nincpos2 + 1
    mode2 = 2
    elsif wincounta2 >= wincountb2 or stratavga2 >= stratavgb2 and mode2 = 1 then
    valuey = valuey + (increment2*pincpos2)
    pincpos2 = pincpos2 + 1
    mode2 = 1
    elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 2 then
    valuey = valuey + (increment2*pincpos2)
    pincpos2 = pincpos2 + 1
    mode2 = 1
    elsif wincounta2 >= wincountb2 or stratavga2 >= stratavgb2 and mode2 = 2 then
    valuey = valuey - (increment2*nincpos2)
    nincpos2 = nincpos2 + 1
    mode2 = 2
    endif
     
    if nincpos2 > maxincrement2 or pincpos2 > maxincrement2 then
    if besta2 = bestb2 then
    valuey = besta2
    else
    if reps2 >= 10 then
    weightedscore2 = 10
    else
    weightedscore2 = round((reps2/100)*100)
    endif
    valuey = round(((besta2*(20-weightedscore2)) + (bestb2*weightedscore2))/20) //lower reps = less weight assigned to win%
    endif
    nincpos2 = 1
    pincpos2 = 1
    elsif valuey > maxvalue2 then
    valuey = maxvalue2
    elsif valuey < minvalue2 then
    valuey = minvalue2
    endif
     
    optimise2 = 0
    endif
    // heuristics algorithm 2 end
    endif
    
    //GRAPH valuex
    //GRAPH valuey
    
    timeframe(1 day)
    volindic = (averagetruerange[5](close)/close)*100
    
    timeframe(5 minute)
    thigh1 = Highest[valuex](high)+ SlowPipDisplace*pointsize
    tlow1  = Lowest[valuex](low)- SlowPipDisplace*pointsize
    thigh2 = Highest[valuey](high)+ FastPipDisplace*pointsize
    tlow2  = Lowest[valuey](low)- FastPipDisplace*pointsize
    
    if barindex>2 then
    if Close>line1[1] then
    line1 = tlow1
    else
    line1 = thigh1
    endif
    if Close>line2[1] then
    line2 = tlow2
    else
    line2 = thigh2
    endif
    endif
    
    if (Close[0]<line1[0] and Close[0]<line2[0]) then
    trend =  1
    endif
    if (Close[0]>line1[0] and Close[0]>line2[0]) then
    trend = -1
    endif
    if (line1[0]>line2[0] or trend[0] =  1) then
    trena =  1
    endif
    if (line1[0]<line2[0] or trend[0] = -1) then
    trena = -1
    endif
    if trena<>trena[1] then
    if trena=1 then
    //bear
    prefecttrend = 2
    else
    //bull
    prefecttrend = 1
    endif
    endif
    
    timeframe(default)
    
    bollMA = average[length, 1](close)//50,1
    STDDEV = STD[length]
    bollUP = bollMA + 2 * STDDEV
    bollDOWN = bollMA - 2 * STDDEV
    bollPercent = 100 * (close - bollDOWN) / (bollUP - bollDOWN)
    
    
    //====== Enter market - start =====
    
    //  LONG  side
    C1 = bollPercent > 60 AND prefecttrend[1] = 2 AND prefecttrend = 1
    
    IF timeok AND Not OnMarket AND C1 AND volindic < 3.5 THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP   pLOSS   SL
    
    ENDIF
    
    //  SHORT side
    C2 = bollPercent < 40 AND prefecttrend[1] = 1 AND prefecttrend = 2
    
    IF timeok AND Not OnMarket AND C2 AND volindic < 3.5 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    SET STOP   pLOSS   SL
    
    ENDIF
    
    
    //====== Enter market - end =====
    
    //====== Exit market - start =====
    
    X1 = prefecttrend[1] = 1 AND prefecttrend = 2
    IF LONGONMARKET AND X1 THEN
    SELL AT MARKET
    ENDIF
    
    
    X2 = prefecttrend[1] = 2 AND prefecttrend = 1
    IF SHORTONMARKET AND X2 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Avoid losing trade not caught by training
    tradegain = POSITIONPERF * 100
    rangelevel = 100* (range)/close
    gainenough = summation[barindex - tradeindex](tradegain > 0.2) > 1
    closefast = gainenough AND rangelevel < 0.5 AND POSITIONPERF * 100 <= 0.1
    
    IF closefast THEN
    EXITSHORT AT MARKET
    SELL AT MARKET
    ENDIF
    
    
    //====== Exit market - end =====
    
    //====== Trailing Stop mechanism - start =====
    
    trailingstart = (0.5 * SL ) / pointsize
    trailingstep = (0.25 * SL ) / pointsize
    
    //resetting variables when no trades are on market
    if not onmarket then
    priceexit = 0
    endif
    
    //case LONG order
    if longonmarket then
    
    //first move (breakeven)
    IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THEN
    priceexit = tradeprice(1) + trailingstep*pointsize
    ENDIF
    //next moves
    IF priceexit>0 THEN
    
    P2 = close-priceexit >= trailingstart*pointsize
    IF P2 THEN
    priceexit = priceexit + trailingstep*pointsize
    ENDIF
    
    ENDIF
    
    endif
    
    //case SHORT order
    if shortonmarket then
    
    //first move (breakeven)
    IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THEN
    priceexit = tradeprice(1) - trailingstep*pointsize
    ENDIF
    //next moves
    IF priceexit>0 THEN
    
    P2 = priceexit-close >= trailingstart*pointsize
    IF P2 THEN
    priceexit = priceexit - trailingstep*pointsize
    ENDIF
    
    ENDIF
    
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    
    //====== Trailing Stop mechanism - end =====
    
    swedshare and keewee thanked this post
    #129849 quote
    Yomihou
    Participant
    New

    Hi yahootew3000

    Thank you very interesting strategy. I worked a lot on your previews version. I think some entry point missed because of the closure of a previous position.

    I’m going to look at your new one. Boll are interesting indeed. On you result screen below which variable did you use? Even with optimization tool starting date 2019, I can find out the same result. Maybe i’m wrong on something, is there variable to modify in the code text directly?

    Many thanks for the work.

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

Strategy TrendImpulse v1


ProOrder support

New Reply
Author
author-avatar
Dow Jones @yahootew3000 Participant
Summary

This topic contains 74 replies,
has 6 voices, and was last updated by thomas2004ch
3 years, 1 month ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 04/27/2020
Status: Active
Attachments: 19 files
Logo Logo
Loading...