duration of a stoploss

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #76083 quote
    immo_vienna
    Participant
    Average

    hi guys!

    i read in some articles that an stoploss has an duration of 1 candle.

    so if i have the following code for automatic trading – the stoploss is only for 1 minute, 10 minutes, (depends on the timeframe)?

     

    //trailing stop function
    trailingstart = 20 //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
    //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*pipsize then
    newSL = tradeprice(1)+trailingstep*pipsize
    endif
    //next moves
    if newSL>0 and close-newSL>=trailingstep*pipsize then
    newSL = newSL+trailingstep*pipsize
    endif
    endif
    //manage short positions
    if shortonmarket then
    //first move (breakeven)
    if newSL=0 and tradeprice(1)-close>=trailingstart*pipsize then
    newSL = tradeprice(1)-trailingstep*pipsize
    endif
    //next moves
    if newSL>0 and newSL-close>=trailingstep*pipsize then
    newSL = newSL-trailingstep*pipsize
    endif
    endif
    //stop order to exit the positions
    if newSL>0 then
    sell at newSL stop
    exitshort at newSL stop
    endif

    @ this point: thx to nicolas for this system

    #76084 quote
    robertogozzi
    Moderator
    Master

    STOP LOSS does not expire if you set it with ProOrder instructions (SET STOP LOSS,…..).

    PENDING ORDERS expire each bar (be it 1 second or 1 week) and need to be placed again if needed. Thus if you set your SL with a pending order (like Nicolas did in his code) it must be placed again if you still need it after each bar. Nicolas’code does this with lines 31-34.

    immo_vienna thanked this post
    #76085 quote
    Vonasi
    Moderator
    Master

    Correct. LIMIT and STOP orders last for one bar only. So on a ten minute time frame it is for ten minutes. If you want the order kept on the market then reissue it at each candle close or use a SET instruction to place a stop or limit on the market at a set distance from the position price. A SET instrution only has to be issued once and keeps the order on the market until the position is closed. The SET distance can be changed at any bar close by placing a new SET instruction if you want to change the value.

    immo_vienna thanked this post
    #76086 quote
    immo_vienna
    Participant
    Average

    how to write such SET instruction?

    #76088 quote
    robertogozzi
    Moderator
    Master
    #76089 quote
    immo_vienna
    Participant
    Average

    thx! all of u out there are amazing and i love this forum because u all are here!

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

duration of a stoploss


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by immo_vienna
7 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/16/2018
Status: Active
Attachments: No files
Logo Logo
Loading...