Move SL depending on time – after SL is moved to breakeven.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #176441 quote
    seatroutseatrout
    Participant
    Average

    Hi!

    I´m trying to find a way to move SL, not depending on price but depending on time.

    I have a scalping algo working on 10sec chart and when taking a trade I have a preset SL.
    After that, If the price moves in the right direction, my break even code move the SL to lets say small profit of 1point.
    Often the price movement stalls after that move and also quite often price goes back and hit the breakeven level.
    So my idea is to move SL quite rapidly towards the price after breakeven code have done it´s work so at least a few more points are gained.
    For example every minut (6bars at 10sec chart) the SL will be moved 1point against the price.

    Any ideas how to do it?

    #176446 quote
    XORANDNOTXORANDNOT
    Participant
    Senior

    Like this ? Not tested.

    If not onmarket then
    stopset = 0
    endif
    
    breakeven = positionprice
    
    If longonmarket and highwashighenough and stopset = 0 then
    sell at breakeven stop
    nextstop = breakeven
    stopset = 1
    stopindex = barindex
    endif
    
    If stopset = 1 and barindex = stopindex + 6 then
    nextstop = nextstop + 1
    sell at nextstop stop
    stopindex = barindex
    endif
    seatrout thanked this post
    #176447 quote
    seatroutseatrout
    Participant
    Average

    Thanks alot!

    Took a while to get my head around it… I`m not a coder 😉

    Row 7: “and highwashighenough” shouldn´t be there – right?

    Row: 14-18 makes the loop?

    Row 5: ok to change to  “positionprice+1” ?

    #176448 quote
    XORANDNOTXORANDNOT
    Participant
    Senior

    Of course row 7 should be there. It means that your special condition for setting  the stop  to break-even has been met.

    Row 14-18 pull the stop 1 point higher every 60 seconds. And yes, setting the initial break even to any desired value in row 5 is ok.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Move SL depending on time – after SL is moved to breakeven.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
seatrout @seatrout Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by XORANDNOTXORANDNOT
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/29/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...