SET STOP pLOSS with negative value

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #59112 quote
    Vonasi
    Moderator
    Master

    I was just working on a new trailing stop theory and using SET STOP pLOSS SL at the end of the code and changing the value of SL within the code – I was getting some weird results as I was limiting the minimum value of SL to 1. For some reason I had not twigged that the STOP pLOSS is subtracted from the TradePrice or PositionPrice and so there is no reason why you cannot have a negative value for the stop loss – meaning that as you go into profit SET STOP pLOSS can be used to close positions above the TradePrice/PositionPrice.

    I don’t think I have seen any other trailing stops doing this – they seem to prefer SELL AT x STOP rather than a negative valued SET STOP pLOSS.

    Except for the fact that I think I need to avoid a zero value on the SET STOP pLOSS is there any reason not to do this as the lack of other code with it in always gives me reason to wonder?

    #59115 quote
    Nobody
    Participant
    Veteran

    I wrote a post to reply but i somehow i got logged out and then couldnt log back in and in the process my post disappeared  . Correct me if i am wrong but would not any – stop loss have you stopped on any entry for the price of the spread instantaneously  ?   I cant fathom how this could possibly work   . What am i missing here

    #59123 quote
    Vonasi
    Moderator
    Master

    Yes if it was not a trailing stop. I start with a positive value and slowly move it into negative as price rises. So (PositionPrice – (-20)) is 20 pips above PositionPrice which is fine if close is 30 above for example.

    #59189 quote
    Nicolas
    Keymaster
    Master

    It is not possible since stoploss set with SET STOP, must be an absolute value.

    #59192 quote
    Vonasi
    Moderator
    Master

    I’ve replied in the other discussion we are having about this at:

    GRAPH Close returns wrong value

    Strange thing is that it seems to work but just messes up the GRAPH function.

    Guess I’ll just go back to SELL STOP orders.

    #59194 quote
    Vonasi
    Moderator
    Master

    Am I right in my thinking that if you have the following code that the SELL STOP order will not be set at the time that the BUY order is placed as at that candles close PositionPrice has no value? You will have to wait for the next candles close.

    IF Not OnMarket and <conditions> THEN
    BUY 1 CONTRACT AT MARKET
    SELL AT (PositionPrice - SL) STOP
    ENDIF
    
    
    #59219 quote
    Nicolas
    Keymaster
    Master

    Right, since PositionPrice will only be known at the end of the next candlestick. You can do something like this instead:

    SELL AT (Close - SL) STOP

    Making the assumption that there will be no gap, it should be ok 🙂

    #59224 quote
    Vonasi
    Moderator
    Master

    Could you do something like this to avoid the gap issue and have a trailing stop?

    IF Not OnMarket and <conditions to buy> THEN
    BUY 1 CONTRACT AT MARKET
    SL = <Starting Stop Loss>
    SET STOP pLoss SL
    ENDIF
    
    IF OnMarket and <conditions to change stop> THEN
    SL = SL - <amount you want to reduce stoploss by>
    SET STOP pLoss 0 //cancel StopLoss order
    SELL AT (PositionPrice - SL) STOP
    ENDIF
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

SET STOP pLOSS with negative value


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by Vonasi
8 years, 1 month ago.

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