Scalping EURUSD
Forums › ProRealTime English forum › ProOrder support › Scalping EURUSD
- This topic has 32 replies, 7 voices, and was last updated 7 years ago by Ronny.
-
-
04/11/2017 at 11:56 AM #31707
I have been reading about mean reverting strategies for intra days and in one article I red the author claimed that it’s actually easier to do it in the second half of the day when the movements are a bit smoother. To test this I made a simple bollinger band strategy and the result looks nice, but does anyone know if this is actually can perform on a longer period of time? I have only optimised the stop loss. Everything else is untouched.
1234567891011121314151617181920212223242526272829303132333435363738394041424344Defparam Cumulateorders = falsen = 1Starttime = 100000Endtime = 220000// Indicatorsblow = Bollingerdown[20]bhigh = Bollingerup[20]MA1 = Average[8]MA2 = Average[200]// LONGcb1 = (low < blow and close < blow)cb2 = (MA1 > MA2)cb3 = (currenttime > Starttime and currenttime < Endtime)IF NOT Longonmarket and cb1 and cb2 and cb3 THENBUY n SHARES AT MARKETENDIFcb4 = high > bhigh and close > bhighIF cb4 Thensell n shares at marketendif// SHORTcs1 = (high > bhigh and close > bhigh)cs2 = (MA1 < MA2)cs3 = (currenttime > Starttime and currenttime < Endtime)IF NOT Shortonmarket and cs1 and cs2 and cs3 THENSELLSHORT n SHARES AT MARKETENDIFcs4 = low < blow and close < blowIF cs4 ThenExitshort n shares at marketendifSET STOP pLOSS 5004/11/2017 at 12:22 PM #31715BTW – I have backtested with 0.6 pip spread.
04/11/2017 at 1:50 PM #3171904/11/2017 at 1:55 PM #31722Hi Eric!
I’ve done the same. You can also change the exit conditions to only include the “close”. Including the other command makes no difference to the result.
04/24/2017 at 11:00 AM #33156Here is a quick version for USDJPY (5min) spread 0.8. I have not worked on optimisation yet. I hav added the ADX indicator.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647Defparam Cumulateorders = falseStarttime = 100000Endtime = 240000// Indicatorsblow = Bollingerdown[20]bhigh = Bollingerup[20]MA1 = Average[8]MA2 = Average[200]ad = adx[21]adlevel = 23// LONGcb1 = (low < blow and close < blow)cb2 = (MA1 > MA2)cb3 = (currenttime > Starttime and currenttime < Endtime)cb4 = (ad > adlevel)IF NOT Longonmarket and cb1 and cb2 and cb3 and cb4 THENBUY 1 CONTRACT AT MARKETENDIFcb8 = close > bhighcb9 = LONGONMARKET AND DAYOFWEEK=5 AND TIME>=235000IF cb8 OR cb9 Thensell at marketendif// SHORTcs1 = (high > bhigh and close > bhigh)cs2 = (MA1 < MA2)cs3 = (currenttime > Starttime and currenttime < Endtime)cs4 = (ad > adlevel)IF NOT Shortonmarket and cs1 and cs2 and cs3 and cs4 THENSELLSHORT 1 CONTRACT AT MARKETENDIFcs8 = close < blowcs9 = SHORTONMARKET AND DAYOFWEEK=5 AND TIME>=235000IF cs8 OR cs9 ThenExitshort at marketendifSET STOP pLOSS 701 user thanked author for this post.
04/24/2017 at 1:03 PM #33181Here is an updated version on the EURUSD. The major improvement is with focus on a lower draw down.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748Defparam Cumulateorders = falseStarttime = 100000Endtime = 240000// Indicatorsblow = Bollingerdown[20]bhigh = Bollingerup[20]MA1 = Average[8]MA2 = Average[200]ad = adx[24]adlevel = 14// LONGcb1 = (low < blow and close < blow)cb2 = (MA1 > MA2)cb3 = (currenttime > Starttime and currenttime < Endtime)cb4 = (ad > adlevel)IF NOT Longonmarket and cb1 and cb2 and cb3 and cb4 THENBUY 1 CONTRACT AT MARKETENDIFcb8 = close > bhighcb9 = LONGONMARKET AND DAYOFWEEK=5 AND TIME>=230000IF cb8 OR cb9 Thensell at marketendif// SHORTcs1 = (high > bhigh and close > bhigh)cs2 = (MA1 < MA2)cs3 = (currenttime > Starttime and currenttime < Endtime)cs4 = (ad > adlevel)IF NOT Shortonmarket and cs1 and cs2 and cs3 and cs4 THENSELLSHORT 1 CONTRACT AT MARKETENDIFcs8 = close < blowcs9 = SHORTONMARKET AND DAYOFWEEK=5 AND TIME>=230000IF cs8 OR cs9 ThenExitshort at marketendifSET STOP pLOSS 5004/24/2017 at 6:44 PM #33232Just a quick run.- It Looks like if only going short on the udsjpy ver- it gets better statistic. Long only provide 1.5%
Cheers Kasper
04/25/2017 at 7:45 AM #33277Hi Kasper!
Where do you find the 1,5% gain? In my backtest (100 000 bars) I have the split 53,86%/87,5% between Long/short.
1,5% would make sense on a 100 000 bars backtest because only about 3 months are positive trend, the rest is negative.
04/25/2017 at 8:41 AM #33283Hi Victor- I might be wrong- I will check again when home 🙂
04/25/2017 at 5:04 PM #33354Hi guys,
I like this one so if you don’t mind me contributing, I’ve made some modifications and thought I’d share.
- Logic optimization: The system is quite slow over many bars so I’ve made some logic optimizations to have it perform a bit faster. It makes a considerable difference during optimization. It could be further optimized, but keeping it as readable as possible for now.
- As people from all over might be working on this I’ve introduced a GMT timezone offset variable so that you can keep the same times and just change it to +1 (if in the EU) or have fun with it. It’s a clean way to shift trading time constrains forward of back with 1 number
- Stop loss selection framework – currently I’ve just got 2 options there: a static stop loss or (the one selected currently) a ATR based dynamic stop loss. This seems to perform better on USD/JPY – haven’t tested any more yet.
- Variable optimization selection framework so you can keep the same code base and dump different variable sets. (I haven’t optimized all the variables yet)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102// ADX-Bollinger Mean Reversion v 1.12// Version 0.22//DEFPARAM cumulateOrders = falseDEFPARAM preloadBars = 300once positionSize = 1once GMTOffset = 0 // Your time zone reletive to +/- GMT (in hours) 1=gmt | 2=cetonce optimization = 1// -- Optimizations selection --if optimization = 1 then // USD_JPY :: M5 (Jan 2016- Apr 2017)startTime = 090000 // 100000endTime = 230000 // 240000fridayEndTime = 225000 //bolUpPeriod = 20bolDnPeriod = 20maShrtPeriod = 8maLongPeriod = 200adxPeriod = 21adxThreshold = 22stopLossMode = 2 // 1: Static | 2: DynamicstopLoss = 70 // For Static stopslATRmultiple = 6 // For Dynamic stopelsif optimization = 2 then// Add your optimizations here// elsif optimization = 3 then // ... and so onendif// -- Time zone adjustments --startTime = startTime + ( GMTOffset * 10000 )endTime = endTime + ( GMTOffset * 10000 )fridayEndTime = fridayEndTime + ( GMTOffset * 10000 )// -- Indicators -----bLow = BollingerDown[bolUpPeriod]bHigh = BollingerUp[bolDnPeriod]MA1 = average[maShrtPeriod]MA2 = average[maLongPeriod]ad = adx[adxPeriod]atr = averageTrueRange[40]// -- Entry conditions -----// -- Common Conditions (for both long and short) --isTradingTime = (currenttime > startTime and currenttime < endTime)atADXLevel = (ad > adxThreshold)isLateFriday = (dayOfWeek = 5 and time >= fridayEndTime)if isTradingTime and atADXLevel then// -- long conditions only --bc1 = not longOnMarket //and isTradingTime and atADXLevelbc1 = bc1 and (max(low, close) < bLow) //(low < bLow and close < bLow)bc1 = bc1 and (MA1 > MA2) //and (MA2 > MA2[1])// -- Short conditions only --sc1 = not shortOnMarket //and isTradingTime and atADXLevelsc1 = sc1 and (min(high, close) > bHigh) //(high > bHigh and close > bHigh)sc1 = sc1 and (MA1 < MA2) //and (MA2 < MA2[1])elsebc1 = 0sc1 = 0endifif onMarket then// -- Long EXIT conditions only --le1 = longOnMarket and ( (close > bHigh) or isLateFriday )// -- Short EXIT conditions only --se1 = shortOnMarket and ( (close < bLow) or isLateFriday )elsele1 = 0se1 = 0endif// -- Execution Handlers -----if bc1 thenbuy positionSize contract at marketelsif sc1 thensellShort positionSize contract at marketelsif le1 thensell at marketelsif se1 thenexitshort at marketendifif stopLossMode = 1 then // static stop lossSET STOP pLOSS stopLosselsif stopLossMode = 2 then // dynamic ATR based stop lossSET STOP pLOSS (atr * slATRmultiple)elsif stopLossMode = 3 then // Time based stop// - na -elsif stopLossMode = 4 then // trailing stop// - na -endifHope this helps. Any questions about what I did, let me know. Cheers @ victormork, good work.
5 users thanked author for this post.
04/25/2017 at 5:06 PM #333581234567<span class="token comment" spellcheck="true">// * Correction on the versioning and on the GMT offset thing// ADX-Bollinger Mean Reversion v 0.22</span><span class="token comment" spellcheck="true">// Version 0.22</span><span class="token comment" spellcheck="true">// </span><span class="token keyword">once</span> GMTOffset <span class="token operator">=</span> <span class="token number">0</span> <span class="token comment" spellcheck="true">// Your time zone reletive to +/- GMT (in hours) 0=GMT | 1=CET</span>04/25/2017 at 5:25 PM #33365Hi Victor, I still get the same result on 100000 unit- However I had a 0 more in the initial capital- but it still off your results- what timezone are you in?
1 user thanked author for this post.
04/25/2017 at 5:27 PM #3336904/25/2017 at 7:16 PM #33381Hi Maz- I don’t get our result at all? 🙁
If I am correct you are 1 hour behind me(?) I’m at +1 GMT
here is my results from your ITF file.
what could be wrong?
Cheers Kasper
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105// ADX-Bollinger Mean Reversion v 1.12// Version 0.22//DEFPARAM cumulateOrders = falseDEFPARAM preloadBars = 300once positionSize = 1once GMTOffset = 1 // Your time zone reletive to +/- GMT (in hours) 1=gmt | 2=cetonce optimization = 1// -- Optimizations selection --if optimization = 1 then // USD_JPY :: M5 (Jan 2016- Apr 2017)startTime = 090000 // 100000endTime = 230000 // 240000fridayEndTime = 225000 // 235000//startTime = 100000//endTime = 240000//fridayEndTime = 235000bolUpPeriod = 20bolDnPeriod = 20maShrtPeriod = 8maLongPeriod = 200adxPeriod = 21adxThreshold = 22stopLossMode = 2 // 1: Static | 2: DynamicstopLoss = 70 // For Static stopslATRmultiple = 6 // For Dynamic stopelsif optimization = 2 then// Add your optimizations here// elsif optimization = 3 then // ... and so onendif// -- Time zone adjustments --startTime = startTime + ( GMTOffset * 10000 )endTime = endTime + ( GMTOffset * 10000 )fridayEndTime = fridayEndTime + ( GMTOffset * 10000 )// -- Indicators -----bLow = BollingerDown[bolUpPeriod]bHigh = BollingerUp[bolDnPeriod]MA1 = average[maShrtPeriod]MA2 = average[maLongPeriod]ad = adx[adxPeriod]atr = averageTrueRange[40]// -- Entry conditions -----// -- Common Conditions (for both long and short) --isTradingTime = (currenttime > startTime and currenttime < endTime)atADXLevel = (ad > adxThreshold)isLateFriday = (dayOfWeek = 5 and time >= fridayEndTime)if isTradingTime and atADXLevel then// -- long conditions only --bc1 = not longOnMarket //and isTradingTime and atADXLevelbc1 = bc1 and (max(low, close) < bLow) //(low < bLow and close < bLow)bc1 = bc1 and (MA1 > MA2) //and (MA2 > MA2[1])// -- Short conditions only --sc1 = not shortOnMarket //and isTradingTime and atADXLevelsc1 = sc1 and (min(high, close) > bHigh) //(high > bHigh and close > bHigh)sc1 = sc1 and (MA1 < MA2) //and (MA2 < MA2[1])elsebc1 = 0sc1 = 0endifif onMarket then// -- Long EXIT conditions only --le1 = longOnMarket and ( (close > bHigh) or isLateFriday )// -- Short EXIT conditions only --se1 = shortOnMarket and ( (close < bLow) or isLateFriday )elsele1 = 0se1 = 0endif// -- Execution Handlers -----if bc1 thenbuy positionSize contract at marketelsif sc1 thensellShort positionSize contract at marketelsif le1 thensell at marketelsif se1 thenexitshort at marketendifif stopLossMode = 1 then // static stop lossSET STOP pLOSS stopLosselsif stopLossMode = 2 then // dynamic ATR based stop lossSET STOP pLOSS (atr * slATRmultiple)elsif stopLossMode = 3 then // Time based stop// - na -elsif stopLossMode = 4 then // trailing stop// - na -endif04/25/2017 at 7:53 PM #33392Not sure, Kasper. I have tried playing with the time zones and here are 3 different results attached. I see from the screen shot your results are displayed in Yen? Not sure what data feed or vehicle to market you are using or if that has something to do with it? I’m sure it’s something simple.
-
AuthorPosts