Strategy DayOpen Straddle for DAX

Viewing 15 posts - 76 through 90 (of 242 total)
  • Author
    Posts
  • #85228 quote
    GraHal
    Participant
    Master

    BUT when i backtest it today, it enters long,

    I backtested your code and it enters Short for today (top curve).

    My version (lower curve) also enters Short on both Backtest and Forward Test

    Ulle.jpg Ulle.jpg
    #85230 quote
    ullle73
    Participant
    Senior

    BUT when i backtest it today, it enters long,

    I backtested your code and it enters Short for today (top curve).

    My version (lower curve) also enters Short on both Backtest and Forward Test

    yes, but as you can see in my picture, live took short, and backtest went long, it was on FRIDAY the 16th on “sverige30 cash” (sweden30 cash).

    #85231 quote
    GraHal
    Participant
    Master

    it was on FRIDAY the 16th on “sverige30 cash” (sweden30 cash).

    Apologies … just shows how wrong one (me) can be! 🙂

    Out of interest I just changed my  TF to 5 mins (as I noticed your pics show 5 min TF) anyway on my version the short trade on Friday changed to a long trade!

    Ulle-2.jpg Ulle-2.jpg
    #85233 quote
    ullle73
    Participant
    Senior
    //-------------------------------------------------------------------------
    // Main code : Open SP500 10 NY
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    // Main Code : Straddle Dayopen V2.0
    //-------------------------------------------------------------------------
    // Test On DAX 30 Cash 10 Minute Timeframe 200k bars or from 1/1/2015
    
    // Common Rules
    Defparam Cumulateorders = False
    Defparam Preloadbars = 1000
    
    // On/off
    Extratradecriteria   = 1 // I.e. Long; Only Enters When The Current Bar High Is Lower Then The Lowest Daily High From Today, Yesterday And Day Before.
    Usepercentage        = 0 // The Minimum Difference In Percentage [[1] From Dayopen Or In Points [0] From Dayopen
    Mfetrailing          = 1 // Mfe Trailing Stop
    Wtrailing            = 1 // Williams 3 Bar Trailing Stop
    Breakevenstop        = 1 // Breakevenstop, Move Stoploss When Position Is In Profit.
    Excludefirsttwoweeks = 1 // Exclude The First 2 Weeks Of Every Year (Weeknumber 1 And 2)
    
    // Settings
    Positionsize = 1
    SL    = 0.4 // % Stoploss
    PT    = 0.7 // % Profit Target
    MFETS = 0.35 // % Mfe Trailing Stop
    BES   = 0.35 // % Break Even Stop
    BESMP = 0.05 // % Break Even Stop Minimum Profit
    WTSMP = 0.50 // % Williams Trailing Stop Minimum Profit If Mfe Trailing Stop Is Not Used
    ETD   = 0    //   Exclude a Trade Day; Sunday = 0
    If Usepercentage Then
    Nopl=((Dayopen*0.15)/100)/pointsize
    Nops=((Dayopen*0.15)/100)/pointsize
    Else
    Nopl=4 //number of points long
    Nops=4 //number of points short
    Endif
    
    // Day & Time
    Once Entertime = 153000
    Once Lasttime  = 160000
    Once Closetime = 240000 // Greater Then 23.59 Means It Continues Position Overnight
    Once Closetimefr=220000
    
    If Excludefirsttwoweeks=1 Then
    If Year=2015 And Month=1 And (Day>=1 And Day<=18) Then
    Notrading = 1
    Elsif Year=2016 And Month=1 And (Day>=1 And Day<=24) Then
    Notrading = 1
    Elsif Year=2017 And Month=1 And (Day>=1 And Day<=22) Then
    Notrading = 1
    Elsif Year=2018 And Month=1 And (Day>=1 And Day<=21) Then
    Notrading = 1
    Elsif Year=2019 And Month=1 And (Day>=1 And Day<=20) Then
    Notrading = 1
    Else
    Notrading = 0
    Endif
    Endif
    
    Tt1 = Time >= Entertime
    Tt2 = Time <= Lasttime
    Tradetime = Tt1 And Tt2 and Notrading = 0 And Dayofweek <> ETD
    
    // Reset At Start
    If Intradaybarindex = 0 Then
    Longtradecounter = 0
    Shorttradecounter = 0
    Tradecounter = 0
    Mclong = 0
    Mcshort = 0
    Endif
    
    // [pc] Position Criteria
    Pclong  = Countoflongshares < 1 And Longtradecounter < 1 And Tradecounter < 1
    Pcshort = Countofshortshares < 1 And Shorttradecounter < 1 And Tradecounter < 1
    
    // [mc] Main Criteria
    If Time = Entertime Then
    Dayopen=open
    Endif
    
    If High > Dayopen+nopl Then
    Mclong=1
    Else
    Mclong=0
    Endif
    
    If Low < Dayopen-nops Then
    Mcshort=1
    Else
    Mcshort=0
    Endif
    
    // [ec] Extra Criteria
    If Extratradecriteria Then
    Min1 = Min(Dhigh(0),dhigh(1))
    Min2 = Min(Dhigh(1),dhigh(2))
    
    Max1 = Max(Dlow(0),dlow(1))
    Max2 = Max(Dlow(1),dlow(2))
    
    Eclong = High < Min(Min1,min2)
    Ecshort = Low > Max(Max1,max2)
    else
    Eclong=1
    Ecshort=1
    Endif
    
    // Long & Short Entry
    If Tradetime Then
    If Pclong and Mclong And Eclong Then
    Buy Positionsize Contract At Market
    Longtradecounter=longtradecounter + 1
    Tradecounter=tradecounter+1
    Endif
    If Pcshort and Mcshort And Ecshort Then
    Sellshort Positionsize Contract At Market
    Shorttradecounter=shorttradecounter + 1
    Tradecounter=tradecounter+1
    Endif
    Endif
    
    // Break Even Stop
    If Breakevenstop Then
    If Not Onmarket Then
    Newsl=0
    Endif
    If Longonmarket And close-tradeprice(1)>=((Tradeprice/100)*BES)*pipsize Then
    Newsl = Tradeprice(1)+((Tradeprice/100)*BESMP)*pipsize
    Endif
    If Shortonmarket And Tradeprice(1)-close>=((Tradeprice/100)*BES)*pipsize Then
    Newsl = Tradeprice(1)-((Tradeprice/100)*BESMP)*pipsize
    Endif
    If Newsl>0 Then
    Sell At Newsl Stop
    Exitshort At Newsl Stop
    Endif
    Endif
    
    // Exit Mfe Trailing Stop
    If Mfetrailing Then
    Trailingstop = (Tradeprice/100)*MFETS
    If Not Onmarket Then
    Maxprice = 0
    Minprice = Close
    Priceexit = 0
    Endif
    If Longonmarket Then
    Maxprice = Max(Maxprice,close)
    If Maxprice-tradeprice(1)>=trailingstop*pipsize Then
    Priceexit = Maxprice-trailingstop*pipsize
    Endif
    Endif
    If Shortonmarket Then
    Minprice = Min(Minprice,close)
    If Tradeprice(1)-minprice>=trailingstop*pipsize Then
    Priceexit = Minprice+trailingstop*pipsize
    Endif
    Endif
    If Onmarket And Wtrailing=0 And Priceexit>0 Then
    Sell At Market
    Exitshort At Market
    Endif
    Endif
    
    // Exit Williams Trailing Stop
    If Wtrailing Then
    Count=1
    I=0
    J=i+1
    Tot=0
    While Count<4 Do
    Tot=tot+1
    If (Low[j]>=low[i]) And (High[j]<=high[i]) Then
    J=j+1
    Else
    Count=count+1
    I=i+1
    J=i+1
    Endif
    Wend
    
    Basso=lowest[tot](Low)
    Alto=highest[tot](High)
    
    If Close>alto[1] Then
    Ref=basso
    Endif
    If Close<basso[1] Then
    Ref=alto
    Endif
    
    If Onmarket And Mfetrailing=0 And Positionperf>WTSMP Then
    If Low[1]>ref And High<ref Then
    Sell At Market
    Endif
    If High[1]<ref And Low>ref Then
    Exitshort At Market
    Endif
    Endif
    
    If Onmarket And Mfetrailing=1 And Priceexit>0 Then
    If High<ref Then
    Sell At Market
    Endif
    If Low>ref Then
    Exitshort At Market
    Endif
    Endif
    Endif
    
    // Exit At Closetime
    If Onmarket Then
    If Time >= Closetime Then
    Sell At Market
    Exitshort At Market
    Endif
    Endif
    
    // Exit At Closetime Friday
    If Onmarket Then
    If (Currentdayofweek=5 And Time>=closetimefr) Then
    Sell At Market
    Exitshort At Market
    Endif
    Endif
    
    // Build-in Exit
    Set Stop %loss SL
    Set Target %profit PT
    
    //graph 0 Coloured(300,0,0) As "Zeroline"
    //graph (Positionperf*100)coloured(0,0,0,255) As "Positionperformance"
    

    Another error, clearly opens down, still goes long?!

    usa500.jpg usa500.jpg
    #85237 quote
    Paul
    Participant
    Master

    When the NOP value is too low, it could happen to get a buy and short on the same bar. But that’s not the case here it seems.

    To make it more clear I’ve written 2 histograms. When both are the same colour it’s a buy/short next bar at market.

    Screenshot-2018-11-19-at-22.13.54.png Screenshot-2018-11-19-at-22.13.54.png
    #85239 quote
    Paul
    Participant
    Master
    //ind_sdo [mc]
    
    // day & time
    Once entertime  = entertime
    Once lasttime   = lasttime
    
    Tt1 = time >= entertime
    Tt2 = time <= lasttime
    Tradetime = tt1 and tt2
    
    // [mc] main criteria
    Entertime=entertime
    Nopl=nopl
    Nops=nops
    
    If time = entertime then
    Dayopen=open
    Endif
    
    If tradetime and high > dayopen + nopl then
    Mclong=1
    Else
    Mclong=0
    Endif
    
    If tradetime and low < dayopen - nops then
    Mcshort=-1
    Else
    Mcshort=0
    Endif
    
    // fixed lines
    Fix1=1
    Fix2=0
    Fix3=-1
    
    Return mclong coloured(50,205,50,255) style(histogram,2) as "Eclong",mcshort coloured(255,0,0,255) style(histogram,2) as "Ecshort",fix1, fix2, fix3
    
    //ind_sdo [ec]
    
    // day & time
    Once entertime  = entertime
    Once lasttime   = lasttime
    
    Tt1 = time >= entertime
    Tt2 = time <= lasttime
    Tradetime = tt1 and tt2
    
    // [ec] extra criteria
    Min1 = min(dhigh(0),dhigh(1))
    Min2 = min(dhigh(1),dhigh(2))
    
    Max1 = max(dlow(0),dlow(1))
    Max2 = max(dlow(1),dlow(2))
    
    If tradetime and high < min(min1,min2) then
    Eclong=1
    Else
    Eclong=0
    Endif
    If tradetime and low > max(max1,max2) then
    Ecshort=-1
    Else
    Ecshort=0
    Endif
    
    // fixed lines
    Fix1=1
    Fix2=0
    Fix3=-1
    
    Return eclong coloured(50,205,50,120) style(histogram,2) as "Eclong",ecshort coloured(255,0,0,120) style(histogram,2) as "Ecshort",fix1, fix2, fix3
    
    #85240 quote
    ullle73
    Participant
    Senior

    When the NOP value is too low, it could happen to get a buy and short on the same bar. But that’s not the case here it seems.

    To make it more clear I’ve written 2 histograms. When both are the same colour it’s a buy/short next bar at market.

    okay, what could be the case for this one? Backtest gives one signal and live the other?

    #85241 quote
    ullle73
    Participant
    Senior

    and the rule is : open up and reaches x points, its ONLY long, opens down and its short?

    #85242 quote
    Paul
    Participant
    Master

    Here an example. NOP value set to 1 for the dax which is too low. But it can happen if you have a big range bar.

    Then all criteria are met, from the Main criteria and the Exra criteria. Any solutions?

    Screenshot-2018-11-19-at-23.45.14.png Screenshot-2018-11-19-at-23.45.14.png
    #85244 quote
    ullle73
    Participant
    Senior

    Here an example. NOP value set to 1 for the dax which is too low. But it can happen if you have a big range bar.

    Then all criteria are met, from the Main criteria and the Exra criteria. Any solutions?

    it does not show both long and short.

     

    But do i understand your main concept right? : open up and price goes UP x points, its a LONG. Opens down, and moves DOWN x points, its a SHORT?

    #85245 quote
    ullle73
    Participant
    Senior

    might figured it out, can it be that im displaying price on +1 central eurotime, and price when taking pos on automated strategies only goes after 0 timezone?

    #85246 quote
    Paul
    Participant
    Master

    It’s more complicated than that and hard to explain.

    If the extra criteria is disabled and use a cross over/under function in the main criteria it is. Then you can buy at the red and green  lines with a limit order.

    But now only when the main criteria and extra criteria are matched its an enter. Use the histograms which may help a bit.

    About the timezone, I add a pic of my settings.

    Screenshot-2018-11-20-at-00.38.36.png Screenshot-2018-11-20-at-00.38.36.png
    #85344 quote
    ullle73
    Participant
    Senior

    It’s more complicated than that and hard to explain.

    If the extra criteria is disabled and use a cross over/under function in the main criteria it is. Then you can buy at the red and green lines with a limit order.

    But now only when the main criteria and extra criteria are matched its an enter. Use the histograms which may help a bit.

    About the timezone, I add a pic of my settings.

    but then you dont get the gaps on lets say Dax?

    #85375 quote
    pippo999
    Participant
    Junior

    Guys, can I run two systems in real account  (nearly the same, few changes regarding take profits and range breakout) on the same Index ?

    #85382 quote
    GraHal
    Participant
    Master

    can I run two systems in real account

    Yeah sure you can I do it all the time.
    Why did you think you couldn’t?

    You may get rejections IF both Systems from the same Platform try to take the SAME trade at the same time! The Platform will then send the Order again 1 second later until it gets filled and so then both Orders have been filled.

    pippo999 thanked this post
Viewing 15 posts - 76 through 90 (of 242 total)
  • You must be logged in to reply to this topic.

Strategy DayOpen Straddle for DAX


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 241 replies,
has 39 voices, and was last updated by Monobrow
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/04/2018
Status: Active
Attachments: 100 files
Logo Logo
Loading...