Looking for Momentum
Forums › ProRealTime English forum › ProOrder support › Looking for Momentum
- This topic has 5 replies, 3 voices, and was last updated 4 years ago by
nonetheless.
-
-
08/20/2021 at 4:16 PM #175806
Hi,
Attached is a strategy from Kevin Davey, Momentum and Big Range. Very simple entry code which I really like. With help from JC_bywan, thank you. What I notice is the significant uptick in performance from 2017 onward. Therefore, there must be a filter to say when this market condition will change or end? Any ideas would be greatly appreciated. Have yet to try to adapt to other indices or CCY pairs.
(Also – PRT seems to think it is in the market for an infinite period of time! Not sure what’s happening there.)
Thank you very much,
S
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155//================================================// Code: TEST KD1 MomtRange v1// Source: https://www.youtube.com/watch?v=D_P_XqB5nHs// Entry Strategy #1 Momentum and Big Range// Author: Kevin Davey// Version 1// Index: NASDAQ// TF: 15 min// Notes: v1.1 Square root calc// Notes: v1.2 Swaped Square for Sandard Deviation - thanks to JC_bywan// Notes: v1.3 Tried timeframes 1m, 3m, 5m, 10m and 30m - poor performance// Notes: v1.4 Tested different day of week combos - poorreduced overfall performance// Notes: v1.5 Added Break Even Trailing Stop from KISS strategy//================================================//Risk ManagementPositionSize=1//Range ParametersNbars=5Pbars=10rrange=high-lowstdrange=2*std[Nbars](range) //squareavgrange=rrange[Nbars]// Conditions to enter long positionsIf rrange>stdrange+avgrange and close>close[Pbars] thenBuy PositionSize CONTRACTS AT MARKETENDIF// Conditions to enter short positions//IF rrange>2*stdrange+avgrange and close<close[10] THEN//SELLSHORT PositionSize CONTRACTS AT MARKET//ENDIF// Stops and targetsSET STOP LOSS 100 //50SET TARGET PROFIT 175 //50//FOR STOPLOSS MANNGEMENT// Conditions to enter long positionsstartBreakeven = 30PointsToKeep = 12IF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF//************************************************************************IF longonmarket and barindex-tradeindex>1600 and close<positionprice thensell at marketendifIF shortonmarket and barindex-tradeindex>1800 and close>positionprice thenexitshort at marketendif//===================================myrsiM5=rsi[14](close)//if myrsiM5<30 and barindex-tradeindex>1 and longonmarket and close>positionprice thensell at marketendifif myrsiM5>70 and barindex-tradeindex>1 and shortonmarket and close<positionprice thenexitshort at marketendif//===================================once openStrongLong = 0once openStrongShort = 0if (time <= 090000 or time >= 210000) thenopenStrongLong = 0openStrongShort = 0endif//detect strong direction for market openonce rangeOK = 30once tradeMin = 2500IF (time >= 090500) AND (time <= 090500 + tradeMin) AND ABS(close - open) > rangeOK THENIF close > open and close > open[1] THENopenStrongLong = 1openStrongShort = 0ENDIFIF close < open and close < open[1] THENopenStrongLong = 0openStrongShort = 1ENDIFENDIFonce bollperiod = 20once bollMAType = 1once s = 2bollMA = average[bollperiod, bollMAType](close)STDDEV = STD[bollperiod]bollUP = bollMA + s * STDDEVbollDOWN = bollMA - s * STDDEVIF bollUP = bollDOWN THENbollPercent = 50ELSEbollPercent = 100 * (close - bollDOWN) / (bollUP - bollDOWN)ENDIFonce trendPeriod = 80once trendPeriodResume = 10once trendGap = 4once trendResumeGap = 4if not onmarket thenfullySupported = 0fullyResisteded = 0endif//Market supported in the wrong directionIF shortonmarket AND fullySupported = 0 AND summation[trendPeriod](bollPercent > 50) >= trendPeriod - trendGap THENfullySupported = 1ENDIF//Market pull back but continue to be supportedIF shortonmarket AND fullySupported = 1 AND bollPercent[trendPeriodResume + 1] < 0 AND summation[trendPeriodResume](bollPercent > 50) >= trendPeriodResume - trendResumeGap THENexitshort at marketENDIF//Market resisted in wrong directionIF longonmarket AND fullyResisteded = 0 AND summation[trendPeriod](bollPercent < 50) >= trendPeriod - trendGap THENfullyResisteded = 1ENDIF//Market pull back but continue to be resistedIF longonmarket AND fullyResisteded = 1 AND bollPercent[trendPeriodResume + 1] > 100 AND summation[trendPeriodResume](bollPercent < 50) >= trendPeriodResume - trendResumeGap THENsell at marketENDIF//Started real wrong directiononce strongTrend = 60once strongPeriod = 4once strongTrendGap = 2IF shortonmarket and openStrongLong and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent > strongTrend) = strongPeriod - strongTrendGap thenexitshort at marketENDIFIF longonmarket and openStrongShort and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent < 100 - strongTrend) = strongPeriod - strongTrendGap thensell at marketENDIF//SET STOP $LOSS stoploss2 users thanked author for this post.
08/20/2021 at 4:44 PM #175812At line 24, your “avgrange” variable is made equal to rrange Nbars ago, if that’s you wanted then ok… but just in case, with the name suggesting it might be an average, if what you wanted is the average of rrange over Nbars, then it would be:
1avgrange=average[Nbars](rrange)08/20/2021 at 4:50 PM #175815is that backtest for long only? short entry is //
08/20/2021 at 5:09 PM #175816At line 24, your “avgrange” variable is made equal to rrange Nbars ago, if that’s you wanted then ok… but just in case, with the name suggesting it might be an average, if what you wanted is the average of rrange over Nbars, then it would be:
1avgrange=average[Nbars](rrange)Thank you, my error. I also see I hadn’t copied over the “DEFPARAM CUMULATEORDERS = FALSE” at the start.
1 user thanked author for this post.
08/20/2021 at 5:11 PM #175817is that backtest for long only? short entry is //
Hello – This is a long only strategy for now. I have left the short side in but commented out for now, as I plan to add it in for the next version.
1 user thanked author for this post.
08/20/2021 at 5:12 PM #175818I also see I hadn’t copied over the “DEFPARAM CUMULATEORDERS = FALSE”
I was about to say that. makes a rather large difference, but i guess you’ve seen that now.
-
AuthorPosts
