reducing stoploss timebased

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #88564 quote
    Paul
    Participant
    Master

    Hi

    If I run a intraday strategy it has to perform with a stoploss of 1%

    Still I like to reduce that, but not with standard optimisation.

    An idea I thought of is reducing it based on time.

    But if a trade continues to a new day, it starts again using the wrong stoploss.

    What is the best way to prevent that?

    Perhaps this may not be a good idea because it creates variables, but still I’am interested to see how it works out.

    set stop %loss sl
    
    if reducestoploss then
    If onmarket and  barindex > tradeindex then
    if time = 100000 and (positionperf*100) > sl-(x*2) then
    set stop %loss sl-(x*2)
    endif
    if time = 113000 and (positionperf*100) > sl-(x*3) then
    set stop %loss sl-(x*3)
    endif
    if time = 133000 and (positionperf*100) > sl-(x*4) then
    set stop %loss sl-(x*4)
    endif
    if time = 150000 and (positionperf*100) > sl-(x*5) then
    set stop %loss sl-(x*5)
    endif
    endif
    endif
    #88649 quote
    Nicolas
    Keymaster
    Master

    What is the best way to prevent that?

    Flag the date in a variable the first time you change the stoploss, and check if it has changed when you are on market.

    #88670 quote
    Paul
    Participant
    Master

    Thanks for the usefull feedback! I was wrong in my approach.

    The code below should do the job.

    reducestoploss=1 ( 0=disabeld)

    // build-in exit
    if not onmarket then
    flag=0
    endif
    
    sl=1.00
    x=0.1
    
    if reducestoploss then
    If onmarket then
    if flag=0 and time = 100000 then
    set stop %loss sl-(x*2)
    flag=1
    endif
    if flag=1 and time = 113000 then
    set stop %loss sl-(x*3)
    flag=2
    endif
    if flag=2 and time = 133000 then
    set stop %loss sl-(x*4)
    flag=3
    endif
    if flag=3 and time = 150000 then
    set stop %loss sl-(x*5)
    flag=4
    endif
    endif
    else
    set stop %loss sl
    endif
    
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

reducing stoploss timebased


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Paul
7 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/14/2019
Status: Active
Attachments: No files
Logo Logo
Loading...