Low Volume Reversal Strategy
Forums › ProRealTime English forum › ProOrder support › Low Volume Reversal Strategy
- This topic has 16 replies, 8 voices, and was last updated 1 year ago by T-rader.
-
-
08/24/2021 at 3:21 PM #176098
Hi,
Here is another strategy that uses 2 simple entry criteria and one filter as the core requirements. As volume is better at the start and end of the week it doesn’t trade mid-week or Sundays. It is an adaptation of a strategy from……Kevin Davey (well guessed). Adapted from a Daily time frame to a 15 minute. As you will see in the code, I have added in various snippets of code from nonetheless and robertogozzi, thank you.
The strategy looks for a low volume bar compared to a look back period of 5 and a new lowest close over a look back period of 4 in order to go long. As it uses volume as an entry criteria I can only back test to June 2016.
Work in progress, but I wanted to share to see if it sparks any interest for new ideas on how to evolve it. Walkforward has proven well so fat. Am working on possible short entry and ways to reduce drawdown.
Thank you, hope you enjoy and welcome any feedback.
5 users thanked author for this post.
08/24/2021 at 3:35 PM #17610108/24/2021 at 9:10 PM #176140Lets try to help https://www.prorealcode.com/user/samsampop to improve his code.
How to create good short entrys?
How to reduce Drawdown?
Is something from here helfull: “https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0TEST LowVolRev DJI 15m v1.7123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192//==========================================================================================================// Code: TEST LowVolRev DJI 15m v1// Source: Inspired by Kevin Davey's Low Volume Reversal idea// Author: Kevin Davey// Version 1// Index: DJI// TF: 15 min (adapted from Daily to 15min)// TZ: EU// Spread: 2// Notes: v1.1 Core strategy, Long only// v1.2 Added and optimised Entry Filter (Moving Averages)// v1.3 Added Breakeven and Trailing Stop from KISS stategy (need to test others, incl. ATR)// v1.4 Focused on volume at start and end of week where it is typcially higher// v1.5 Added Max Monthly Loss logic// Author robertogozzi// v1.6 $ Loss limit linked to PositionSize// Author Van K. Tharp (Position Sizing theory)// v1.7 Added Exit Zombie Trade code// Author nonetheless//// Pending: Need to test possible Short entry// Need to reduce Drawdown//==========================================================================================================DEFPARAM CUMULATEORDERS = false//=== Risk Management ===PositionSize=10stoploss=PositionSize*180 //1800//=== Max Monthly Loss ===ONCE MyProfit = 0ONCE TradeON = 1IF Month <> Month[1] THENMyProfit = STRATEGYPROFIT //store profits/losses at the beginning of each monthTradeON = 1 //enable trading each new monthENDIFIF (STRATEGYPROFIT - MyProfit) < -3500 THEN //disable trading when losing > 200 currency unitsTradeON = 0ENDIF//=== Entry Filter ===//Filter 1indicator1=average[75,7]indicator2=average[125,7]indicator3=average[150,7]F1 = indicator1>indicator2F2 = indicator2>indicator3//=== Entry Criteria ===//Entry Criteria 1entrylen = 5LowVol = round(volume[4])E1 = volume < LowVolbullish = close>lowest[entrylen](low)IF E1 AND bullish AND F1 AND F2 AND opendayofweek <> 3 AND opendayofweek <> 4 AND opendayofweek <> 0 AND opendayofweek <> 6 AND TradeON THENBUY PositionSize CONTRACTS AT MARKETSET STOP $LOSS stoplossENDIF//=== Breakeven and Stop Loss ===startBreakeven = 31PointsToKeep = 11IF 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 stoploss//=== Exit Zombie Trades ===EZT = 1if EZT thenIF longonmarket and (barindex-tradeindex(1)>= 550 and positionperf>0) or (barindex-tradeindex(1)>= 100 and positionperf<0) thensell at marketendifendif08/24/2021 at 9:55 PM #176142I think this might be the most promising of the KD codes you have posted. This is a fairly quick revision, could be more room for improvement, eg short.
I added MM, replaced the breakeven with a trail, disabled the “detect direction” (which didn’t seem to be helping), added % stop and target, re-opt the averages.
I always use minimum size for testing (0.2), so x50 to compare with your results.
thanks for sharing!
4 users thanked author for this post.
08/25/2021 at 5:43 AM #176148Thanks for the improvements nonetheless. Are these improvements possible to ad to NASDAQ Mean Reversion
08/25/2021 at 7:19 AM #176150se minimum size for testing (0.2),
Wow – that’s an amazing piece of work. Thank you so much. I am working through each of the modifications you have made to ensure I fully understand them. What an incredible series of enhancements.
08/25/2021 at 8:54 AM #176159Are these improvements possible to ad to NASDAQ Mean Reversion
no, each would have to be treated separately. I’ll have a look at it when I get a chance.
09/06/2021 at 5:08 PM #17689109/08/2021 at 10:35 PM #17706509/09/2021 at 2:26 AM #177073Remove all variables used for optimization wih values or other variables not to be optimized.
There can’t be variables in the optimization window.
09/09/2021 at 9:01 AM #177096This is essentially the version 2 of Nonetheless (rif. 176142) with the max daily loss and split winning position (v.3.1).
[Test 200K: v3.1 on the right side]
//TS KD LowVolume v3.1 – DowJones 15 min – cfd 1 contract
//spread 4 points
DEFPARAM CUMULATEORDERS = false
PositionSize=1
//———————————————SETUP
avgHull11=average[45,7]
avgHull2=average[135,7]
avgHull3=average[145,7]
c1 = avgHull11>avgHull2 and avgHull2>avgHull3
lowVol = round(volume[4])
c2 = volume < lowVol
lowBars = 5
c3 = close>lowest[lowBars](low)
IF c1 and c2 AND c3 and tradeAllowed = 1 THEN
BUY PositionSize CONTRACTS AT MARKET
ENDIF
//———————————————————————
EZT = 1
if EZT then
IF longonmarket and (barindex-tradeindex(1)>= 640 and positionperf>0) or (barindex-tradeindex(1)>= 160 and positionperf<0) then
sell at market
endif
endif
//———————————————————————
myrsiM5=rsi[14](close)
if myrsiM5<30 and barindex-tradeindex>1 and longonmarket and close>positionprice then
sell at market
endif
if myrsiM5>70 and barindex-tradeindex>1 and shortonmarket and close<positionprice then
exitshort at market
endif
//—————————————————————-
maxDailyLoss = 200
realPosition=positionPerf*positionPrice/pointSize*pointValue
once tradeAllowed = 1
if intradayBarIndex=0 then
myProfit=strategyProfit
tradeAllowed=1
endif
if (strategyProfit+realPosition) <= (myProfit-maxDailyLoss) then
tradeAllowed=0
endif
//—————————————————————————————–
SET STOP %LOSS 0.9
SET TARGET %PROFIT 3.5
//—————————————————————————————–
once trailingstop = 1
if trailingstop then
trailingpercentlong = 0.29
once acceleratorlong = 0.035
once steppercentlong = (trailingpercentlong/10)*acceleratorlong
if onmarket then
trailingstartlong = positionprice*(trailingpercentlong/100)
trailingsteplong = positionprice*(steppercentlong/100)
endif
IF NOT ONMARKET THEN
newSL=0
ENDIF
IF LONGONMARKET THEN
IF newSL=0 AND high-tradeprice(1)>=trailingstartlong THEN
newSL = tradeprice(1)+trailingsteplong
ENDIF
IF newSL>0 AND high-newSL>trailingsteplong THEN
newSL = newSL+trailingsteplong
ENDIF
ENDIF
IF newSL>0 THEN
SELL AT newSL STOP
ENDIF
endif
//———————————————————————————————————————–
once partialcloseGain = 1
If partialcloseGain then
ONCE PerCent = 0.5 //close 1/2 size
ONCE PerCentGain = 0.023 //0.005 = 0.5%
ONCE MinLotSize = 0.5
ExitQuantity = abs(CountOfPosition) * PerCent
LeftQty = max(MinLotSize,abs(CountOfPosition) – ExitQuantity)
CloseQuantity = abs(CountOfPosition) – LeftQty
IF Not OnMarket THEN
Flag = 1
ENDIF
IF partialcloseGain AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain)) AND Flag THEN
SELL CloseQuantity Contracts AT Market
Flag = 0
endif
endif
//——————————————————————–
2 users thanked author for this post.
09/09/2021 at 9:05 AM #17709806/12/2023 at 8:34 PM #216029I am on it but as of now, I ain’t successful at all…
08/05/2023 at 11:47 PM #21863708/06/2023 at 6:50 AM #218638Hi, assuming you have made your backtest with IG, there was no volume data on major indexes before 2016 (forex goes back earlier). Reading the code script, at least one condition necessary to start a trade involves volume not being zero, so even with plenty of history loaded on a big timeframe taking a trade with those conditions wouldn’t happen until volume data is provided sometime in 2016.
If on the other hand you were not on IG (or on an asset providing volume long before 2016), then more details on broker and asset used need to be provided to be able to replicate the issue in same conditions.
-
AuthorPosts
Find exclusive trading pro-tools on