Widen stoploss overnight

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #77953 quote
    robertogozzi
    Moderator
    Master

    You can or cannot use ABS, it depends on your coding style. Look at this code, the most widely used for trailing stops https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/.

    To check if the current price has reached your trailing stop treshold you can (but the above example is complete and perfectly working AS IS) write:

    // for LONG trades
    IF TRADEPRICE - close >= MyTreshold THEN
       .
       .
    ENDIF
    
    // for SHORT trades
    IF close - TRADEPRICE >= MyTreshold THEN
       .
       .
    ENDIF

     

    #77954 quote
    Vonasi
    Moderator
    Master

    Negative values do not work with a SET STOP.

    #77957 quote
    Seb
    Participant
    Average

    Alright, so you can only trail to break-even with a SET STOP type stoploss. Than I will try to find out what’s causing the strange overnight behavior with the stops as described in my first post.

    #77962 quote
    Vonasi
    Moderator
    Master

    Also do not forget that if you send an order to the market that is too close to the price then the order will be rejected. You need to consider the minimum allowed stop distance for whatever instrument you are trading and include something in your code to ensure you never try to place an order that is under it.

    Seb thanked this post
    #77964 quote
    Seb
    Participant
    Average

    I experienced that if it tries to put in a stoploss and the current price is beyond the stoploss level, the position closes at market (with IG CFD). Stops too close indeed got rejected. Will this shut the system down after too many rejections?

    #77967 quote
    GraHal
    Participant
    Master
    Will this shut the system down after too many rejections?

    Yes, after 12 rejections, you are closed down on the 13th I think?

    Not sure if there is a time limit on that, like > 12 rejections within 1 week etc??

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

Widen stoploss overnight


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Seb @seb Participant
Summary

This topic contains 20 replies,
has 4 voices, and was last updated by GraHal
7 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/09/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...