Strategy DayOpen Straddle for DAX
Forums › ProRealTime English forum › ProOrder support › Strategy DayOpen Straddle for DAX
- This topic has 241 replies, 39 voices, and was last updated 3 years ago by Monobrow.
-
-
12/02/2018 at 7:42 PM #8620812/04/2018 at 4:10 PM #86312
Thank you Paul for this great strategy !
I noticed that the months of July and August are performing badly and i would like to add something in the code to exclude trading during these months, each year.
Could someone help me with writing the lines of code needed to do that ? I have tried a few things but i am not able to make it work.
Thanks !
12/04/2018 at 6:24 PM #86314Hi,
Just replace the existing part with this.
1234567891011121314151617If Excludefirsttwoweeks=1 ThenIf Year=2015 And Month=1 And (Day>=1 And Day<=18) ThenNotrading = 1Elsif Year=2016 And Month=1 And (Day>=1 And Day<=24) ThenNotrading = 1Elsif Year=2017 And Month=1 And (Day>=1 And Day<=22) ThenNotrading = 1Elsif Year=2018 And Month=1 And (Day>=1 And Day<=21) ThenNotrading = 1Elsif Year=2019 And Month=1 And (Day>=1 And Day<=20) ThenNotrading = 1Elsif month=7 or month=8 thenNotrading = 1ElseNotrading = 0EndifEndif1 user thanked author for this post.
12/04/2018 at 6:51 PM #8631503/30/2019 at 6:00 PM #9510704/01/2019 at 3:13 PM #95223I am using it for DAX and also Brent Crude 1 min since the 8th March and its working really well
04/01/2019 at 3:45 PM #95231Which code are you using for brent crude 1min? Could you please share to check?
Or just the same code implemented on 1min?
I am using 3min for DAX in demo live since last 21st march and working well. Some cancelled orders sometimes but these are demo live issues, not real live I think.
And of course thanks to Paul for the strategy!!!
04/02/2019 at 4:42 AM #9527504/02/2019 at 8:50 AM #95289I tried all the major indicies and commodities, this was before I had a system for testing so it’s not written down. From memory it worked well on euro50 and MIB but the MIB drawdowns would have been too high for me to run at present, the code I am currently using is:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245/-------------------------------------------------------------------------// Main code : DailyOpen Straddle DAX 3min//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Main code : Straddle DayOpen//-------------------------------------------------------------------------// common rulesDEFPARAM CUMULATEORDERS = falseDEFPARAM PRELOADBARS = 10000// optionalExtraTradeCriteria=1// positionsize and stopspositionsize = 1sl = 0.6 // % Stoploss 0.6pt = 0.4 // % Profit Target 0.4ts = 0.35 // % MFETrailing// indicator settignsNOP=15 //number of pointsTimeOpen=080000// day & time rulesONCE entertime = TimeOpenONCE lasttime = 100000ONCE closetime = 240000 // greater then 23.59 means it continues position overnightONCE closetimeFriday=173000tt1 = time >= entertimett2 = time <= lasttimetradetime = tt1 and tt2DayForbidden = 0 // 0=sundaydf = dayofweek <> dayforbidden// setup number of trades intradayif IntradayBarIndex = 0 thenlongtradecounter = 0Shorttradecounter = 0Tradecounter=0endif// general criteriaGeneralCriteria = tradetime and df// trade criteriatcLong = countoflongshares < 1 and longtradecounter < 1 and tradecounter <1tcShort = countofshortshares < 1 and shorttradecounter < 1 and tradecounter <1// indicator criteriaIf time = TimeOpen thenDayOpen=openendifif IntradayBarIndex = 0 thenlx=0sx=0endifif high > DayOpen+NOP thenlx=1elselx=0endifif low < DayOpen-NOP thensx=1elsesx=0endif// trade criteria extramin1 = MIN(dhigh(0),dhigh(1))min2 = MIN(dhigh(1),dhigh(2))max1 = MAX(dlow(0),dlow(1))max2 = MAX(dlow(1),dlow(2))If ExtraTradeCriteria thentcxLong = high < MIN(min1,min2)tcxShort = low > MAX(max1,max2)elsetcxLong = hightcxShort = lowendif// long entryIf GeneralCriteria thenif lx and tcLong and tcxLong thenbuy positionsize contract at marketlongtradecounter=longtradecounter + 1tradecounter=tradecounter+1endifendif// short entryIf GeneralCriteria thenif sx and tcShort and tcxShort thensellshort positionsize contract at marketshorttradecounter=shorttradecounter + 1tradecounter=tradecounter+1endifendif// MFETrailingtrailingstop = (tradeprice/100)*tsif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endifif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=trailingstop*pipsize thenpriceexit = MAXPRICE-trailingstop*pipsizeendifendifif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=trailingstop*pipsize thenpriceexit = MINPRICE+trailingstop*pipsizeendifendifIf onmarket and priceexit>0 thensell at marketexitshort at marketendif// exit at closetimeIf onmarket thenif time >= closetime thensell at marketexitshort at marketendifendif// exit friday at set closetimeif onmarket thenif (CurrentDayOfWeek=5 and time>=closetimefriday) thensell at marketexitshort at marketendifendif// build-in exitSET TARGET %PROFIT ptSET STOP %LOSS slI got mixed up and the brent strategy is actually this one https://www.prorealcode.com/prorealtime-trading-strategies/dax30-morning-breakout-order-size-increase/I modified the code to take out the variable unit sizing, code is:/-------------------------------------------------------------------------// Main code : DAX 1 min mor steigerung flat//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Main code : DAX 1 min mor steigerung//-------------------------------------------------------------------------DEFPARAM FLATBEFORE=090100// Festlegen der Code-ParameterDEFPARAM CumulateOrders = false // Kumulieren von Positionen deaktiviert// einmalige werteonce size = 2//once profi = 20once in = 1once korrek = 1sl = 40// Verhindert das Trading an bestimmten WochentagendaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0noEntryAfterTime = 100000timeEnterAfter = time < noEntryAfterTime// einen trade nurIF (CurrentTime = 010000) thenonetrade = 0ENDIF// Bedingungen zum Einstieg in Long-PositionenIF (CurrentTime = 085900) thenhigh7 = HIGHEST[120](high)low7 = LOWEST[120](low)ENDIFIF (close > high7) AND (CurrentTime >= 090100) thenonetrade = 2ENDIFIF (CurrentTime >= 090100) AND not daysForbiddenEntry AND (onetrade = 0) AND timeEnterAfter THENBUY size CONTRACT AT high7 STOPENDIFIF (LONGONMARKET = 1) thenonetrade = 2in = 1korrek = 0//l1 = POSITIONPRICE + 0.0008l2 = POSITIONPRICE - sl//sell at l1 LIMITsell at l2 stopENDIF// Bedingungen zum Einstieg in Short-PositionenIF close < low7 AND (CurrentTime >= 090100) thenonetrade = 1ENDIFIF (CurrentTime >= 090100) AND not daysForbiddenEntry AND (onetrade = 0) AND timeEnterAfter THENSELLSHORT size CONTRACT AT low7 STOPENDIFIF (SHORTONMARKET = 1) thenonetrade = 2in = 1korrek = 0//s1 = POSITIONPRICE - 0.0008s2 = POSITIONPRICE + sl//EXITSHORT at s1 LIMITEXITSHORT at s2 STOPENDIF// korrekturIF (LONGONMARKET < 1) AND (SHORTONMARKET < 1) thenin = 0ENDIFIF in = 0 and korrek = 0 thend1 = POSITIONPERF(1) > 0d2 = POSITIONPERF(1) < 0IF d1 and size > 1 thensize = size - 1korrek = 1ELSIF d2 thensize = 2korrek = 1ENDIFENDIF// Stops und TargetsSET STOP pLOSS 30SET TARGET pPROFIT sl//// Performance//IF STRATEGYPROFIT > profi then//size = 1//profi = profi + 20//ENDIF04/02/2019 at 1:49 PM #95330Ruark Baker – please use the ‘Insert PRT Code’ button when posting code in any future posts as it makes it far easier for others to read. I have tidied up your post for you. 🙂
04/03/2019 at 4:12 PM #95422Hello Paul,
Great Idea with the code and thanks for sharing.
I had a little time to look into your code.
I might have spotted a mistake for your MFE Trailing Stop calculationtradeprice(1) – maxprice > trailingstop instead of maxprice – tradeprice(1)
You want to start trailing from the moment you have a certain profit level if I am correct.12345If Longonmarket ThenMaxprice = Max(Maxprice,close)If tradeprice(1)-maxprice>=trailingstop*pipsize ThenPriceexit = Maxprice-trailingstop*pipsizeEndifFurthermore I dont know what the Williams Trailing is doing. Maybe I just dont understand it.
But it seems to make no difference whether it is activated or not.Kind regards
1 user thanked author for this post.
04/03/2019 at 6:13 PM #95430@O-jay8 Thanks for the critical look. I’ve no idea where you found that, but you are correct.
The goal of the wbar 3 trailing stop was not to use an optimized profittarget and a minimal loss of maximum profits.
This doesn’t have an effect if you use a short timeframe like 1 minute. But i.e. 3 minute it makes a difference.
It’s not huge, but just a bit better exit points.
downside with a default trailing stop is that you may surrender some nice points, but upside is you can get bigger profits.
upside with a williams 3 bar trailing stop is that get you out of a trade at a fairly good price….at the time, but downside here is you can miss out on bigger profits.
While it’s a williams 3 bar trailing stop, testing it to 4 or 5 can be usefull.
https://www.prorealcode.com/prorealtime-indicators/williams-3-bar-trailing-stop/
Just add the indicator to the price-chart.
1 user thanked author for this post.
05/11/2019 at 1:47 PM #9823405/11/2019 at 4:05 PM #98241Yes at the moment doesn’t work good enough! Volatility is a different angle, I will give it a look.
Few things to consider;
- higher chance that it doesn’t work if there’s daily gap because of zigzag at opening (and days after)
- holiday 1 mei tag der arbeid in Germany (volatility), check the holidays and perhaps prevent trading.
- exit-time 173000 or 223000 on Friday can make a difference. As always the biggest difference is in the most recent day!
- main criteria uses > instead of crossover, there’s a potential of conflict. That long and short criteria are true at the same time. I use a workaround because I want to use it as is.
- got criteria which prevent entering the market on new high or low in opposite or same direction.
- In ways to prevent losing 1% (my stoplos which I don’t optimise on a short timeframe) I’am trying to prevent losing that number
- when in a position and it breaks previous days dhigh/dlow to close position and not to go on hope. Basically cut losses short but without exiting too much. But there’s more to it then this but that’s the idea.
- the concept to enter a second position when performance < -0.20% and use trailing stop on 2nd better position to close both and maintaining stoploss of 1st position. But there’re a few cave-cats so binned that idea for now.
- (but look at Friday when exiting at 22.30. If you had bought with -0.20% and exited on TS on first or second position it would’ve been interesting again)
All in all, it shows that you should be running more strategy’s at the same time !
But the concept to enter the market in the first hour remains good.
1 user thanked author for this post.
06/17/2019 at 2:59 PM #100887The Williams trailing stop doesn’t work because there are a couple of errors:
- Positionperf is quoted with 4 decimals (0.0050), while WTSMP is set to 0.50 (must be 0.0050)
-
12If Onmarket and Mfetrailing=0 and Positionperf>WTSMP thenIf Low[1]>ref[1] and High<ref then
ref[1] because the last 2 candles must be one above and the other below the signal line “ref” in that moment.
With these corrections the Williams ts seem to work a little better than the MFE ts
-
AuthorPosts
Find exclusive trading pro-tools on