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.
-
-
06/06/2017 at 12:47 PM #3760807/27/2017 at 10:57 AM #4178508/14/2017 at 2:06 PM #43151
Hi, I think there could be some edge on Brent crude for this system but I have very limited history. Maybe there is someone with slightly more data who wants to give it a try?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172// ====================================== \\// :: Optimizations --// -------------------------------------- //// Static Optimization for Brent Crude Contract 1 hour// Jan 2013 - April 2017// Spread 3 pointsreinvest = 0opti = 2if opti =1 thenwintarget = 30 // Clip target to maximum of x points (45)//wintarget = (atr * targetATRmultiple)*pointsizeminTradeTime = 17 // stay in trade for at least x barsmcShortPeriod = 6 // Short period momentumrcShortPeriod = 3 // Short period average rangemcLongPeriod = 92 // Long period momentumrcLongPeriod = 54 // Long period average rangemcThreshold = 0.16 // 0.5 // Momentum coefficient thresholdrcThreshold = 0.41 // 1 // Range coefficient thresholdmaShortPeriod = 44 // Short term moving averagemaLongPeriod = 25 // Long term moving averageatrPeriod = 14 // preiods for average true rangeslATRmultiple = 5 // multiplier for dynamic stop (3)stoptargettype = 2 // 1= fixed stop, 2=dynamic stop//targetATRmultiple = 2 //if dynamic target// Static Optimization for Brent Crude Contract 1 hour// Jan 2013 - April 2017// Spread 3 pointselsif opti = 2 then//wintarget = 30 // Clip target to maximum of x points (45)wintarget = (atr * targetATRmultiple)*pointsizetargetATRmultiple = 1 //if dynamic targetminTradeTime = 17 // stay in trade for at least x barsmcShortPeriod = 4 // Short period momentumrcShortPeriod = 3 // Short period average rangemcLongPeriod = 40 // Long period momentumrcLongPeriod = 120 // Long period average rangemcThreshold = 0.16 // 0.5 // Momentum coefficient thresholdrcThreshold = 0.41 // 1 // Range coefficient thresholdmaShortPeriod = 5 // Short term moving averagemaLongPeriod = 15 // Long term moving averageatrPeriod = 14 // preiods for average true rangeslATRmultiple = 3 // multiplier for dynamic stop (3)stoptargettype = 1 // 1= fixed stop, 2=dynamic stopendiftraidingtime = (currenttime > 060000 and currenttime < 230000)// ====================================== \\// :: Position size// -------------------------------------- //once startpositionsize=1once positionsize=startpositionsizeif reinvest = 0 thenpositionsize=1elsif reinvest = 1 then//------------ Fixed fraction money management ----------once multiplier=1once fraction=100*pipvalueonce newlevel=100*pipvalueonce oldlevel=100*pipvalueonce startequity=1000if strategyprofit+startequity>newlevel thenmultiplier=multiplier+1oldlevel=newlevelnewlevel=strategyprofit+startequity+multiplier*fractionpositionsize=multiplier*startpositionsizeelsif strategyprofit+startequity<oldlevel and multiplier>=2 thennewlevel=strategyprofit+startequityoldlevel=strategyprofit+startequity-multiplier*fractionmultiplier=multiplier-1positionsize=multiplier*startpositionsizeendifendif// ====================================== \\// :: 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)atr = averagetruerange[atrPeriod](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]bc1 = bc1 and traidingtime// long exit rules (exit long conditions)le1 = longOnMarketle1 = le1 and ( barIndex >= barIndexAtBuy + minTradeTime)le1 = le1 and (maLong < maLong[4])// ====================================== \\// :: Execution Handlers// -------------------------------------- //if bc1 thenbuy positionsize contracts at marketset target pprofit wintargetbarIndexAtBuy = barIndexendifif le1 and longOnMarket thensell at marketendifif stoptargettype = 1 thenSET STOP pLOSS 95elsif stoptargettype= 2 thenSET STOP plOSS (atr * slATRmultiple)*pointsizeendif//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 STOPendif08/15/2017 at 3:15 PM #43203Hi Victormork, any reason why it trades only on the long side?
Grazie!
08/16/2017 at 7:22 AM #43234Hi! This is the long side only. I’ve not tried to make a short version yet.
1 user thanked author for this post.
10/25/2017 at 12:22 PM #50486Please correct me if I wrong,
At the begining, when I was learning to code, I test a lot of ideas with a lot of variable to be optimized and nice results. Then I run them in real and I made a lot of losses.
Then I continue reading and practicing until I learn that and over optimization create an strategy that only work in the past…. then the WF tool came to PRT….
…but,
Is it a correct aproach to create a trading System with a lot of variables and of course it will very profitable because is over-optimized in the past but not for the future?
Is it “robustness” inversely proportional to the number of variable in a trading system?
10/26/2017 at 1:00 PM #50604Hi Leo, One suggestion could be to start with a base line. Let say that if close > atr(10)*2 you will go long and exit after 5 bars. If this entry/exit criteria alone produce a positive return then you have a baseline. Let’s say that you try simliar entries on several markets and you find that it works on a few, then you have a kind of robust start. You can then enhance the return slightly with different trend filters etc. but here you need to be careful not to add to many or taking out a lot of trades. With the momentum-range system this indicator which is stated in the code is the base that filters has been added around. If you take out filters from the system you can see what difference they make and maybe judge if it make sense to include or not.
2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on