Momentum-Range Differential Acceleration System
Forums › ProRealTime English forum › ProOrder support › Momentum-Range Differential Acceleration System
- This topic has 51 replies, 13 voices, and was last updated 6 years ago by victormork.
-
-
04/22/2017 at 9:15 PM #32994
Sorry ALE I have only 100 000 bars and it was very very long only with 3 variables
In fact I think you should WF on how many bars you want to use the code with an optimisation
For example if you want to keep the same optimisation every week 34*5=170 bars
If you test on 5 periods 5*170 is quite enough I think
Cheers
04/24/2017 at 2:43 PM #33188Hi. Has anyone tried this on a commodity? I’m trying it out on Mini Crude Oil and can’t get it to work. I’ve been trying to optimise all morning however getting nowhere. The code is working but think I’m not looking at the right range for the variables so that the best optimisation results are from o trades for 0% gain (the rest of the results are negative). I think it could be due to the different point size than for fx.
In particular, can anyone suggest variables for mcThreshold and rcThreshold? I’ve literally spent hours optimising various numbers but not getting anywhere.
I’m sure it’s a beginners error to do with adjusting for different point sizes. Any help appreciated.
Thanks04/24/2017 at 5:56 PM #33224Issues like you experienced jonjon are partly why I suggest in post #32898 that we leave in the numbers for the variable sets when we attach an .itf file.
The other reason is that unless we can see the range of variables used by an optimiser submitting code and re-optimise a few ourselves then how can we have confidence in the values?
I’m sure we have all re-optimised Systems submitted on the various Threads and in the Library and found variable values that give better results?
Leaving the variable sets / range in the file makes it easier to do a confidence check?
GraHal
1 user thanked author for this post.
04/25/2017 at 8:08 AM #332811In system 2, why is the mcThreshold and rcThreshold defined twice? I have taken one set out on the code I'm testing now.04/25/2017 at 9:26 AM #33290Hi guys,
Understanding the code (indicators) before you optimize
Before dumping the code base on a new asset class, you need to fully understand the code, how it’s working and what it does. Pull it apart. Make custom indicators from the indicator section. See how they work graphically on different instruments. This way it will make more sense as to what ranges you need to try.Where to start optimizing for a new asset
Think about price action characteristics on the asset the system works well on – ATR, volatility, etc. Think about how that relates to the asset you want to move onto trying. For example if the new asset is less volatile, you’ll want to try variable ranges that make sense to reflect that. In this case smaller = less volatile.Not a one-size-fits-all
Although the premise is market-agnostic, that PRT code I posted in the library is not a one-size-fits-all. Different asset classes will need different filters so you need to do the research. If you look at the filters I’ve used for the example (EUR/USD) you’ll see they may not make sense out of the box for stocks or for commodities due to the way stocks and commodities move. By filters I mean reasons NOT to take a (potentially weak) setup.3 users thanked author for this post.
04/25/2017 at 9:31 AM #33291I have done a stress test and optimisation on DOW 1E 3p spread with 100 000 bar history and below is the result. I have also tried trailing stop, profit target and Donchian stop and they all give more or less the same result. If anyone have other suggestions on what I could try, please let me know!
Btw, there are a few things I don’t understand when I’m testing this code (keep in mind I’m a beginner).
The code have several commands for exit a trade: wintarget+trailing stop+mintradetime+MA long criteria. Will the system takes whatever happens first? I have tried to take some away and test each exit separately but with a poorer result. There are for example profits above the win target plus trades close before the mintradetime. Can anyone explain the reason for this?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899// ====================================== \\// DOW E1 Contract, TF 1H, Spread: 3p// -------------------------------------- //// Static Optimization for DOW E1 Contract 1 hour// Jan 2013 - April 2017// Spread 3 pointswintarget = 42 // Clip target to maximum of x pointsminTradeTime = 16 // stay in trade for at least x barsmcShortPeriod = 4 // Short period momentumrcShortPeriod = 3 // Short period average rangemcLongPeriod = 100 // Long period momentumrcLongPeriod = 80 // Long period average rangemcThreshold = 0.25 // 0.5 // Momentum coefficient thresholdrcThreshold = 0.5 // 1 // Range coefficient thresholdmaShortPeriod = 5 // Short term moving averagemaLongPeriod = 3 // Long term moving average// ====================================== \\// :: Indicators --// -------------------------------------- //// Momentum Coefficient and Range Coefficient ============= \\if barIndex >= max(mcLongPeriod, rcLongPeriod) thenmShort = momentum[mcShortPeriod]mLong = momentum[mcLongPeriod]mc = max(0, (abs(mShort) / abs(mLong)) -1)r = abs(range)arLong = average[max(1, rcLongPeriod)](r)arShort = average[max(1, rcShortPeriod)](r)rc = max(0, (arShort / arLong) -1)//rc = max(0, arShort - arLong)endif// ----------------------------------- //// General Indicators ================= \\upBar = close > openmaShort = exponentialAverage[maShortPeriod](Close)maLong = exponentialAverage[maLongPeriod](Close)// ----------------------------------- //// ====================================== \\// :: Entry Logic// -------------------------------------- //// long entry rules (buy condition)bc1 = not longOnMarketbc1 = bc1 and (mc >= mcThreshold)bc1 = bc1 and (rc >= rcThreshold)bc1 = bc1 and upBarbc1 = bc1 and maShort > maShort[1]// long exit rules (exit long conditions)le1 = longOnMarketle1 = le1 and ( barIndex >= barIndexAtBuy + minTradeTime)le1 = le1 and (maLong < maLong[4])// ====================================== \\// :: Execution Handlers// -------------------------------------- //if bc1 thenbuy 1 shares at marketset target pprofit wintargetbarIndexAtBuy = barIndexendifif le1 and longOnMarket thensell at marketendifSET STOP pLOSS 70//trailing stoptrailingstop = 25//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0priceexit = 0endif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenSELL AT priceexit STOPendif04/25/2017 at 10:53 AM #33300Thanks @Maz. A logical approach to finding the ranges. An obvious solution but I needed it pointing out!
I’ve created new indicators from Maz’s code which I’ve added to my charts to help and I put the code below as it may be of help to some. I’m already seeing that this should hopefully help me with my Oil query and I’ll let you know any positive results.
123456789// Momentum Coefficient ============= \\mcShortPeriod = 5mcLongPeriod = 20mShort = momentum[mcShortPeriod]mLong = momentum[mcLongPeriod]mc = max(0, (abs(mShort) / abs(mLong)) -1)Return mc12345678910// Range Coefficient ============= \\rcShortPeriod = 5rcLongPeriod = 20r = abs(range)arLong = average[max(1, rcLongPeriod)](r)arShort = average[max(1, rcShortPeriod)](r)rc = max(0, (arShort / arLong) -1)Return r as "Range", rc04/25/2017 at 11:05 AM #33301Just realised that my last post with the indicators is just a repitition of Maz’s first post and link to his indicator (which was done better than mine above).
Maz’s indicator can be found here
04/30/2017 at 11:07 AM #34015Hi MAZ, what version of PRT are you using? the IG or the Premium ver from PRT?
I still cannot get the DIFF system to generate any trades- So I might think there could be a difference in the compilers. I use the IG ver.
Cheers Kasper
04/30/2017 at 11:35 AM #34017Hi Again.
I did some troubleshooting- forked the bc1 into 5 indicators.
What I could see is
12bc2 = (mc >= mcThreshold)bc3= (rc >= rcThreshold)is never gonna be true until I *pipsize the Thresholds.
It looks like this. Question is why do some get trades, and some don’t?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122// ====================================== \// :: MDif-RDif// Long Name : Momentum Differential and Range Differential Accelleration// Version : v1.11// Author : Maz @ prorealcode.com// Date : 07-04-2017// Contact : prtmaz at gmail dot com// -------------------------------------- //// ====================================== \// :: Optimizations --// -------------------------------------- //once optimization = 1 // 1 = EUR/USD M15// Set to 0 for re-optimization and walk-forwardif optimization = 1 then// Static Optimization for EUR/USD M15// May 2015 - April 2017wintarget = 43 // Clip target to maximum of x pointsminTradeTime = 43 // stay in trade for at least x bars// try also 27mcShortPeriod = 5 // Short period momentumrcShortPeriod = 4 // Short period average rangemcLongPeriod = 100 // Long period momentumrcLongPeriod = 100 // Long period average rangemcThreshold = 2*pipsize // Momentum coefficient thresholdrcThreshold = 8.5*pipsize // Range coefficient thresholdmaShortPeriod = 18 // Short term moving averagemaLongPeriod = 53 // Long term moving average// ( try also 150 / or 53 for 70% hit rate / or 51elsif optimization = 2 then// Insert your optimizations here// wintarget = 43 // Clip target to maximum of x points// minTradeTime = 43 // stay in trade for at least x bars// ...wintarget = 43 // Clip target to maximum of x pointsminTradeTime = 43 // stay in trade for at least x barsmcShortPeriod = 5 // Short period momentumrcShortPeriod = 4 // Short period average rangemcLongPeriod = 100 // Long period momentumrcLongPeriod = 100 // Long period average rangemcThreshold = 0.1*pipsize // Momentum coef or dif thresholdrcThreshold = 0.9*pipsize // Range coef or dif thresholdmaShortPeriod = 18 // Short term moving averagemaLongPeriod = 53 // Long term moving averageendif// ====================================== \// :: Indicators --// xr = max(0, xr) // hide values below zero// -------------------------------------- //// Momentum Differential ============= \mShort = momentum[mcShortPeriod]mLong = momentum[mcLongPeriod]mc = max(abs(mShort) - abs(mLong), 0)// ----------------------------------- //// Range Differential ================= \r = abs(range)arLong = average[max(1, rcLongPeriod)](r)arShort = average[max(1, rcShortPeriod)](r)rc = max(0, arShort - arLong)// ----------------------------------- //// General Indicators ================= \upBar = close > openmaShort = exponentialAverage[maShortPeriod](Close)maLong = exponentialAverage[maLongPeriod](Close)// ----------------------------------- //// ====================================== \// :: Entry Logic// -------------------------------------- //// long entry rules (buy condition)bc1 = not longOnMarketbc2 = (mc >= mcThreshold)bc3= (rc >= rcThreshold)bc4 = upBarbc5 = maShort > maShort[1]// long exit rules (exit long conditions)le1 = longOnMarketle1 = le1 and ( barIndex >= barIndexAtBuy + minTradeTime )le1 = le1 and (maLong < maLong[4])// short entry rule// -- na --// short exit rules// -- na --// ====================================== \// :: Execution Handlers// -------------------------------------- //if bc1 and bc2 and bc4 and bc3 and bc5 thenbuy 1 shares at marketset target pprofit wintargetbarIndexAtBuy = barIndexendifif le1 and longOnMarket thensell at marketendif//graph mc COLOURED(255,0,0) AS "mc"//black//graph mcThreshold COLOURED(0,255,0) AS "mcThreshold"//blackgraph rc COLOURED(255,0,0) AS "rc"//blackgraph rcThreshold COLOURED(0,255,0) AS "rcThreshold"//black//graph bc3 COLOURED(0,0,255) AS "bc3"//black//graph bc4 COLOURED(0,255,255) AS "bc4"//black//graph bc5 COLOURED(255,255,0) AS "bc5"//black1 user thanked author for this post.
04/30/2017 at 4:08 PM #3404004/30/2017 at 4:12 PM #3404104/30/2017 at 4:44 PM #34043Hi Maz, no, but rc and mc are, at least in my ver. and currency 🙂 they are exactly the pipsize factor smaller. I admit- it strange.
04/30/2017 at 8:24 PM #34078$ M-R Dif EURUSD M15 Long works good for me Kasper, attached results.
I cant recall making any changes, but my version is attached.
Site below is well easy to use for checks on code difference if you ever need it.
GraHal
05/01/2017 at 6:59 AM #34095Hi GraHal, yes I know it works for most people, I did see some one else having the same problem though. I think it my PRT that has either a diffenent currency conversion or simpley another way of it own.. But when I seperated the Bc1 into every variable I could see the numbers would never match for the two variables tested. That why I never got any trades.
It’s definetely not Maz’s work that has the problem- It’s just depressing.
Cheers Kasper
-
AuthorPosts
Find exclusive trading pro-tools on