add snippet to breakout code

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #193911 quote
    ullle73
    Participant
    Senior

    Ive got much appreciated help from Roberto coding a DJ open-breakout strategy. I would like to get some help adding US daylight savings time or EU summer/winter time snippet code to this strategy.

     

    DEFPARAM CumulateOrders = FALSE
    
    IF Not OnMarket THEN
    MyExit = 0
    ELSE
    c1 = 0
    ENDIF
    // ADR Average Daily Range
    MyADR       = average[20,0](Dhigh(1) - Dlow(1))
    //
    IF (Time = 000000) OR ((Time > 000000) AND (Time < Time[1])) THEN
    MyHI     = high
    MyLO     = low
    c1       = 0
    ENDIF
    IF Time <= 142900 THEN
    MyHI     = max(MyHI,high)
    MyLO     = min(MyLO,low)
    MyRange  = MyHI - MyLO
    c1       = ((MyRange / MyADR) * 100) < x //75
    ENDIF
    IF Time >= 142900 AND c1 THEN
    BUY       0.2 Contract AT MyHI + y * pipsize STOP
    SELLSHORT 0.2 Contract AT MyLO - y * pipsize STOP
    SET TARGET pPROFIT PL //40
    SET STOP   pLOSS   SL //80
    ENDIF
    IF MyExit = 0 THEN
    IF (LongOnMarket AND (close - TradePrice) >= t * pipsize) OR (ShortOnMarket AND (TradePrice - close) >= tS * pipsize) THEN //27.5 37.5
    MyExit = TradePrice
    ENDIF
    ENDIF
    IF MyExit > 0 THEN
    SELL      AT MyExit STOP
    EXITSHORT AT MyExit STOP
    ENDIF
    //GraphOnPrice TradePrice coloured(0,0,255,255)
    //GraphOnPrice MyHI       coloured(0,128,0,200)
    //GraphOnPrice MyLO       coloured(255,0,0,255)
    //Graph close - TradePrice
    //Graph c1
    //Graph MyADR
    //Graph MyRange
    

    Ive found this US daylight savings code in MOD:

    // ---------   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
    
    once shortStep = 0
    once openStrongLong = 0
    if not onmarket or (time <= 143000 - USDLS and time >= 210000 - USDLS) then
    shortStep = 0
    openStrongLong = 0
    endif
    
    //detect strong direction for market open
    once rangeOK = 50
    once tradeMin = 500
    IF (time >= 144000 - USDLS) AND (time <= 144000 + tradeMin - USDLS) THEN
    openStrongLong = close > open AND close - open > rangeOK
    ENDIF

     

    I dont get it to work, since results are exactly the same.

    #194055 quote
    robertogozzi
    Moderator
    Master

    I think this should the the correct snippet (for 2022):

    // ---------   US DAY LIGHT SAVINGS MONTHS      ---------------- //
    DSTstart = 20220313
    DSTend   = 20221106
    IF OpenDate >= DSTstart AND OpenDate < DSTend THEN
       USDLS=010000
    ELSE
       USDLS=0
    ENDIF

    you’ll have to change it every year.

    ullle73 thanked this post
    #194138 quote
    ullle73
    Participant
    Senior

    thanks roberto! but results on 200k 1m and 5m bars shows exactly the same results.

    #194179 quote
    robertogozzi
    Moderator
    Master

    I think you should add USDLS, instead of subtracting it.

    #194205 quote
    ullle73
    Participant
    Senior

    okay, tried to change it up in many ways, but dont understand what you mean by add instead of subtract.

    #194219 quote
    robertogozzi
    Moderator
    Master

    Instead of using “-“, I think “+” would be more apppropriate.

    #194225 quote
    ullle73
    Participant
    Senior
    // ---------   US DAY LIGHT SAVINGS MONTHS      ---------------- //
    DSTstart = 20220313
    DSTend   = 20221106
    IF OpenDate >= DSTstart AND OpenDate < DSTend THEN
       USDLS=010000
    ELSE
       USDLS=0
    ENDIF

    but there are no “-” in the code? sorry for not understanding

    #194226 quote
    robertogozzi
    Moderator
    Master

    Line 20.

    ullle73 thanked this post
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

add snippet to breakout code


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/26/2022
Status: Active
Attachments: No files
Logo Logo
Loading...