TSV time segmented volume

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #155633 quote
    JohnScher
    Participant
    Veteran

    Your loved ones.

    It’s about this indicator: https://www.prorealcode.com/prorealtime-indicators/tsv-time-segmented-volume/

    I reprogrammed the indicator into a long-only strategy and brought in a time-based component, a filter and a trailing stop.
    The result 200k attached in the screenshot.

     

    //-------------------------------------------------------------------------
    // Main code : TSV 1HL 51/151 trail 1/1/1
    // dax 1 euro
    // timezone europe, berlin
    // timeframe 1h
    //-------------------------------------------------------------------------
    
    
    
    defparam cumulateorders = false
    once position = 1
    
    ONCE p1    = 51
    ONCE p2    = 151
    ONCE Mtype = 0
    
    p1           = max(1,min(999,p1))
    p2           = max(1,min(999,p2))
    Mtype        = max(0,min(6,Mtype))
    MyVol = 0
    
    IF close > close[1] THEN
    MyVol = volume * (close - close[1])
    ELSIF close < close[1] THEN
    MyVol = -volume * (close - close[1])
    ENDIF
    
    TSV    = summation[p1](MyVol)
    Signal = average[p2, MType](TSV)
    
    
    td = opendayofweek = 1 or opendayofweek = 2 or opendayofweek = 3 or opendayofweek = 4 or opendayofweek = 5
    tt = time >=  090000 and time <= 110000 or time >= 160000 and time <= 180000
    
    
    a = 1
    b = 1
    c = 1
    
    
    IF td and tt then
    if TSV crosses over Signal and close > exponentialaverage [100] (close) then
    buy position contracts at market
    set stop %loss a
    endif
    endif
    
    //%trailing stop function
    trailingPercent = b
    stepPercent = c
    
    if onmarket then
    trailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailingstart points profit
    trailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stoploss
    endif
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart THEN
    newSL = tradeprice(1)+trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
    newSL = tradeprice(1)-trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>trailingstep THEN
    newSL = newSL-trailingstep
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
     
    

     

    The question I have is whether I have programmed this through correctly? Maybe one of you can take a look at it and give me his opinion? Maybe

    Can I still improve something on it? –  or is this complete stupid what I have programmed here?

    Kind regards
    JohnScher

    MAKSIDE thanked this post
    tsv-1hl-trail.png tsv-1hl-trail.png
    #155642 quote
    robertogozzi
    Moderator
    Master

    The code was modified due to a typo in the formula I used to make it. A user pointed this out and I corrected the code at https://www.prorealcode.com/topic/time-segmented-volume-by-worden-brothers-code/page/2/#post-150506.

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

TSV time segmented volume


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
JohnScher @johnscher Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/30/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...