Revisited this today and no matter where I place the SetStopLoss, there is a gap (sometimes negligible - sometimes not) between it being cancelled and the Sell at a Price on a Stop showing up.
In the end, I decided to keep the SetStopLoss active and use it as a Trailing Stop by recalculating '(StpLoss)'. Fortunately, a negative value is accepted to permit locking in profit. Admittedly, it's ugly - but it does work without any time gaps before the Stop Order is moved.
Hello Jad,
In your code SetStopLoss is under a condition:
Code: Select all
If MarketPosition = 0 then begin
SetStopLoss();
end;
Please try using the SetStopLoss command without any conditions. It will behave the same - the order will trigger only when there is an open position.
I have also noticed the following:
When cancel/replacing an order, sometimes one or more errors are returned with message: 'Another command is in execution'.
The result is, for example:
If the current Trailing Sell Stop is at 10 and the market moves up on the next tick to require the Stop to be moved to 11 and then the next tick to 12 and the next to 13, I will receive two of these errors. While while the Stop is moved to 11 after the first tick in the series, it remains at 11 until it is hit or until another tick causes it to move higher again.
My guess (and it's only a guess) is that MC has not received confirmation that the Order has been moved to 11 before the ticks requiring further moves are received.
If so, then that's understandable but once the confirmation of the move to 11 has been received, no further move of the order takes place even thought the script is continuing to request a move to 12 and then 13. Another request to 14 seems to be needed before the order is moved off 11. This does not always occur and is only happening when there is a flurry of activity. During slow periods, it does not happen.
It depends on the instrument you are using. The trailing price is calculated in the instrument currency. That is possible that 1 tick price change on the chart does not change the trailing price due to insignificant change expressed in the currency value.
min $ move (1 tick) = Min.Movment * Price Scale * Big Pont Value.
These values can be found in QuoteManager -> Edit symbol -> Settings.