Low Volume Reversal Strategy

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #176098 quote
    deletedaccount051022
    Participant
    New

    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.

    Low-Volume-Reversal.png Low-Volume-Reversal.png TEST-LowVolRev-DJI-15m-v1.7.itf
    #176101 quote
    robertogozzi
    Moderator
    Master

    Good job samsampop. Thank you for sharing your code 🙂

    thanked this post
    #176140 quote
    murre87
    Participant
    Senior

    Lets 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=0

    //==========================================================================================================
    //   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=10
    stoploss=PositionSize*180  //1800
    
    
    //=== Max Monthly Loss ===
    ONCE MyProfit = 0
    ONCE TradeON  = 1
    IF Month <> Month[1] THEN
    MyProfit = STRATEGYPROFIT //store profits/losses at the beginning of each month
    TradeON  = 1              //enable trading each new month
    ENDIF
    IF (STRATEGYPROFIT - MyProfit) < -3500 THEN  //disable trading when losing > 200 currency units
    TradeON = 0
    ENDIF
    
    
    //=== Entry Filter ===
    //Filter 1
    indicator1=average[75,7]
    indicator2=average[125,7]
    indicator3=average[150,7]
    
    F1 = indicator1>indicator2
    F2 = indicator2>indicator3
    
    
    //=== Entry Criteria ===
    //Entry Criteria 1
    entrylen = 5
    LowVol = round(volume[4])
    E1 = volume < LowVol
    
    bullish = 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  THEN
    BUY PositionSize CONTRACTS AT MARKET
    SET STOP $LOSS stoploss
    ENDIF
    
    
    //=== Breakeven and Stop Loss ===
    startBreakeven = 31
    PointsToKeep = 11
    
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    
    // --- BUY SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
     
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    
    //************************************************************************
    IF longonmarket and barindex-tradeindex>1600 and close<positionprice then
    sell at market
    endif
    IF shortonmarket and barindex-tradeindex>1800 and close>positionprice then
    exitshort at market
    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
    //===================================
    
    once openStrongLong = 0
    once openStrongShort = 0
    if (time <= 090000 or time >= 210000) then
    openStrongLong = 0
    openStrongShort = 0
    endif
    
    //detect strong direction for market open
    once rangeOK = 30
    once tradeMin = 2500
    IF (time >= 090500) AND (time <= 090500 + tradeMin) AND ABS(close - open) > rangeOK THEN
    IF close > open and close > open[1] THEN
    openStrongLong = 1
    openStrongShort = 0
    ENDIF
    IF close < open and close < open[1] THEN
    openStrongLong = 0
    openStrongShort = 1
    ENDIF
    ENDIF
    
    once bollperiod = 20
    once bollMAType = 1
    once s = 2
    
    bollMA = average[bollperiod, bollMAType](close)
    STDDEV = STD[bollperiod]
    bollUP = bollMA + s * STDDEV
    bollDOWN = bollMA - s * STDDEV
    IF bollUP = bollDOWN THEN
    bollPercent = 50
    ELSE
    bollPercent = 100 * (close - bollDOWN) / (bollUP - bollDOWN)
    ENDIF
    
    once trendPeriod = 80
    once trendPeriodResume = 10
    once trendGap = 4
    once trendResumeGap = 4
    if not onmarket then
    fullySupported = 0
    fullyResisteded = 0
    endif
    //Market supported in the wrong direction
    IF shortonmarket AND fullySupported = 0 AND summation[trendPeriod](bollPercent > 50) >= trendPeriod - trendGap THEN
    fullySupported = 1
    ENDIF
    
    //Market pull back but continue to be supported
    IF shortonmarket AND fullySupported = 1 AND bollPercent[trendPeriodResume + 1] < 0 AND summation[trendPeriodResume](bollPercent > 50) >= trendPeriodResume - trendResumeGap THEN
    exitshort at market
    ENDIF
    
    //Market resisted in wrong direction
    IF longonmarket AND fullyResisteded = 0 AND summation[trendPeriod](bollPercent < 50) >= trendPeriod - trendGap THEN
    fullyResisteded = 1
    ENDIF
    
    //Market pull back but continue to be resisted
    IF longonmarket AND fullyResisteded = 1 AND bollPercent[trendPeriodResume + 1] > 100 AND summation[trendPeriodResume](bollPercent < 50) >= trendPeriodResume - trendResumeGap THEN
    sell at market
    ENDIF
    
    //Started real wrong direction
    once strongTrend = 60
    once strongPeriod = 4
    once strongTrendGap = 2
    IF shortonmarket and openStrongLong and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent > strongTrend) = strongPeriod - strongTrendGap then
    exitshort at market
    ENDIF
    
    IF longonmarket and openStrongShort and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent < 100 - strongTrend) = strongPeriod - strongTrendGap then
    sell at market
    ENDIF
    
    //SET STOP $LOSS stoploss
    
    //=== Exit Zombie Trades ===
    EZT = 1
    if EZT then
    IF longonmarket and (barindex-tradeindex(1)>= 550 and positionperf>0) or (barindex-tradeindex(1)>= 100 and positionperf<0) then
    sell at market
    endif
    endif
    
    #176142 quote
    nonetheless
    Participant
    Master

    I 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!

    Midlanddave, murre87 and KumoNoJuzza thanked this post
    DJ-15m-LowVolRev-v2.jpg DJ-15m-LowVolRev-v2.jpg DJ-15m-LowVolRev-v2.itf
    #176148 quote
    murre87
    Participant
    Senior

    Thanks for the improvements nonetheless.  Are these improvements possible to ad to NASDAQ Mean Reversion 

    #176150 quote
    deletedaccount051022
    Participant
    New

    se 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.

    #176159 quote
    nonetheless
    Participant
    Master

    Are 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.

    #176891 quote
    murre87
    Participant
    Senior

    Great strategy.  Anyone got further with short?

    #177065 quote
    s83
    Participant
    Junior

    Can anyone help me with this error?

    624081B8-47F1-4D04-9D29-03138073D17D.jpeg 624081B8-47F1-4D04-9D29-03138073D17D.jpeg
    #177073 quote
    robertogozzi
    Moderator
    Master

    Remove all variables used for optimization wih values or other variables not to be optimized.

    There can’t be variables in the optimization window.

    #177096 quote
    MauroPro
    Participant
    Veteran

    This 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

    //——————————————————————–

    reb and KumoNoJuzza thanked this post
    TS-KD-LowVol.jpg TS-KD-LowVol.jpg
    #177098 quote
    murre87
    Participant
    Senior

    Hi.

    What is

    YourConditions

    in your backtest?

    #216029 quote
    KumoNoJuzza
    Participant
    New

    I am on it but as of now, I ain’t successful at all…

    #218637 quote
    T-rader
    Participant
    Average

    Nice strategy. Have performed alright since you posted exempt for in downtrend. How come the strategy dosen´t take any trades before 2016 even if i test it on higher timeframes?

    #218638 quote
    JC_Bywan
    Moderator
    Master

    Hi, 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.

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.

Low Volume Reversal Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 16 replies,
has 8 voices, and was last updated by T-rader
2 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/24/2021
Status: Active
Attachments: 6 files
Logo Logo
Loading...