Hi,
I have 2 questions regarding trailing stops.
1 – In the following example:
SET TARGET pPROFIT 75
SET STOP pTRAILING 25
SET STOP pLOSS 35
I don’t understand when is the trailing stop executed if ever. Does the instruction sequence matter even if the Stop Loss in not touched?
2 – Is it possible to have an active trailing stop as a condition?
If longonmarket AND trailingstop // Active TrailingStop
THEN Buy 1 Contract // Position Size Increasing
ENDIF
Thanks for your help and patience
In the sequence:
SET TARGET pPROFIT 75
SET STOP pTRAILING 25
SET STOP pLOSS 35
the trailing stop will never be executed, as the last two lines are concurrent types of stop loss and, being the code read and executed sequentially, the last line will always override the previous one.
Your second snippet:
If longonmarket AND trailingstop THEN// Active TrailingStop
Buy 1 Contract .... // Position Size Increasing
ENDIF
has THEN misplaced in the line after IF, while it must be the last keyword in the same line as IF (comments aside). Anyway, the code seems correct, provided you have assigned trailingstop a value other than 0, based on a trailing stop snippet you have placed somewhere in your code.
Thanks Roberto. And thus I am lucky my strategies are profitable – I am still in papertrading -as they are not behaving as expected !!
With that sequence:
SET TARGET pPROFIT 75
SET STOP pLOSS 35
SET STOP pTRAILING 25
Will the trailing stop be executed? Or will it be interrupted at each new candle by the stop loss ?
If so, I guess it is better to code the trailing stop. I found the code in the forum
As you have written the code in the post above …
SET STOP pLOSS 35 will not be executed.
SET STOP pTRAILING 25 will be executed.
If you want SET STOP pLOSS 35 to execute then you will need to use a coded version of Trailing Stop.
There are loads here … 🙂
Snippet Link Library