using set stop and trail stop

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #130158 quote
    leeb82
    Participant
    New

    Hi,

    this is my very first blog post ever so please be kind. I have no experience in programming but i am really keen to try and learn. i would like to and develop some auto trading systems. due to my lack of experience i am having trouble understanding

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[10](close)
    c1 = (close > indicator1)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator2 = Average[10](close)
    c2 = (close < indicator2)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator3 = Average[10](close)
    c3 = (close < indicator3)
    
    IF c3 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator4 = Average[10](close)
    c4 = (close > indicator4)
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP ploss 20 pTRAILING 10
    

     

    the use of combined stops.  i would like to use an initial stop loss, then trail as the trade is in profit.

    for example – if i have ” SET STOP ploss 20 pTRAILING 10. does that mean a hard stop of 20 is in place until the trade moves in my favour? once in profit the trail stop is activated and is closer to price so the 10p trail stop is in place. i have added the code as per the instruction but like i said, i am mainly interested in how the stop loss section reads.

    many thanks,

    Lee

    #130160 quote
    robertogozzi
    Moderator
    Master

    Line 37 is not allowed, you can’t combine two different kind of SL’s.

    Use

    SET STOP ploss 20

    then use Nicolas’code at https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/

    (lines 17-56) as a trailing stop.

    #130189 quote
    GraHal
    Participant
    Master

    you can’t combine two different kind of SL’s.

    Several of the Guidance Notes (one example below) in the link below need deleting then @Nicolas?

    In the meantime I will delete the Log to the link below in the Snippet Library to save confusion.

    A stop loss is placed at x points from average position price and it becomes a trailing stop of y points if the trailing stop level becomes closer to current price than the stop loss level (this occurs price varies favourably by
    y points – x points).

    #130193 quote
    Nicolas
    Keymaster
    Master

    This kind of instruction doesn’t work in real trading because IG doesn’t allow it. It doesn’t mean that it will not be compatible with the automated trading function that will come for Interactive Broker accounts.

    GraHal and robertogozzi thanked this post
    #130204 quote
    leeb82
    Participant
    New

    Thanks so much guys. This has really cleared it up for me.

    cheers,

    Lee

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

using set stop and trail stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
leeb82 @leeb82 Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by leeb82
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/06/2020
Status: Active
Attachments: No files
Logo Logo
Loading...