Hi every one,
Let’s take the example where I am long in market, the buy price 20, and I create a stop loss at 15, If I create a sell order higher than my SL I have the impression that sometimes it doesn’t work, so the question is how to disable the first SL :
IF Long then
BUY 1 Share AT 20 Limit
Set Stop Price 15
ENDIF
IF C1 THEN
Sell AT 18 Stop
ENDIF
// I tried something like this but it doesn't seem to work
IF C1 THEN
Sell AT 18 Stop
Set Stop Price 0 // To disable it permanently
ENDIF
Best Reguards,
ZeroCafeine
The Sell at 18 Stop cancels the Set Stop Price 15.
Reason: Sell at 18 Stop is the more recent command / lower down the code.
Try …
If Close > 15 AND <= 18 Then
Sell at Market
Endif
Above will not cancel Set Stop Price 15 because above is an Order: at Market.
Maybe a cause could be that 18 is too close to 20, so the pending order may be turned into an AT-MARKET order if the required distance is greater.
You should check with the broker if, for that instrument or asset, that distance is ok.
You might then use IF…ENDIF to check whether you need to execute something or something else.
Ok ok,tks you, this number it’s just for exemple, I’m doing some backtest for learning how to program,
@Grahal I agree with you, because I got this problem before, even the selling order is at 18, but because I have also a sell stop at 15,
The software will make me exit at 15 instead of 18, when of course 18 is more favorable for an exit on a long order
@ Roberto I will try to find the exactly problem with a very small code and share it here, maybe after tomorrow
Tks again 😊