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?
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
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.
It is not possible since stoploss set with SET STOP, must be an absolute value.
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.
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
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 🙂
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