Strategy TrendImpulse v1

Viewing 15 posts - 1 through 15 (of 75 total)
  • Author
    Posts
  • #128304 quote
    Dow Jones
    Participant
    Veteran

    Hi everyone,

    Here is a new strategy on Wall Street/DJI 5 min TF that utilize Perfect Trend Line as entry/exit and Trend Impulse Filter as trend direction. All credits to the original author.

    DLS code is added to avoid high spread period. Time Zone used is UTC+08:00. Looking forward for your suggestion and ideas of improvement.

    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)
    
    timeframe(5 minute)
    thigh1 = Highest[SlowLength](high)+ SlowPipDisplace*pointsize
    tlow1  = Lowest[SlowLength](low)- SlowPipDisplace*pointsize
    thigh2 = Highest[FastLength](high)+ FastPipDisplace*pointsize
    tlow2  = Lowest[FastLength](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)
    
    once bb = src
    if barindex>length then
    src = (highest[length](high)+lowest[length](low))/2
    rising = src-src[length]>0
    falling = src-src[length]<0
    aa = rising or falling
    bb = exponentialaverage[centertrend](aa*src+(1-aa)*bb[1])
    //—-
    
    if bb>bb[1] then
    //bull
    trendimpulse = 1
    elsif bb<bb[1] then
    //bear
    trendimpulse = 2
    endif
    
    endif
    
    
    //====== Enter market - start =====
    
    //  LONG  side
    C1 = trendimpulse = 1 AND prefecttrend[1] = 2 AND prefecttrend = 1
    
    IF timeok AND Not OnMarket AND C1 THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP   pLOSS   SL
    
    ENDIF
    
    //  SHORT side
    C2 = trendimpulse = 2 AND prefecttrend[1] = 1 AND prefecttrend = 2
    
    IF timeok AND Not OnMarket AND C2 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
    
    
    //====== Exit market - end =====
    
    swedshare and JohnScher thanked this post
    #128311 quote
    Dow Jones
    Participant
    Veteran

    Please use XXXDJI-M1-TrendImpulsev1-1.itf, I cannot delete XXXDJI-M1-TrendImpulsev1.itf. Anyway, they are functionally the same, but v1 has the variable [center] which cannot be interpreted by Insert PRT code correctly, thus I rename it to [centertrend]

    #128315 quote
    Nicolas
    Keymaster
    Master

    Thanks a lot @yahootew3000. Did you make backtests with “only” 2 OOS please? What about the results if you exclude the last 3 months periods? (start the backtest earlier or just shorten the end date). I think that for most trend following strategy, the last period OOS is not so relevant because of the large volatility and directional bias of the market, just my humble opinion.

    #128392 quote
    GraHal
    Participant
    Master

    Time Zone used is UTC+08:00

    How come you used UTC + 8 when you are UTC +2 in Netherlands?

    Great looking code / System btw!

    Thank You for sharing with us all!

    Dow Jones thanked this post
    #128396 quote
    robertogozzi
    Moderator
    Master

    How come you used UTC + 8 when you are UTC +2 in Netherlands?

    Looks like more Singapore than Netherlands, doesn’t it?
    Lavallette thanked this post
    #128400 quote
    GraHal
    Participant
    Master
    Looks like more Singapore than Netherlands, doesn’t it?
    His flag you mean? It’s weird on his post his flag looks like Singapore? But then when I click  on his name I see a Netherlands flag?? But yeah … UTC + 8 would be correct for Singapore as Singapore is 12 hours ahead of New York. Now to convert for UK Time (UTC +1) EDIT / PS Now I look more closely you are correct Roberto … both flags are Singapore! My eyes again, but also the flags appear so tiny on my screen.
    #128449 quote
    Dow Jones
    Participant
    Veteran
    Thanks a lot @yahootew3000. Did you make backtests with “only” 2 OOS please? …
    Oh ya Nicolas. I did just 2 OOS, used to 1 min time frame. I redo for 5 OOS, seems not so good 🙁 I like this system due to high frequency, but perhaps need to add some other filter…
    #128453 quote
    Dow Jones
    Participant
    Veteran
    Now I look more closely you are correct Roberto … both flags are Singapore!
    Haha, yes, from Singapore indeed…
    GraHal thanked this post
    #128898 quote
    Lucho0712
    Participant
    New
    Hi, congrats for the strategy, it works great with indexes. It’s probably a newbie’s question, but here it goes: how come when I apply this startegy to indexes the performance is great, but when I apply it to a stock the result is not good. I have tried in many different ways to get a good performance with different stocks, but no success. Maybe I am getting this wrong, but isn’t the end objective to apply these to stocks, as we can not buy indexes? sory for the ignorance… Another issue I have encountered is that the command “timeframe” is not accepted by prorealtime 10.3, it returns a message that says it is only allowed for ProScreener. How did you manage to make it work? Cheers and thanks for the great strategy Luis
    #128990 quote
    Dow Jones
    Participant
    Veteran
    No worry, in fact, I’m new as well, I learned a lot from this forum actually 🙂
    how come when I apply this startegy to indexes the performance is great, but when I apply it to a stock the result is not good.
    It is built for the index future only, not for a specific stock, the variables may not be suitable, the SL range is different as well. But I think take some effort, it is possible to apply for stock, but I have less interest to trade algo on stock as you can see this strategy is for frequent trade, if applying on stocks, the commission is costly.
    Maybe I am getting this wrong, but isn’t the end objective to apply these to stocks, as we can not buy indexes?
    Not trading against the index itself, but the future contract of the index. The trade is done using CFD.  
    Another issue I have encountered is that the command “timeframe” is not accepted by prorealtime 10.3
    PRT 10.3 should support it. I don’t know if there is any known issue. @Nicolas, maybe you encounter similar question before or know the answer?
    #128993 quote
    Nicolas
    Keymaster
    Master
    @Lucho0712 If your broker not support real live automatic trading, this error is normal since you still using a previous version of the platform.
    Lucho0712 thanked this post
    #128998 quote
    nonetheless
    Participant
    Master
    Now to convert for UK Time (UTC +1)
    Did you manage to get this to run on UK time? I tried subtracting 7 hours from all times but makes no difference, results are dismal using the fixed values in the opt box.
    #129007 quote
    GraHal
    Participant
    Master
    I agree @Nonetheless and I don’t think it’s times either as they are only short periods where spread is sky high. I put it on the back burner for a while … be good if we can solve the mystery as the OP and  Lucho0712 say it works great!?
    nonetheless thanked this post
    #129018 quote
    Lucho0712
    Participant
    New
    Thanks yahootew for the answers. I am not going to get in CFDs rirght now as I have read that most beginers loose a lot. I will continue learning before getting into this, Thanks anyway!
    #129019 quote
    Lucho0712
    Participant
    New
    Don´t listen to mee too much, I am new at this. I just tried it out on some indexes and compared it to a simple buy and hold strategy, outperforming it.
Viewing 15 posts - 1 through 15 (of 75 total)
  • You must be logged in to reply to this topic.

Strategy TrendImpulse v1


ProOrder: Automated Strategies & Backtesting

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: Automated Strategies & Backtesting
Language: English
Started: 04/27/2020
Status: Active
Attachments: 19 files
Logo Logo
Loading...