Combining STOP orders with STOP LOSS orders

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #112264 quote
    Wilko
    Participant
    Senior

    I have a question that I hope someone on the forum can help me answer.

    This is best explained by an example:

    Let’s suppose I have a system that issues a buy-order and at the same time sets a stop loss:

    IF NOT LongOnMarket AND Close > Close[1] THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP %LOSS 1
    ENDIF

    Let’s say I then at a later bar want to issue a different STOP order

    IF BarIndex - TradeIndex >= 2 AND Close > PositionPrice THEN
    SELL AT close STOP
    ENDIF

    Will the system accept the new order without first cancelling the first STOP LOSS order? Ie will it reject the second STOP order because there is already a STOP order in the system? Or can a system have one STOP LOSS order at the same time as a different SELL STOP order?

    In other words do I have to run the below instruction before I can issue the second STOP order?

    SET STOP %LOSS 0

    Many thanks for any clarification!

     

    /F

    #112269 quote
    robertogozzi
    Moderator
    Master

    You can write the second line 2 as:

    SELL AT MARKET

    since that code will be always executed at closing time, thus CLOSE is the current price.

    ProOrder does’n care about previous settings, whenever there’s a LONG trade open and you order it to SELL… it.

    Your broker may have some objections if you don’t abide to its distance requirements.

    Wilko thanked this post
    #112270 quote
    Wilko
    Participant
    Senior

    Thanks! I didn’t realize it was a bad example!  I will change above code to the below to hopefully make it clear what I am trying to do:

    SELL AT close * 0.995 STOP

    I am aware that I need to respect minimum distance requirements for any STOP or LIMIT orders

    #112271 quote
    robertogozzi
    Moderator
    Master

    It will place the SELL order at your requested price level. As all pending orders it will expire after 1 bar and you will have to place it again, if needed.

    But I’m not sure if this will affect your previous SL. in case your SELL order is not triggered and expires and you don’t place it again will your previous SL be remembered or you may end up without a SL.

    When I trail stop loss, any time a new pending stop order is executed, IG updates the status of my trade to set a new SL, and it remains there because I set it continuously candle after candle, but I never tried to not place it again to see what happens.

    It would be worth trying.

    #112272 quote
    robertogozzi
    Moderator
    Master

    I just tested this strategy, it sets a SL at 200 pips from entry price, then, when onmarket, sets a new SELL pending order at 100 pips from entry price without placing it again next bar.

    The original SL is kept, while for just 1 bar there’s a further pending order at -100 pips:

    ONCE Flag = 0
    // place a SL to 100 pips for just this time to let it expire
    IF OnMarket AND Flag = 0 THEN
       SELL AT Tradeprice - 100 * pipsize STOP
       Flag = 1
    ENDIF
    IF Not OnMarket THEN
       BUY AT MARKET
       SET TARGET pPROFIT 200
       SET STOP   pLOSS   200
    ENDIF
    Wilko thanked this post
    #112273 quote
    Wilko
    Participant
    Senior

    Thanks!

    If that is correct, that’s good news for me. I remember seeing an order rejected with error message “Stop order already active”, so therefore my question. But I guess one of my systems managed to issue two stop orders during same instance in that case.

    #112282 quote
    Nicolas
    Keymaster
    Master

    But I guess one of my systems managed to issue two stop orders during same instance in that case.

    In that case, the first stop order read in the code is the one that will be set.

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

Combining STOP orders with STOP LOSS orders


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Wilko @wilko Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by Nicolas
6 years, 3 months ago.

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