BB Trading one Long one Short on DAX 9-17,30

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #236385 quote
    Lambo
    Participant
    New

    Hello,

    i have build a programm which poorly didn’t work. Can someone help me?

    It didn’t accept the filters from day before

    It do more than one Trade in one direction

     

     

    I use the Dax Future 9-1730

    a) for the Filter of day candle

    b) for creat the 5 minut BB

    c) for Backtesting i take the one minute Chart and 1.000.000 candles

    Here is the code with the explain of filter, stop etc.

    Thank you very much

    defparam preloadbars=5000
    defparam cumulateorders=false
    size=(100000+strategyprofit)/(close)*3

     

    //Trading Time for start
    if time=>090000 and Time<124000 THEN
    t=1
    ELSE
    t=0
    ENDIF
    //Parameter from Yesterday for Starting Conditions
    Timeframe(daily)
    //Range >0,6%
    c101=(high-low)/close*100>0.6

    //Strong Cande with body of a minimum of 50%
    if open>close then
    c102=(open-close)/(high-low)>0.5
    else
    c102=(close-open)/(high-low)>0.5
    endif

    //Use BB of 5 Min Chart
    timeframe(5 minutes,updateonclose)
    Bolld=ExponentialAverage[21](open)-2*std[21](open)
    Bollu=ExponentialAverage[21](open)+2*std[21](open)

    // Only on Long Trade and one Short Trade a day
    timeframe (5 minute)

    c1=(high[0]> BOLLU)
    c2=(low[0]< BOLLD)
    MaxTrades = 1
    IF IntraDayBarIndex = 0 THEN
    LongTally = 0
    ShortTally = 0
    Endif

    if not SHORTONMARKET and c1 and t=1 and ShortTally<Maxtrades then
    SELLSHORT size contracts at market
    ShortTally = ShortTally + 1
    ENDIF

    //Close Position on 1730 when not SL or TP
    if SHORTONMARKET and close<Average[21] or time>173000 THEN
    EXITSHORT at market
    ENDIF

    //Stop Conditions
    if shortonmarket THEN
    SET STOP LOSS AverageTrueRange[5](close)*2.0
    ENDIF

    if not longONMARKET and c2 and t=1 and LongTally<MaxTrades THEN
    buy size contracts roundedup AT MARKET
    LongTally = LongTally + 1
    ENDIF

     

    if longonmarket THEN
    SET STOP LOSS -AverageTrueRange[5](close)*2.0
    ENDIF

    if LONGONMARKET and close>Average[21] or time>173000 THEN
    sell AT MARKET
    ENDIF

    #236386 quote
    Lambo
    Participant
    New
    defparam preloadbars=5000
    defparam cumulateorders=false
    size=(100000+strategyprofit)/(close)*3
    
     
    
    //Trading Time for start
    if time=>090000 and Time<124000 THEN
    t=1
    ELSE
    t=0
    ENDIF
    //Parameter from Yesterday for Starting Conditions
    Timeframe(daily)
    //Range >0,6%
    c101=(high-low)/close*100>0.6
    
    //Strong Cande with body of a minimum of 50%
    if open>close then
    c102=(open-close)/(high-low)>0.5
    else
    c102=(close-open)/(high-low)>0.5
    endif
    
    //Use BB of 5 Min Chart
    timeframe(5 minutes,updateonclose)
    Bolld=ExponentialAverage[21](open)-2*std[21](open)
    Bollu=ExponentialAverage[21](open)+2*std[21](open)
    
    // Only on Long Trade and one Short Trade a day
    timeframe (5 minute)
    
    c1=(high[0]> BOLLU)
    c2=(low[0]< BOLLD)
    MaxTrades = 1
    IF IntraDayBarIndex = 0 THEN
    LongTally = 0
    ShortTally = 0
    Endif
    
    if not SHORTONMARKET and c1 and t=1 and ShortTally<Maxtrades then
    SELLSHORT size contracts at market
    ShortTally = ShortTally + 1
    ENDIF
    
    //Close Position on 1730 when not SL or TP
    if SHORTONMARKET and close<Average[21] or time>173000 THEN
    EXITSHORT at market
    ENDIF
    
    //Stop Conditions
    if shortonmarket THEN
    SET STOP LOSS AverageTrueRange[5](close)*2.0
    ENDIF
    
    if not longONMARKET and c2 and t=1 and LongTally<MaxTrades THEN
    buy size contracts roundedup AT MARKET
    LongTally = LongTally + 1
    ENDIF
    
     
    
    if longonmarket THEN
    SET STOP LOSS -AverageTrueRange[5](close)*2.0
    ENDIF
    
    if LONGONMARKET and close>Average[21] or time>173000 THEN
    sell AT MARKET
    ENDIF
    #236397 quote
    Iván González
    Moderator
    Master

    Hello!
    I’ve slightly modified the code while keeping most of your original proposal. Now the system only makes one trade in each direction per day at most. Here is the code:

    defparam preloadbars=5000
    defparam cumulateorders=false
    size=(100000+strategyprofit)/(close)*3
    
    //Trading Time for start
    if time=>090000 and Time<124000 THEN
    t=1
    ELSE
    t=0
    ENDIF
    //Parameter from Yesterday for Starting Conditions
    Timeframe(daily)
    //Range >0,6%
    c101=(high-low)/close*100>0.6
    //Strong Cande with body of a minimum of 50%
    if open>close then
    c102=(open-close)/(high-low)>0.5
    else
    c102=(close-open)/(high-low)>0.5
    endif
    dailyfilter=c101 and c102
    //Use BB of 5 Min Chart
    timeframe(5 minutes,updateonclose)
    Bolld=ExponentialAverage[21](open)-2*std[21](open)
    Bollu=ExponentialAverage[21](open)+2*std[21](open)
    // Only on Long Trade and one Short Trade a day
    timeframe (5 minute)
    c1=(high[0]> BOLLU)
    c2=(low[0]< BOLLD)
    
    timeframe(default)
    MaxTrades = 1
    IF IntraDayBarIndex = 0 THEN
    LongTally = 0
    ShortTally = 0
    Endif
    
    if not SHORTONMARKET and c1 and dailyfilter and t=1 and ShortTally<Maxtrades then
    SELLSHORT size contracts at market
    ShortTally = ShortTally + 1
    ENDIF
    
    if SHORTONMARKET then
    //Stop Conditions
    SET STOP LOSS AverageTrueRange[5](close)*2.0
    //Close Position on 1730 when not SL or TP
    if close<Average[21] or time>173000 THEN
    EXITSHORT at market
    ENDIF
    endif
    
    if not longONMARKET and c2 and dailyfilter and t=1 and LongTally<MaxTrades THEN
    buy size contracts roundedup AT MARKET
    LongTally = LongTally + 1
    ENDIF
    
    if longonmarket THEN
    SET STOP LOSS -AverageTrueRange[5](close)*2.0
    if close>Average[21] or time>173000 THEN
    sell AT MARKET
    ENDIF
    ENDIF
    
    //graph LongTally coloured("green")
    //graph ShortTally coloured("red")
    
    Lambo thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

BB Trading one Long one Short on DAX 9-17,30


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Lambo @lambo Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Iván González
1 year, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/14/2024
Status: Active
Attachments: No files
Logo Logo
Loading...